1 package de.spring.webservices.binders;
3 import java.text.DateFormat;
4 import java.text.SimpleDateFormat;
6 import java.util.TimeZone;
8 import javax.xml.bind.annotation.adapters.XmlAdapter;
12 * ATTENTION: if you are using this custombinder you will have to create custom payload
13 * validators for Spring (AS FAR AS I KNOW)
16 public class XSDateTimeCustomBinder extends XmlAdapter<String, Date> {
19 public Date unmarshal(final String dateTime) throws Exception {
20 // X pattern just works from Java >= 1.7
21 final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
22 formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
24 return formatter.parse(dateTime);
28 public String marshal(final Date dateTime) throws Exception {
29 // X pattern just works from Java >= 1.7
30 final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
31 formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
33 return formatter.format(dateTime);