mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-27 19:33:39 +00:00
8164669: Lazier initialization of java.time
Reviewed-by: scolebourne, chegar, alanb
This commit is contained in:
parent
dfa00059e2
commit
338343e0e1
@ -150,10 +150,12 @@ public final class Duration
|
||||
/**
|
||||
* The pattern for parsing.
|
||||
*/
|
||||
private static final Pattern PATTERN =
|
||||
private static class Lazy {
|
||||
static final Pattern PATTERN =
|
||||
Pattern.compile("([-+]?)P(?:([-+]?[0-9]+)D)?" +
|
||||
"(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of seconds in the duration.
|
||||
@ -387,7 +389,7 @@ public final class Duration
|
||||
*/
|
||||
public static Duration parse(CharSequence text) {
|
||||
Objects.requireNonNull(text, "text");
|
||||
Matcher matcher = PATTERN.matcher(text);
|
||||
Matcher matcher = Lazy.PATTERN.matcher(text);
|
||||
if (matcher.matches()) {
|
||||
// check for letter T but no time sections
|
||||
if (!charMatch(text, matcher.start(3), matcher.end(3), 'T')) {
|
||||
|
||||
@ -27,15 +27,8 @@ package sun.util.calendar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SimpleTimeZone;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@ -80,8 +73,6 @@ public class ZoneInfo extends TimeZone {
|
||||
private static final long ABBR_MASK = 0xf00L;
|
||||
private static final int TRANSITION_NSHIFT = 12;
|
||||
|
||||
private static final CalendarSystem gcal = CalendarSystem.getGregorianCalendar();
|
||||
|
||||
/**
|
||||
* The raw GMT offset in milliseconds between this zone and GMT.
|
||||
* Negative offsets are to the west of Greenwich. To obtain local
|
||||
@ -379,6 +370,7 @@ public class ZoneInfo extends TimeZone {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Gregorian gcal = CalendarSystem.getGregorianCalendar();
|
||||
CalendarDate date = gcal.newCalendarDate(null);
|
||||
date.setDate(year, month + 1, day);
|
||||
if (gcal.validate(date) == false) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user