Do you know a format for this kind of date without losing the last 3 numbers?
I used a select query in my project to extract a date from a table and I need to use this date for a second query and extract other information on another table. The Date I got from the first query has this structure and the value is only an example:
"2022-09-23-11.25.52.660135"
I need to use this Date as String in order to do the second query, but when I use the format, I lose the last 3 numbers ( 135 ) and obviously the select returns nothing because the date is wrong.
I used this DateFormat for the first try:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SS");
Formats like yyyy-MM-dd-HH.mm.ss.SSS and yyyy-MM-dd-HH.mm.ss.SSSSSS don't work because it will just add zeroes and I need the exact same Date.
To solve this issue i had to edit the format of the column in the model class of the desired table. In my case for example
@Column(name = "TIMESTAMP_B_B03") private Timestamp timestampB03;
I had to change Timestamp and use LocalDateTime to get microseconds
ps: the real format of the column on DB is Timestamp but you need to use LocalDateFormat in java.