In Java when I use Calendar.getInstance();
I get a Calendar
object for the current Timezone. But java.sql.Timestamp
is usually stored in U
Your code is already doing exactly what you want. Timestamp
(as well as Date
) does not have timezone information and should always contain a GMT timestamp (which ist what Calendar.getTimeInMillis()
returns).
The reson why you see local time printed is that the DateFormat
factory methods as well as Timestamp.toString()
implicitly use the system timezone.