mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8349000: Performance improvement for Currency.isPastCutoverDate(String)
Reviewed-by: naoto, aturbanov
This commit is contained in:
parent
ee4caa4180
commit
250ff86dc8
1 changed files with 11 additions and 12 deletions
|
@ -32,8 +32,10 @@ import java.io.FileReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.ParseException;
|
import java.time.LocalDateTime;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -1156,7 +1158,7 @@ public final class Currency implements Serializable {
|
||||||
&& !isPastCutoverDate(prop.date)) {
|
&& !isPastCutoverDate(prop.date)) {
|
||||||
prop = null;
|
prop = null;
|
||||||
}
|
}
|
||||||
} catch (ParseException ex) {
|
} catch (DateTimeParseException ex) {
|
||||||
prop = null;
|
prop = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1196,15 +1198,12 @@ public final class Currency implements Serializable {
|
||||||
|| prop.fraction != fractionDigit);
|
|| prop.fraction != fractionDigit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPastCutoverDate(String s)
|
// cutOver adheres to ISO8601 Local Date Time format (excluding nano secs)
|
||||||
throws ParseException {
|
private static boolean isPastCutoverDate(String cutOver) {
|
||||||
SimpleDateFormat format = new SimpleDateFormat(
|
return System.currentTimeMillis() >
|
||||||
"yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
|
LocalDateTime.parse(cutOver, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
.toInstant(ZoneOffset.UTC)
|
||||||
format.setLenient(false);
|
.toEpochMilli();
|
||||||
long time = format.parse(s.trim()).getTime();
|
|
||||||
return System.currentTimeMillis() > time;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void info(String message, Throwable t) {
|
private static void info(String message, Throwable t) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue