Home » Java » java – XMLGregorian Calender get a date from sql-Exceptionshub

java – XMLGregorian Calender get a date from sql-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to convert simple date into XML GregorianCalender date.where date is saved in sql table and I am accessing date from there.my code is working fine but I am getting current date and time instead I want to get the specific date which user has enterd e.g 2019-12-24T08:00:06.000+01:00 but I am getting 2020-02-17T08:00:06.000+01:00…here is my code

else if (data.getClass().getName().equals("java.sql.Date"))
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(new Date());
XMLGregorianCalendar xCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
method.invoke(obj, xCal);
else
        ....

how to fix this problem. any help will be appreciated.

How to&Answers: