KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > conversion > DateToStringConverter


1 /*
2  * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * db4objects - Initial API and implementation
11  */

12 package org.eclipse.core.internal.databinding.conversion;
13
14 import java.util.Date JavaDoc;
15
16 import org.eclipse.core.databinding.conversion.IConverter;
17
18
19 /**
20  * Converts a Java.util.Date to a String using the current locale. Null date
21  * values are converted to an empty string.
22  *
23  * @since 1.0
24  */

25 public class DateToStringConverter extends DateConversionSupport implements IConverter {
26     public Object JavaDoc convert(Object JavaDoc source) {
27         if (source != null)
28             return format((Date JavaDoc)source);
29         return ""; //$NON-NLS-1$
30
}
31
32     public Object JavaDoc getFromType() {
33         return Date JavaDoc.class;
34     }
35
36     public Object JavaDoc getToType() {
37         return String JavaDoc.class;
38     }
39 }
40
Popular Tags