/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 4823811
* @summary Confirm that text which includes numbers with a trailing minus sign is parsed correctly.
*/
public class Bug4823811 {
"============================================================";
/*
* I don't use static import here intentionally so that this test program
* can be run on JDK 1.4.2.
*/
// private static int JAN = Calendar.JANUARY;
// private static int FEB = Calendar.FEBRUARY;
// private static int MAR = Calendar.MARCH;
// private static int AUG = Calendar.AUGUST;
// private static int SEP = Calendar.SEPTEMBER;
// private static int OCT = Calendar.OCTOBER;
// private static int NOV = Calendar.NOVEMBER;
// private static int DEC = Calendar.DECEMBER;
"yyyy MMMM d H m s",
"yyyy MM dd hh mm ss",
/*
* Because 1-based HOUR_OF_DAY, 1-based HOUR, MONTH, and YEAR fields
* are parsed using different code from the code for other numeric
* fields, I prepared YEAR-preceding patterns and SECOND-preceding
* patterns.
*/
"yyyy M d h m s",
" yyyy M d h m s",
"yyyy M d h m s ",
"s m h d M yyyy",
" s m h d M yyyy",
"s m h d M yyyy ",
};
// for Arabic formatter and modified English formatter
{"--", "-/", "::", ":/", "\uff0d\uff0d", "\uff0d/"},
// for English formatter and modified Arabic formatter
{"--", "/-", "::", "/:", "\uff0d\uff0d", "/\uff0d"},
};
/*
* Format:
* +-------------------------------------------------------------------+
* | Input | Output |
* +---------------------+---------------------------------------------|
* | datesEG & datesUS | formattedDatesEG & formattedDatesUS |
* +-------------------------------------------------------------------+
*
* Parse:
* +-------------------------------------------------------------------+
* | Input | Output |
* |---------------------+---------------------------------------------|
* | datesToParse | datesEG & datesUS |
* +-------------------------------------------------------------------+
*/
// "JUNE" and "JULY" are replaced with a localized month name later.
{"2008 JULY 20 3 12 83",
"2008 JULY 20 3 12 83",
"2008 JULY 20 3 12 83"},
{"2008 07 20 03 12 83",
"2008 07 20 03 12 83",
"2008 07 20 03 12 83"},
{"2008 7 20 3 12 83",
"2008 7 20 3 12 83",
"2008 7 20 3 12 83"},
{" 2008 7 20 3 12 83",
" 2008 7 20 3 12 83",
" 2008 7 20 3 12 83",
"2008 7 20 3 12 83"},
{"2008 7 20 3 12 83 ",
"2008 7 20 3 12 83 ",
"2008 7 20 3 12 83"},
{"83 12 3 20 7 2008",
"83 12 3 20 7 2008",
"83 12 3 20 7 2008"},
{" 83 12 3 20 7 2008",
" 83 12 3 20 7 2008",
" 83 12 3 20 7 2008",
"83 12 3 20 7 2008"},
{"83 12 3 20 7 2008 ",
"83 12 3 20 7 2008 ",
"83 12 3 20 7 2008"},
};
// For formatting
{"2008 JULY 20 3 13 23",
"2009 JULY 20 3 13 23",
null},
{"2008 07 20 03 13 23",
"2009 07 20 03 13 23",
"2007 05 20 03 13 23"},
{"2008 7 20 3 13 23",
"2009 6 10 3 13 23",
"2007 4 10 3 13 23"},
{" 2008 7 20 3 13 23",
null,
" 2009 7 20 3 13 23",
null},
{"2008 7 20 3 13 23 ",
"2008 7 20 3 10 37 ",
null},
{"23 13 3 20 7 2008",
"37 10 9 19 7 2008",
"23 49 8 19 7 2008"},
{" 23 13 3 20 7 2008",
null,
" 37 10 3 20 7 2008",
null},
{"23 13 3 20 7 2008 ",
"23 13 3 20 7 2009 ",
null},
};
{"2008 JULY 20 3 13 23",
null,
"2008 JUNE 10 3 13 23"},
{"2008 07 20 03 13 23",
"2007 05 20 03 13 23",
"2008 06 10 03 13 23"},
{"2008 7 20 3 13 23",
"2007 5 19 9 13 23",
"2008 6 9 9 13 23"},
{" 2008 7 20 3 13 23",
" 2009 7 20 3 13 23",
" 2007 5 20 3 13 23",
null},
{"2008 7 20 3 13 23 ",
"2008 7 20 3 13 23 ",
null},
{"23 13 3 20 7 2008",
"23 49 2 10 6 2008",
"23 13 9 9 6 2008"},
{" 23 13 3 20 7 2008",
" 37 10 3 20 7 2008",
" 23 49 2 20 7 2008",
null},
{"23 13 3 20 7 2008 ",
"23 13 3 20 7 2008 ",
null},
};
null},
null,
null},
null},
null,
null},
null},
};
null,
null},
null},
null},
null},
};
/* flags */
private static boolean err = false;
private static boolean verbose = false;
verbose = true;
}
try {
/*
* Test SimpleDateFormat.parse() and format() for original
* SimpleDateFormat instances
*/
/*
* Test SimpleDateFormat.parse() and format() for modified
* SimpleDateFormat instances using an original minus sign,
* pattern, and diffenrent month names in DecimalFormat
*/
/*
* Test SimpleDateFormat.parse() and format() for modified
* SimpleDateFormat instances using a fullwidth minus sign
*/
/*
* Just to confirm that regressions aren't introduced in
* DecimalFormat. This cannot happen, though. Because I didn't
* change DecimalFormat at all.
*/
}
catch (Exception e) {
err = true;
}
finally {
if (err) {
throw new RuntimeException("Date/Number formatting/parsing error.");
} else {
}
}
}
//
// DateFormat test
//
private static void testDateFormat1() {
for (int j = 0; j <= 1; j++) {
// Generate a pattern
}
}
}
private static void testDateFormat2() {
/*
* modified ar_EG Date&Time formatter :
* minus sign: ':'
* pattern: "#,##0.###"
* month names: In Arabic
*
* modified en_US Date&Time formatter :
* minus sign: ':'
* pattern: "#,##0.###;#,##0.###-"
* month names: In English
*/
for (int j = 2; j <= 3; j++) {
// Generate a pattern
}
}
}
private static void testDateFormat3() {
/*
* modified ar_EG Date&Time formatter :
* minus sign: '\uff0d' // fullwidth minus
* pattern: "#,##0.###;#,##0.###-"
* month names: In Arabic
*
* modified en_US Date&Time formatter :
* minus sign: '\uff0d' // fullwidth minus
* pattern: "#,##0.###"
* month names: In English
*/
for (int j = 4; j <= 5; j++) {
// Generate a pattern
}
}
}
int basePattern,
int delimiter,
boolean useEnglishMonthName) {
}
continue;
}
}
}
int basePattern,
int delimiter,
boolean useEnglishMonthName) {
}
continue;
}
}
}
if (verbose) {
}
} else {
err = true;
}
}
int basePattern,
int delimiter,
boolean useEnglishMonthName) {
}
}
}
int basePattern,
int delimiter,
boolean useEnglishMonthName) {
}
}
}
try {
if (expectedGC == null) {
err = true;
if (verbose) {
}
} else {
err = true;
}
}
catch (ParseException pe) {
if (expectedGC == null) {
if (verbose) {
}
} else {
err = true;
}
}
}
//
// NumberFormat test
//
private static void testNumberFormat() {
}
int given,
if (verbose) {
}
} else {
err = true;
}
}
try {
if (verbose) {
}
} else {
err = true;
}
}
catch (ParseException pe) {
err = true;
}
}
int expected,
try {
err = true;
}
catch (ParseException pe) {
if (errorOffset == expected) {
if (verbose) {
}
} else {
err = true;
}
}
}
}