Merge pull request #10254 from volodymyr-babak/tb-date-fix

TbDate - use strict constructors instead of constructors with var args
This commit is contained in:
Andrew Shvayka 2024-02-23 15:57:07 +02:00 committed by GitHub
commit 703cd9f854
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,7 +35,6 @@ import java.time.format.DateTimeParseException;
import java.time.format.FormatStyle; import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAccessor;
import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@ -73,21 +72,37 @@ public class TbDate implements Serializable, Cloneable {
instant = Instant.ofEpochMilli(dateMilliSecond); instant = Instant.ofEpochMilli(dateMilliSecond);
} }
public TbDate(int year, int month, int date, String... tz) { public TbDate(int year, int month, int date) {
this(year, month, date, 0, 0, 0, 0, null);
}
public TbDate(int year, int month, int date, String tz) {
this(year, month, date, 0, 0, 0, 0, tz); this(year, month, date, 0, 0, 0, 0, tz);
} }
public TbDate(int year, int month, int date, int hrs, int min, String... tz) { public TbDate(int year, int month, int date, int hrs, int min) {
this(year, month, date, hrs, min, 0, 0, null);
}
public TbDate(int year, int month, int date, int hrs, int min, String tz) {
this(year, month, date, hrs, min, 0, 0, tz); this(year, month, date, hrs, min, 0, 0, tz);
} }
public TbDate(int year, int month, int date, int hrs, int min, int second, String... tz) { public TbDate(int year, int month, int date, int hrs, int min, int second) {
this(year, month, date, hrs, min, second, 0, null);
}
public TbDate(int year, int month, int date, int hrs, int min, int second, String tz) {
this(year, month, date, hrs, min, second, 0, tz); this(year, month, date, hrs, min, second, 0, tz);
} }
public TbDate(int year, int month, int date, int hrs, int min, int second, int secondMilli, String... tz) { public TbDate(int year, int month, int date, int hrs, int min, int second, int milliSecond) {
ZoneId zoneId = tz.length > 0 ? ZoneId.of(Arrays.stream(tz).findFirst().get()) : ZoneId.systemDefault(); this(year, month, date, hrs, min, second, milliSecond, null);
instant = parseInstant(year, month, date, hrs, min, second, secondMilli, zoneId); }
public TbDate(int year, int month, int date, int hrs, int min, int second, int milliSecond, String tz) {
ZoneId zoneId = tz != null && tz.length() > 0 ? ZoneId.of(tz) : ZoneId.systemDefault();
instant = parseInstant(year, month, date, hrs, min, second, milliSecond, zoneId);
} }
public Instant getInstant() { public Instant getInstant() {