List:General Discussion« Previous MessageNext Message »
From:Michael Dykman Date:August 21 2013 11:56pm
Subject:Re: Java UTC Calendar and Mysql TimeStamp - Gets me every time!!!!!
View as plain text  
Nick,

You should have answered your own question in the text.

The MySql TIMESTAMP type is, as all other timestamps in the *nix
world, a count of seconds since epoch time.  The Java function you are
using yields MILLI-seconds.  Divide it by 1000 and you should be good
to go.


On Wed, Aug 21, 2013 at 6:03 PM, Nick Khamis <symack@stripped> wrote:
> Hello Everyone,
>
> 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
>
>
> Our environments is:
>
> JDBC Driver = 5.1.26
> Mysql = 5.5
>
>
> show variables like 'time_zone%';
> +---------------+--------+
> | Variable_name | Value  |
> +---------------+--------+
> | time_zone     | +00:00 |
> +---------------+--------+
>
> SELECT @@global.sql_mode;
> +-------------------+
> | @@global.sql_mode |
> +-------------------+
> |                   |
> +-------------------+
>
> Not sure why I am getting this error.
>
>
> Thanks in Advance,
>
> Nick.



-- 
 - michael dykman
 - mdykman@stripped

 May the Source be with you.
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