I have the following code:
DateFormat dateFormat = new SimpleDateFormat(SQL_SERVER_DATE_FORMAT);
Date startDate;
startDate = (Date) dateFormat.parse(some_string_represents_date_received_from_sql_server);
where SQL_SERVER_DATE_FORMAT is:
public static final String SQL_SERVER_DATE_FORMAT = "yyyy-mm-dd'T'HH:mm:ss";
For some reason when
some_string_represents_date_received_from_sql_server = '2014-02-05T12:15:59.417'
I get this wrongly converted to 1388916959000
ticks which mean Sun Jan 05 12:15:59 GMT+02:00 2014
.
and when I have
some_string_represents_date_received_from_sql_server = '2014-01-30T16:30:00.437'
I get this correctly converted to 1391092200000
ticks which mean Thu Jan 30 16:30:00 GMT+02:00 2014
.
Any ideas?
Try DateFormat
for parsing as public static final String SQL_SERVER_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
instead of public static final String SQL_SERVER_DATE_FORMAT = "yyyy-mm-dd'T'HH:mm:ss";