1
|
package eu.etaxonomy.cdm.remote.editor;
|
2
|
|
3
|
import java.beans.PropertyEditorSupport;
|
4
|
|
5
|
import org.joda.time.DateTime;
|
6
|
import org.joda.time.format.DateTimeFormatter;
|
7
|
import org.joda.time.format.DateTimeFormatterBuilder;
|
8
|
|
9
|
public class DateTimeEditor extends PropertyEditorSupport {
|
10
|
|
11
|
private static DateTimeFormatter parser;
|
12
|
private static DateTimeFormatter printer;
|
13
|
|
14
|
static {
|
15
|
parser = new DateTimeFormatterBuilder().appendPattern("dd/MM/YYYY").appendOptional(new DateTimeFormatterBuilder().appendPattern(" HH:mm:ss").toParser()).toFormatter();
|
16
|
printer = new DateTimeFormatterBuilder().appendPattern("dd/MM/YYYY HH:mm:ss").toFormatter();
|
17
|
}
|
18
|
|
19
|
public void setAsText(String text) {
|
20
|
setValue(parser.parseDateTime(text));
|
21
|
}
|
22
|
|
23
|
public String getAsText() {
|
24
|
return printer.print((DateTime)getValue());
|
25
|
}
|
26
|
|
27
|
}
|