Last change
on this file since 223 was
223,
checked in by oschonef, 14 years ago
|
|
-
Property svn:eol-style set to
native
|
File size:
670 bytes
|
Line | |
---|
1 | package eu.clarin.cmdi.virtualcollectionregistry.model.mapper; |
---|
2 | |
---|
3 | import java.text.DateFormat; |
---|
4 | import java.text.SimpleDateFormat; |
---|
5 | import java.util.Date; |
---|
6 | import java.util.GregorianCalendar; |
---|
7 | |
---|
8 | import javax.xml.bind.annotation.adapters.XmlAdapter; |
---|
9 | |
---|
10 | public class DateAdapter extends XmlAdapter<String, Date> { |
---|
11 | private final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
---|
12 | |
---|
13 | public Date unmarshal(String date) throws Exception { |
---|
14 | Date utilDate = df.parse(date); |
---|
15 | GregorianCalendar cal = new GregorianCalendar(); |
---|
16 | cal.setTime(utilDate); |
---|
17 | return cal.getTime(); |
---|
18 | } |
---|
19 | |
---|
20 | public String marshal(Date date) throws Exception { |
---|
21 | return df.format(date); |
---|
22 | } |
---|
23 | |
---|
24 | } // class DateAdapter |
---|
Note: See
TracBrowser
for help on using the repository browser.