Two Laptop Bag*
The moose likes Other Open Source Projects and the fly likes How to convert a datetime value to XMLGregorianCalendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to convert a datetime value to XMLGregorianCalendar" Watch "How to convert a datetime value to XMLGregorianCalendar" New topic
Author

How to convert a datetime value to XMLGregorianCalendar

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
Dear all,

I want to convert a datetime value to a XMLGregorianCalendar for saving it into mysql database.

Here is my code:



After created a dt object, I want to convert it back to XMLGregorianCalendar so that I can save the datetime value in mysql database.

My database schema is shown as below/:

mysql> desc product_article;
+----------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+-------+
| product_id | int(11) | NO | MUL | NULL | |
| creation_date | date | YES | | NULL | |


As shown above, the creation_date is in date type.
After created a DateTime object, if the value is able to convert to XMLGregorianCalendar object, is possible to save the XMLGregorianCalendar object with datetime value into mysql database?

Or what is the usual way to create a datetime value in mysql database? Re. I am not sure whether I should use DateTime type rather than Date time for my database; and then get rid of the XMLGregorianCalendar, and use DateTime directly.

Very appreciate for any suggestion and help.
Merry Christmas & Happy New Year.

Sam
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

In MySQL the "DATETIME" and "TIMESTAMP" datatypes are basically the same having "yyyy-mm-dd HH:mm:ss" as pattern.

The "DATE" datatype is just "yyyy-mm-dd" as you would expect.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to convert a datetime value to XMLGregorianCalendar
 
Similar Threads
DataTime conversion
How to add JAXB customization to a particular element of an xsd?
count by current timestamp
MySQL - Date/Time and Timestamp Issues
date conversion