Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Papademuchos
Creator
Creator

parseDateInUTC and formatDateInUTC behave differently

parsedateInUTC and formatDateInUTC seem to behave differently.

First, I'm in the Pacific Time Zone. So 12 pm PST is 7 pm UTC.

If I do this: TalendDate.parseDateInUTC("yyyy-MM-dd HH:mm:ss","2020-09-23 12:00:00"), I get 23-09-2020 05:00:00, which is incorrect. It's 7 hours backwards instead of forwards.

But if I do this (at 12 pm today):

TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss", TalendDate.getCurrentDate() ), I get 2020-09-23 19:00:00, which is correct.

If I want a string date passed in converted to the correct UTC date, I have to do this:

TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",

TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss",

TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","2020-09-23 12:00:00"))) 

which is crazy - why do I have to parse date twice? why won't parseDateInUTC work? What am I missing?

Thanks in Advance!

Labels (2)
1 Reply
Jesperrekuh
Specialist
Specialist

For those who often forget , AM and PM, java HH is 00-23 and hh 01-12.

 

myJavaUtilDate.toInstant().toString() // Example: '2020-07-03T10:15:30.120Z'

The toString implementation uses the DateTimeFormatter.ISO_INSTANT format by default

 

Look at java's TimeZone format.

And at stackoverflow