Creating a GregorianCalendar instance from milliseconds

Just get an instance of GregorianCalendar and setTime with your java.sql.Timestamp timestamp:

Calendar cal=GregorianCalendar.getInstance();
cal.setTime(timestamp);

Edit: As peterh pointed out, GregorianCalendar.getInstance() will not provide a GregorianCalendar by default, because it is inherited fromCalendar.getInstance(), which can provide for example a BuddhistCalendar on some installations. To be sure to use a GregorianCalender use new GregorianCalendar() instead.


Timestamp timestamp = new Timestamp(23423434);
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTimeInMillis(timestamp.getTime());

To get a GregorianCalendar object and not a Calendar object. Like Michael's answer provides, you can also do the following:

long timestamp = 1234567890;
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(timestamp);

This assumes a UTC epoch timestamp.