Skip to content

Commit

Permalink
fix wrong date value with 12 hours clock on 12:XXPM time
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Feb 12, 2024
1 parent 793419e commit 6f96c7b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,15 @@ public int getCorrectHour(int hour) {
@Override
public Date getTime() {
JsDate jsDate = new JsDate();
jsDate.setHours(DayPeriod.PM.equals(dayPeriod) ? hour + 12 : hour);
if (DayPeriod.PM.equals(dayPeriod) && hour < 12) {
jsDate.setHours(hour + 12);
} else if (DayPeriod.AM.equals(dayPeriod) && hour == 12) {
jsDate.setHours(0);
} else {
jsDate.setHours(hour);
}
jsDate.setMinutes(minute);
jsDate.setSeconds(second);
return new Date((long) jsDate.getTime());
return new Date(new Double(jsDate.getTime()).longValue());
}
}

0 comments on commit 6f96c7b

Please sign in to comment.