How to convert TIMESTAMP / DATETIME to GregorianCalendar?

1

How do I convert a TIMESTAMP or DATETIME of MySQL into a GregorianCalendar of Java? Or a better idea?

In the class, the dataCadastro field is of type GregorianCalendar . I'm writing to the database in type TIMESTAMP dd-MM-yyyy 00:00:00 .

Now I want to do the opposite, get the bank and generate GregorianCalendar to compose the object.

The idea is to keep the complete data of the user's registration date!

How to do it?

    
asked by anonymous 24.08.2015 / 19:27

1 answer

1
Timestamp ts = seuTimeStamp;
GregorianCalendar c = new GregorianCalendar();
c.setTime(ts);

or, if it is Date

Date d = seuDate;
GregorianCalendar c = new GregorianCalendar();
c.setTime(d);
    
24.08.2015 / 20:13