Create timestamp without timeZone

How can I create java.sql.timestamp without a time zone (I get 2007-09-23T10:10:10Z and I pretend 2007-09-23T10:10:10 ).

I'm trying to

 Timestamp timestamp = Timestamp.valueOf("2010-10-23 12:05:16"); 

but in debug I saw that cdate 2007-09-23T10:10:10.000+0100 instead of 2007-09-23T10:10:10

+4
source share
1 answer

The timestamp does not have a time zone. When you show a timestamp as a string, it displays the time and indicates the time zone, because otherwise you might not know what time it represents. And he chooses to use the default time zone (yours), because the one with which you are most familiar.

Saying this, 12:00:00 means nothing. Saying 12:00 in your time zone means something. But the timestamp contains only instantaneous time. You can display this instant time in any time zone in which you want to use DateFormat.

Note: Timestamp.valueOf("2010-10-23 12:05:16"); means "create a timestamp with a given time in the default time zone."

+11
source

Source: https://habr.com/ru/post/1388283/


All Articles