Guest User

Untitled

a guest
Jan 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import javax.xml.bind.annotation.adapters.XmlAdapter;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Date;
  4.  
  5. public class DateAdapter extends XmlAdapter<String, Date> {
  6. private final SimpleDateFormat dateFormat = new
  7. SimpleDateFormat("yyyyMMdd'T'HHmmss.SSSz");
  8.  
  9. @Override
  10. public String marshal(Date v) throws Exception {
  11. synchronized (dateFormat) {
  12. return dateFormat.format(v);
  13. }
  14. }
  15.  
  16. @Override
  17. public Date unmarshal(String v) throws Exception {
  18. synchronized (dateFormat) {
  19. return dateFormat.parse(v);
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment