Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.xml.bind.annotation.adapters.XmlAdapter;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class DateAdapter extends XmlAdapter<String, Date> {
- private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
- @Override
- public String marshal(Date v) throws Exception {
- synchronized (dateFormat) {
- return dateFormat.format(v);
- }
- }
- @Override
- public Date unmarshal(String v) throws Exception {
- synchronized (dateFormat) {
- return dateFormat.parse(v);
- }
- }
- }
- 2001-07-04T12:08:56.235+03:00
- Fri Jan 01 02:59:59 MSK 2010
- riskMetric.getUpdateDateTime().getCalendarDate()
- returns 2010-01-01T02:59:59.000+0300
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement