Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.datatype.XMLGregorianCalendar;
import org.joda.time.DateTime;

public class Main {
    public static DateTime xmlToDateTime(final XMLGregorianCalendar xmlCal) {
        DateTime result = null;
        if (xmlCal != null) {
            int hourOfDay = xmlCal.getHour();
            int minuteOfHour = xmlCal.getMinute();
            int secondOfMinute = xmlCal.getSecond();
            int milliOfSecond = xmlCal.getMillisecond();

            if (hourOfDay < 0) {
                hourOfDay = 0;
            }
            if (minuteOfHour < 0) {
                minuteOfHour = 0;
            }
            if (secondOfMinute < 0) {
                secondOfMinute = 0;
            }
            if (milliOfSecond < 0) {
                milliOfSecond = 0;
            }
            result = new DateTime(xmlCal.getYear(), xmlCal.getMonth(), xmlCal.getDay(), hourOfDay, minuteOfHour,
                    secondOfMinute, milliOfSecond);
        }
        return result;
    }
}