• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to convert a datetime value to XMLGregorianCalendar

Ranch Hand
Posts: 229
  • 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.

Posts: 3648
Mac OS X Firefox Browser Java
  • 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.

Not so fast naughty spawn! I want you to know about
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!