Revision f1a25720
Added by Katja Luther over 6 years ago
- ID f1a25720755daa96e8838a617a660dfced7b9f31
- Parent 23e50194
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/IsoDateTimeEditor.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.remote.editor; |
2 | 2 |
|
3 | 3 |
import java.beans.PropertyEditorSupport; |
4 |
import java.time.ZonedDateTime; |
|
5 |
import java.time.format.DateTimeFormatter; |
|
4 | 6 |
|
5 |
import org.joda.time.DateTime; |
|
6 |
import org.joda.time.format.DateTimeFormatter; |
|
7 |
import org.joda.time.format.ISODateTimeFormat; |
|
8 | 7 |
|
9 | 8 |
public class IsoDateTimeEditor extends PropertyEditorSupport { |
10 | 9 |
|
11 |
private static DateTimeFormatter iso8601Format = ISODateTimeFormat.dateTime(); |
|
12 |
|
|
13 |
public void setAsText(String text) { |
|
14 |
setValue(iso8601Format.parseDateTime(text)); |
|
10 |
private static DateTimeFormatter iso8601Format = DateTimeFormatter.ISO_DATE_TIME; |
|
11 |
|
|
12 |
@Override |
|
13 |
public void setAsText(String text) { |
|
14 |
setValue(iso8601Format.parse(text)); |
|
15 | 15 |
} |
16 |
|
|
17 |
public String getAsText() { |
|
18 |
return iso8601Format.print((DateTime)getValue()); |
|
16 |
|
|
17 |
@Override |
|
18 |
public String getAsText() { |
|
19 |
return ((ZonedDateTime)getValue()).format(iso8601Format); |
|
19 | 20 |
} |
20 | 21 |
|
21 | 22 |
} |
Also available in: Unified diff
first implementation for change from joda time to java8 time