List:General Discussion« Previous MessageNext Message »
From:hsv Date:August 22 2013 2:39am
Subject:Re: Java UTC Calendar and Mysql TimeStamp - Gets me every
time!!!!!
View as plain text  
>>>> 2013/08/21 18:03 -0400, Nick Khamis >>>>
We have the following mysql timetampe field

startdate | timestamp | NO   |     | 0000-00-00 00:00:00

When trying to insert a long value in there:

Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.getTimeInMillis();

We are presented with the following error:

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect
datetime value: '1377119243640' for column 'stopdate' at row 1
<<<<<<<<
Ugh, where is the SQL?

In any case, although it looks as if that is MySQL s internal TIMESTAMP representation,
one does not directly use Unix timestamps; instead, one converts them with the MySQL
function FROM_UNIXTIME.

The same effect may be gotten with any timestamp-formatting function that yields a string
in the form '2013/08/21 18:03:00' (it is all one whether the separator is hyphen, slant,
colon, ...).

Thread
Java UTC Calendar and Mysql TimeStamp - Gets me every time!!!!!Nick Khamis21 Aug
  • Re: Java UTC Calendar and Mysql TimeStamp - Gets me every time!!!!!Michael Dykman21 Aug
  • Re: Java UTC Calendar and Mysql TimeStamp - Gets me everytime!!!!!hsv22 Aug
    • Re: Java UTC Calendar and Mysql TimeStamp - Gets me every time!!!!!Nick Cameo22 Aug
      • Re: Java UTC Calendar and Mysql TimeStamp - Gets me everytime!!!!!hsv23 Aug
    • Re: Java UTC Calendar and Mysql TimeStamp - Gets me every time!!!!!Nick Cameo22 Aug