Question

Maybe this is a recurrent issue, but I need to explain my problem.

I must convert date+hour to Unix time format. I use Apache Commons Lang library, DateUtils class:

Date date = DateUtils.parseDate(strStartDateTime, new String[] { "ddMMyyyyHHmmss" });
Long dateLong = new Long(date.getTime());

Maybe Java Date class is old for this, but it seems to work fine.

But lately, I have detected that the same input, in right expected format, is returning different output in different executions.

I have been looking for a similar issue, and I have read that Java Date is old, joda-time library is recommended, etc.

It would be easy to convert with joda-time, but, why is this happening? Is reliable the code above? It's very likely I'm not taking something into account.

Any help or suggestion would be very appreciated. Thanks in advance.

Was it helpful?

Solution

Excuse me, but finally I found the error. There was a wrong attribute definition. It was my programming error; nothing related to time conversion. Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top