Skip to content

Commit

Permalink
Fix for incorrect timezone selection (#1046)
Browse files Browse the repository at this point in the history
* Fix for incorrect timezone selection
  • Loading branch information
alex0x08 authored Nov 4, 2023
1 parent f2b1a62 commit 368f462
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/main/java/ru/org/linux/search/SearchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,8 @@ public boolean isDateSelected() {
}

public long atEndOfDaySelected(DateTimeZone tz) {
Calendar calendar = Calendar.getInstance();
final Calendar calendar = tz!=null? Calendar.getInstance(tz.toTimeZone()) : Calendar.getInstance();
calendar.setTime(new Date(dt));
if (tz!=null) {
calendar.setTimeZone(tz.toTimeZone());
}
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Expand All @@ -178,11 +175,8 @@ public long atEndOfDaySelected(DateTimeZone tz) {
}

public long atStartOfDaySelected(DateTimeZone tz) {
Calendar calendar = Calendar.getInstance();
final Calendar calendar = tz!=null? Calendar.getInstance(tz.toTimeZone()) : Calendar.getInstance();
calendar.setTime(new Date(dt));
if (tz!=null) {
calendar.setTimeZone(tz.toTimeZone());
}
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Expand Down

0 comments on commit 368f462

Please sign in to comment.