cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Impexes save 12:00:00 PM in 00:00:00 AM

0 Kudos
562

Hello,

I'm new with Hybris and i noticed that in my impexes with startTime[dateformat = yyyy-MM-dd hh:mm:ss] with the value 12:00:00 that is clearly 12:00 PM in the database are saved as 00:00:00 and this is wrong.

Can someone tell me how can i fix this problem? I can't see any errors and i dont know how to avoid this situation.

Thank You

Accepted Solutions (0)

Answers (1)

Answers (1)

mansurarisoy
Contributor

It's not about ImpEx. It's about how date formatting works. As it documented in Oracle website (https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html) lowercase-letter h is used for hour in am/pm (1/12) while uppercase-letter H is used for hour in day (0-23)

If you want to use 0-23 format, you need to change date-format value in the ImpEx header as [dateformat = yyyy-MM-dd HH:mm:ss]

The following code snippet shows the difference you are experiencing:

SimpleDateFormat SDF1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
SimpleDateFormat SDF2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


String dateToParse = "2021-03-27 12:00:00";
System.out.println(SDF1.parse(dateToParse));
System.out.println(SDF2.parse(dateToParse));

The output

Sat Mar 27 00:00:00 EET 2021
Sat Mar 27 12:00:00 EET 2021
Ask a Question