aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java
blob: 382db45ac74cd891d2c11a412b58841cdc1c6fdf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.juick.xml.adapters;

import com.juick.util.DateFormattersHolder;

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

/**
 * Created by vitalyster on 15.11.2016.
 */

public class SimpleDateAdapter extends XmlAdapter<String, Date> {

    @Override
    public String marshal(Date v) throws Exception {
        return DateFormattersHolder.getMessageFormatterInstance().format(v);
    }

    @Override
    public Date unmarshal(String v) throws Exception {
        return DateFormattersHolder.getMessageFormatterInstance().parse(v);
    }
}