org.opentestsystem.authoring.testauth.config.JodaDateTimeXmlAdapter.java Source code

Java tutorial

Introduction

Here is the source code for org.opentestsystem.authoring.testauth.config.JodaDateTimeXmlAdapter.java

Source

/*******************************************************************************
 * Educational Online Test Delivery System
 * Copyright (c) 2013 American Institutes for Research
 * 
 * Distributed under the AIR Open Source License, Version 1.0
 * See accompanying file AIR-License-1_0.txt or at
 * http://www.smarterapp.org/documents/American_Institutes_for_Research_Open_Source_Software_License.pdf
 ******************************************************************************/
package org.opentestsystem.authoring.testauth.config;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import org.joda.time.DateTime;

public class JodaDateTimeXmlAdapter extends XmlAdapter<String, DateTime> {

    @Override
    public DateTime unmarshal(final String datetime) throws Exception {
        return DateTime.parse(datetime);
    }

    @Override
    public String marshal(final DateTime datetime) throws Exception {
        return datetime.toString();
    }
}