All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aeontronix.commons.xml.jaxb.JAXBDateAdapter Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2014 Kloudtek Ltd
 */

package com.aeontronix.commons.xml.jaxb;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * JABX adapter to convert a java.util.Date to a date in the format of yyyy-MM-dd.
 */
public class JAXBDateAdapter extends XmlAdapter {
    private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");

    public synchronized String marshal(Date date) throws Exception {
        return dateFormatter.format(date);
    }

    public synchronized Date unmarshal(String dateString) throws Exception {
        return dateFormatter.parse(dateString);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy