Convert XMLGregorianCalendar To Date I.e "MM/DD/YYYY Hh:mm:ss AM"
Answer : You can do this to return a Date : calendar.toGregorianCalendar().getTime() I found that code from this tutorial. From there, you can use a SimpleDateFormat to turn it into a string in the format you want. But, if you're using JDBC to save the date in the database, you probably can pass in the Date directly with this method: preparedStatement.setDate(colNum, myDate); Here is more clear answer: Get instance of Date from XMLGregorianCalendar instance: Date date = xmlCalendar.toGregorianCalendar().getTime(); I found that code from Convert XMLGregorianCalendar to Date in Java Format that Date instance with format "MM/dd/yyyy hh:mm:ss a", you will get MM/DD/YYYY hh:mm:ss AM format DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a"); String formattedDate = formatter.format(date) From Convert Date to String in Java For inserting database you would do what Daniel suggested If you want to insert your date on a database I would first do w...