How to convert from Timestamp to Calendar?

3

I need to convert a resultSet of the database that returns Timestamp to a variable of type Calendar.

    
asked by anonymous 04.06.2015 / 22:34

1 answer

3

You can Calendar inform the time , which receives an instance of Date .

How Timestamp is subclass of Date , you can do something like this:

public static Calendar timestampToCalendar(final Timestamp timestamp) {
    final Calendar cal = Calendar.getInstance();
    cal.setTime(timestamp);
    return cal;
}
    
04.06.2015 / 22:45