Reputation: 138
I have a db in mysql in which one column is of timstamp
datatype.
It stores timstamp in this format yyyy-mm-dd hh-mm-ss
on both windows and linux.
But when i am fetching data from mysql from my java code, it brings data in this format May 11, 2018, 11:35:34 AM
on my windows and in this format May 11, 2018 11:35:34 AM
on linux ubuntu
.
How make timestamp format consistent?
Upvotes: 0
Views: 246
Reputation: 32973
This is caused by a change in behavior in JDK9, where the default formats being used are now those of Unicode CLDR, as explained here:
The article explains one way of changing this behavior, by overriding the java.locale.providers
property.
The solution I would prefer (as although more elaborate it also allows for more flexibility) is to always use an explicit formatter for date time values. Eg look here
Upvotes: 1