|
@@ -2,6 +2,8 @@ package net.ranides.assira.time2;
|
|
|
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.time.ZonedDateTime;
|
|
import java.time.ZonedDateTime;
|
|
|
|
|
|
|
@@ -12,63 +14,67 @@ public class DateTimeLiteral {
|
|
|
|
|
|
|
|
public static final ZonedDateTime MAX = datetime(4000, 1, 1, 0, 0, 0);
|
|
public static final ZonedDateTime MAX = datetime(4000, 1, 1, 0, 0, 0);
|
|
|
|
|
|
|
|
- private static final int BASE_Y = 1900;
|
|
|
|
|
- private static final int BASE_M = 1;
|
|
|
|
|
- private static final int BASE_D = 1;
|
|
|
|
|
|
|
+ public static ZonedTime time(ZoneId zone, int h, int m, int s) {
|
|
|
|
|
+ return ZonedTime.of(zone, LocalTime.of(h, m, s));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static ZonedDate date(ZoneId zone, int y, int m, int d) {
|
|
|
|
|
+ return ZonedDate.of(zone, LocalDate.of(y, m, d));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static ZonedDateTime datetime(ZoneId zone, int y, int m, int d, int H, int M) {
|
|
|
|
|
+ return ZonedDateTime.of(y, m, d, H, M, 0, 0, zone);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static ZonedDateTime datetime(ZoneId zone, int y, int m, int d, int H, int M, int S) {
|
|
|
|
|
+ return ZonedDateTime.of(y, m, d, H, M, S, 0, zone);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public static ZonedTime time(int h, int m, int s) {
|
|
public static ZonedTime time(int h, int m, int s) {
|
|
|
- return ZonedTime.of(datetime(BASE_Y, BASE_M, BASE_D, h, m, s));
|
|
|
|
|
|
|
+ return time(ZoneId.systemDefault(), h, m, s);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static ZonedDate date(int y, int m, int d) {
|
|
public static ZonedDate date(int y, int m, int d) {
|
|
|
- return ZonedDate.of(datetime(y, m, d, 0, 0));
|
|
|
|
|
|
|
+ return date(ZoneId.systemDefault(), y, m, d);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static ZonedDateTime datetime(int y, int m, int d, int H, int M) {
|
|
public static ZonedDateTime datetime(int y, int m, int d, int H, int M) {
|
|
|
- return datetime(y, m, d, H, M, 0);
|
|
|
|
|
|
|
+ return datetime(ZoneId.systemDefault(), y, m, d, H, M);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static ZonedDateTime datetime(int y, int m, int d, int H, int M, int S) {
|
|
public static ZonedDateTime datetime(int y, int m, int d, int H, int M, int S) {
|
|
|
- return ZonedDateTime.of(y, m, d, H, M, S, 0, ZoneId.systemDefault());
|
|
|
|
|
|
|
+ return datetime(ZoneId.systemDefault(), y, m, d, H, M, S);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
public static ZonedTime timeUtc(int h, int m, int s) {
|
|
public static ZonedTime timeUtc(int h, int m, int s) {
|
|
|
- return ZonedTime.of(datetimeUtc(BASE_Y, BASE_M, BASE_D, h, m, s));
|
|
|
|
|
|
|
+ return time(DateTimeUtils.ZONE_UTC, h, m, s);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedTime timePolish(int h, int m, int s) {
|
|
|
|
|
- return ZonedTime.of(datetimePolish(BASE_Y, BASE_M, BASE_D, h, m, s));
|
|
|
|
|
|
|
+ public static ZonedDate dateUtc(int y, int m, int d) {
|
|
|
|
|
+ return date(DateTimeUtils.ZONE_UTC, y, m, d);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedDate dateUtc(int y, int m, int d) {
|
|
|
|
|
- return ZonedDate.of(datetimeUtc(y, m, d, 0, 0));
|
|
|
|
|
|
|
+ public static ZonedDateTime datetimeUtc(int y, int m, int d, int H, int M) {
|
|
|
|
|
+ return datetime(DateTimeUtils.ZONE_UTC, y, m, d, H, M);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedDate datePolish(int y, int m, int d) {
|
|
|
|
|
- return ZonedDate.of(datetimePolish(y, m, d, 0, 0));
|
|
|
|
|
|
|
+ public static ZonedDateTime datetimeUtc(int y, int m, int d, int H, int M, int S) {
|
|
|
|
|
+ return datetime(DateTimeUtils.ZONE_UTC, y, m, d, H, M, S);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedDateTime datetimeUtc(int y, int m, int d, int H, int M) {
|
|
|
|
|
- return datetimeUtc(y, m, d, H, M, 0);
|
|
|
|
|
|
|
+ public static ZonedTime timePolish(int h, int m, int s) {
|
|
|
|
|
+ return time(DateTimeUtils.ZONE_PL, h, m, s);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedDateTime datetimePolish(int y, int m, int d, int H, int M) {
|
|
|
|
|
- return datetimePolish(y, m, d, H, M, 0);
|
|
|
|
|
|
|
+ public static ZonedDate datePolish(int y, int m, int d) {
|
|
|
|
|
+ return date(DateTimeUtils.ZONE_PL, y, m, d);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
- public static ZonedDateTime datetimeUtc(int y, int m, int d, int H, int M, int S) {
|
|
|
|
|
- return ZonedDateTime.of(y, m, d, H, M, S, 0, DateTimeUtils.ZONE_UTC);
|
|
|
|
|
|
|
+ public static ZonedDateTime datetimePolish(int y, int m, int d, int H, int M) {
|
|
|
|
|
+ return datetime(DateTimeUtils.ZONE_PL, y, m, d, H, M);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ZoneExplicit
|
|
|
|
|
public static ZonedDateTime datetimePolish(int y, int m, int d, int H, int M, int S) {
|
|
public static ZonedDateTime datetimePolish(int y, int m, int d, int H, int M, int S) {
|
|
|
- return ZonedDateTime.of(y, m, d, H, M, S, 0, DateTimeUtils.ZONE_PL);
|
|
|
|
|
|
|
+ return datetime(DateTimeUtils.ZONE_PL, y, m, d, H, M, S);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|