Revision f1a25720
Added by Katja Luther over 6 years ago
- ID f1a25720755daa96e8838a617a660dfced7b9f31
- Parent 23e50194
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/DateTimeEditor.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.remote.editor; |
2 | 2 |
|
3 | 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; |
|
4 |
import java.time.ZonedDateTime; |
|
5 |
import java.time.format.DateTimeFormatter; |
|
6 |
import java.time.format.DateTimeFormatterBuilder; |
|
8 | 7 |
|
9 | 8 |
public class DateTimeEditor extends PropertyEditorSupport { |
10 | 9 |
|
... | ... | |
12 | 11 |
private static DateTimeFormatter printer; |
13 | 12 |
|
14 | 13 |
static { |
15 |
parser = new DateTimeFormatterBuilder().appendPattern("dd/MM/YYYY").appendOptional(new DateTimeFormatterBuilder().appendPattern(" HH:mm:ss").toParser()).toFormatter();
|
|
14 |
parser = new DateTimeFormatterBuilder().appendPattern("dd/MM/YYYY").appendOptional(new DateTimeFormatterBuilder().appendPattern(" HH:mm:ss").toFormatter()).toFormatter();
|
|
16 | 15 |
printer = new DateTimeFormatterBuilder().appendPattern("dd/MM/YYYY HH:mm:ss").toFormatter(); |
17 | 16 |
} |
18 |
|
|
19 |
public void setAsText(String text) { |
|
20 |
setValue(parser.parseDateTime(text)); |
|
17 |
|
|
18 |
@Override |
|
19 |
public void setAsText(String text) { |
|
20 |
setValue(parser.parse(text)); |
|
21 | 21 |
} |
22 |
|
|
23 |
public String getAsText() { |
|
24 |
return printer.print((DateTime)getValue()); |
|
22 |
|
|
23 |
@Override |
|
24 |
public String getAsText() { |
|
25 |
return ((ZonedDateTime)getValue()).format(printer); |
|
25 | 26 |
} |
26 | 27 |
|
27 | 28 |
} |
Also available in: Unified diff
first implementation for change from joda time to java8 time