Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert a datetime value to XMLGregorianCalendar

 
sam White
Ranch Hand
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic