Skip to content

Commit b8948e8

Browse files
shuohaosonus21
andauthored
dateTime based on the current time zone (#174)
* dateTime based on the current time zone * dateTime based on the current time zone Co-authored-by: Sonu Kumar <[email protected]>
1 parent fbdd41d commit b8948e8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/DateTimeUtils.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818

1919
import java.time.Instant;
2020
import java.time.LocalDate;
21-
import java.time.ZoneOffset;
21+
import java.time.ZoneId;
2222
import java.time.ZonedDateTime;
2323
import java.time.format.DateTimeFormatter;
2424

2525
public final class DateTimeUtils {
2626

27-
private static final DateTimeFormatter simple = DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm");
27+
private static final DateTimeFormatter simple = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
2828

29-
DateTimeUtils() {}
29+
DateTimeUtils() {
30+
}
3031

3132
private static String hourString(long hour) {
3233
if (hour > 1) {
@@ -116,15 +117,15 @@ public static String formatMilliToString(Long milli) {
116117
return "";
117118
}
118119
Instant instant = Instant.ofEpochMilli(milli);
119-
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, java.time.ZoneId.of("UTC"));
120+
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
120121
return zonedDateTime.format(simple);
121122
}
122123

123124
public static LocalDate localDateFromMilli(long millis) {
124-
return Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC).toLocalDate();
125+
return Instant.ofEpochMilli(millis).atZone(ZoneId.systemDefault()).toLocalDate();
125126
}
126127

127128
public static LocalDate today() {
128-
return LocalDate.now(ZoneOffset.UTC);
129+
return LocalDate.now(ZoneId.systemDefault());
129130
}
130131
}

0 commit comments

Comments
 (0)