0

I am working on a Java web base project, where I am using web service to access date and update the date, my screen has a date field, which I need to update with the data acquired form the web service, but the web service date is of type XMLGregorianCalendar.

This is what I have:

public class Testing {

/**
 * @param args
 */
public static void main(String[] args) {


    DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    Date date = null;
    try {
        date = (Date)df.parse("5-5-2012");
        System.out.println("Date Date" + date);
    } catch (ParseException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    GregorianCalendar gregory = new GregorianCalendar();
    gregory.setTime(date);
     System.out.println(""+gregory);

     XMLGregorianCalendar calendar =null;
    try {
        calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregory);
    } catch (DatatypeConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    calendar.setTimezone( DatatypeConstants.FIELD_UNDEFINED );
    someDoa.setdate(calendar);

}

}

But the result is:

SEVERE: Servlet.service() for servlet default threw exception
javax.xml.ws.soap.SOAPFaultException: java.lang.IllegalArgumentException: Incorrect Offset :Incorrect Offset :needs a leading +/- sign
4

0 に答える 0