8247706: Unintentional use of new Date(year...) with absolute year
Reviewed-by: naoto, rriggs
This commit is contained in:
parent
4f2edacaaf
commit
175b597ad2
test/jdk/java
text/Format/DateFormat
time/tck/java/time/format
util/Calendar
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1067,7 +1067,7 @@ public class DateFormatRegression extends IntlTest {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
|
||||
@SuppressWarnings("deprecation")
|
||||
String result = fmt.format(new Date(1999, 0, 1));
|
||||
String result = fmt.format(new Date(1999 - 1900, 0, 1));
|
||||
logln("format()=>" + result);
|
||||
if (!result.endsWith("PST")) {
|
||||
errln("FAIL: SimpleDataFormat.format() did not retrun PST");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -180,7 +180,7 @@ public class TCKLocalizedPrinterParser {
|
||||
@Test(dataProvider="time")
|
||||
public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
|
||||
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
|
||||
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
|
||||
Date oldDate = new Date(1970 - 1900, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
|
||||
String text = old.format(oldDate);
|
||||
|
||||
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);
|
||||
@ -192,7 +192,7 @@ public class TCKLocalizedPrinterParser {
|
||||
@Test(dataProvider="time")
|
||||
public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
|
||||
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
|
||||
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
|
||||
Date oldDate = new Date(1970 - 1900, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
|
||||
String text = old.format(oldDate);
|
||||
|
||||
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -147,7 +147,7 @@ public class FieldStateTest extends IntlTest {
|
||||
+ "Then, getTime and set week of year to 43.");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Date d = new Date(2003 - 1990, OCTOBER, 31);
|
||||
Date d = new Date(2003 - 1900, OCTOBER, 31);
|
||||
cal.setTime(d);
|
||||
cal.set(DAY_OF_WEEK, SUNDAY);
|
||||
cal.set(2003, OCTOBER, 31); // 2003/10/31 is Friday.
|
||||
|
Loading…
x
Reference in New Issue
Block a user