< prev index next >
test/java/text/Format/DateFormat/DateFormatRegression.java
Print this page
@@ -39,11 +39,11 @@
public static void main(String[] args) throws Exception {
new DateFormatRegression().run(args);
}
public void Test4029195() {
-
+ @SuppressWarnings("deprecation")
Date today = new Date();
logln("today: " + today);
SimpleDateFormat sdf = (SimpleDateFormat)SimpleDateFormat.getDateInstance();
@@ -72,23 +72,24 @@
}
public void Test4052408() {
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, Locale.US);
+ @SuppressWarnings("deprecation")
Date date = new Date(97, Calendar.MAY, 3, 8, 55);
String str;
logln(str = fmt.format(date));
if (!str.equals("5/3/97 8:55 AM"))
errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str);
- Hashtable expected = new Hashtable();
- expected.put(new Integer(DateFormat.MONTH_FIELD), "5");
- expected.put(new Integer(DateFormat.DATE_FIELD), "3");
- expected.put(new Integer(DateFormat.YEAR_FIELD), "97");
- expected.put(new Integer(DateFormat.HOUR1_FIELD), "8");
- expected.put(new Integer(DateFormat.MINUTE_FIELD), "55");
- expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM");
+ Map<Integer,String> expected = new HashMap<>();
+ expected.put(DateFormat.MONTH_FIELD, "5");
+ expected.put(DateFormat.DATE_FIELD, "3");
+ expected.put(DateFormat.YEAR_FIELD, "97");
+ expected.put(DateFormat.HOUR1_FIELD, "8");
+ expected.put(DateFormat.MINUTE_FIELD, "55");
+ expected.put(DateFormat.AM_PM_FIELD, "AM");
StringBuffer buf = new StringBuffer();
String fieldNames[] = {
"ERA_FIELD",
"YEAR_FIELD",
@@ -118,11 +119,11 @@
str = new String(dst);
log(i + ": " + fieldNames[i] +
", \"" + str + "\", " +
pos.getBeginIndex() + ", " +
pos.getEndIndex());
- String exp = (String) expected.get(new Integer(i));
+ String exp = expected.get(i);
if ((exp == null && str.length() == 0) ||
str.equals(exp))
logln(" ok");
else {
logln(" expected " + exp);
@@ -133,10 +134,11 @@
}
/**
* Verify the function of the [s|g]et2DigitYearStart() API.
*/
+ @SuppressWarnings("deprecation")
public void Test4056591() {
try {
SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US);
Date start = new Date(1809-1900, Calendar.DECEMBER, 25);
fmt.set2DigitYearStart(start);
@@ -253,10 +255,11 @@
logln(df.parse("35/01/1971").toString());
} catch (ParseException e) {ok=true;}
if (!ok) errln("Fail: Lenient not working");
}
+ @SuppressWarnings("deprecation")
public void Test4065240() {
Date curDate;
DateFormat shortdate, fulldate;
String strShortDate, strFullDate;
Locale saveLocale = Locale.getDefault();
@@ -295,10 +298,11 @@
but rather compared for equivalency. This may necessitate adding a
(package private) method to Calendar to test for equivalency.
Currently this bug breaks MessageFormat.toPattern
*/
+ @SuppressWarnings("deprecation")
public void Test4071441() {
DateFormat fmtA = DateFormat.getInstance();
DateFormat fmtB = DateFormat.getInstance();
Calendar calA = fmtA.getCalendar();
Calendar calB = fmtB.getCalendar();
@@ -486,10 +490,11 @@
}
public void Test4101483() {
SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US);
FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD);
+ @SuppressWarnings("deprecation")
Date d= new Date(9234567890L);
StringBuffer buf = new StringBuffer("");
logln(sdf.format(d, buf, fp).toString());
logln(d + " => " + buf);
logln("beginIndex = " + fp.getBeginIndex());
@@ -506,10 +511,11 @@
* work on all locales.
*/
public void Test4103340() {
// choose a date that is the FIRST of some month
// and some arbitrary time
+ @SuppressWarnings("deprecation")
Date d=new Date(97, 3, 1, 1, 1, 1);
SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US);
String s = d.toString();
String s2 = df.format(d);
@@ -536,10 +542,11 @@
SimpleDateFormat sdf = new SimpleDateFormat();
String pattern = "'time' hh:mm";
sdf.applyPattern(pattern);
logln("pattern: \"" + pattern + "\"");
+ @SuppressWarnings("deprecation")
Object[] DATA = {
"time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30),
"time 10:x", new ParsePosition(0), null,
"time 10x", new ParsePosition(0), null,
};
@@ -696,10 +703,11 @@
*/
public void Test4151631() {
String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'";
logln("pattern=" + pattern);
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
+ @SuppressWarnings("deprecation")
String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0));
if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) {
errln("Fail: result=" + result);
}
else {
@@ -709,10 +717,11 @@
/**
* 'z' at end of date format throws index exception in SimpleDateFormat
* CANNOT REPRODUCE THIS BUG ON 1.2FCS
*/
+ @SuppressWarnings("deprecation")
public void Test4151706() {
SimpleDateFormat fmt =
new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US);
try {
Date d = fmt.parse("Thursday, 31-Dec-98 23:00:00 GMT");
@@ -753,10 +762,11 @@
/**
* Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US
* as "EST" or "CST", not Australian "EST" and "CST".
*/
+ @SuppressWarnings("deprecation")
public void Test4406615() {
Locale savedLocale = Locale.getDefault();
TimeZone savedTimeZone = TimeZone.getDefault();
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
@@ -821,10 +831,11 @@
/* We expect 2-digit year formats to put 2-digit years in the right
* window. Out of range years, that is, anything less than "00" or
* greater than "99", are treated as literal years. So "1/2/3456"
* becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC.
*/
+ @SuppressWarnings("deprecation")
Object[] DATA = {
"02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29),
"01/23/01", new Date(2001-1900, Calendar.JANUARY, 23),
"04/05/-1", new Date( -1-1900, Calendar.APRIL, 5),
"01/23/-9", new Date( -9-1900, Calendar.JANUARY, 23),
@@ -876,10 +887,11 @@
public void Test4210209() {
String pattern = "MMM d, yyyy";
DateFormat fmt = new SimpleDateFormat(pattern,
DateFormatSymbols.getInstance(Locale.US));
fmt.getCalendar().setLenient(false);
+ @SuppressWarnings("deprecation")
Date d = new Date(2000-1900, Calendar.FEBRUARY, 29);
String s = fmt.format(d);
logln(d + " x " + pattern + " => " + s);
ParsePosition pos = new ParsePosition(0);
d = fmt.parse(s, pos);
@@ -955,10 +967,11 @@
}
}
}
}
+ @SuppressWarnings("deprecation")
public void Test4253490() throws ParseException {
SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US);
GregorianCalendar cal = new GregorianCalendar();
@@ -1024,10 +1037,11 @@
* Bug in handling of time instance; introduces in fix for 4213086.
*/
public void Test4250359() {
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US);
+ @SuppressWarnings("deprecation")
Date d = new Date(1999-1900, Calendar.DECEMBER, 25,
1, 2, 3);
String s = df.format(d);
// If the bug is present, we see "1:02 AM 1:02 AM".
// Look for more than one instance of "AM".
@@ -1050,10 +1064,11 @@
// XXX: Test assumes "PST" is not TimeZoneNames_ja. Need to
// pick up another time zone when L10N is done to that file.
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));
logln("format()=>" + result);
if (!result.endsWith("PST")) {
errln("FAIL: SimpleDataFormat.format() did not retrun PST");
}
< prev index next >