TESTCASE DESCRIPTION:
--- FirstYearTest.java -------------
import java.time.chrono.JapaneseChronology;
import java.time.chrono.JapaneseDate;
import java.time.format.DateTimeFormatter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
public class FirstYearTest{
static Locale jplocale;
public static void main(String[] args){
jplocale = new Locale("ja", "JP", "JP");
String str;
String pattern = "GGGGyyyy\u5e74";
System.out.println("--- Calendar SimpleDateFormst ---");
Calendar cal = Calendar.getInstance();
cal.set(1989,0,8); // = Heisei 1
SimpleDateFormat format = new SimpleDateFormat(pattern, jplocale);
str = format.format(cal.getTime());
System.out.println("\""+pattern+"\" "+str);
System.out.println("--- JapaneseDate DateTimeFormatter ---");
printDateTimeFormatter("GGGGyyyy\u5e74");
System.out.println("--- JapaneseDate DateTimeFormatter trials ---");
printDateTimeFormatter("GGGGyyy\u5e74");
printDateTimeFormatter("GGGGyy\u5e74");
printDateTimeFormatter("GGGGy\u5e74");
}
static void printDateTimeFormatter(String pattern) {
JapaneseDate date = JapaneseDate.of(1989,1,8);
String str = date.format(DateTimeFormatter.ofPattern(pattern)
.withLocale(jplocale));
System.out.println("\""+pattern+"\" "+str);
}
}
FALING OUTPUT:
--- Calendar SimpleDateFormst ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
--- JapaneseDate DateTimeFormatter ---
"GGGGyyyy\u5e74" \u5e73\u62100001\u5e74
Expected Result:
--- Calendar SimpleDateFormst ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
--- JapaneseDate DateTimeFormatter ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
--- FirstYearTest.java -------------
import java.time.chrono.JapaneseChronology;
import java.time.chrono.JapaneseDate;
import java.time.format.DateTimeFormatter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
public class FirstYearTest{
static Locale jplocale;
public static void main(String[] args){
jplocale = new Locale("ja", "JP", "JP");
String str;
String pattern = "GGGGyyyy\u5e74";
System.out.println("--- Calendar SimpleDateFormst ---");
Calendar cal = Calendar.getInstance();
cal.set(1989,0,8); // = Heisei 1
SimpleDateFormat format = new SimpleDateFormat(pattern, jplocale);
str = format.format(cal.getTime());
System.out.println("\""+pattern+"\" "+str);
System.out.println("--- JapaneseDate DateTimeFormatter ---");
printDateTimeFormatter("GGGGyyyy\u5e74");
System.out.println("--- JapaneseDate DateTimeFormatter trials ---");
printDateTimeFormatter("GGGGyyy\u5e74");
printDateTimeFormatter("GGGGyy\u5e74");
printDateTimeFormatter("GGGGy\u5e74");
}
static void printDateTimeFormatter(String pattern) {
JapaneseDate date = JapaneseDate.of(1989,1,8);
String str = date.format(DateTimeFormatter.ofPattern(pattern)
.withLocale(jplocale));
System.out.println("\""+pattern+"\" "+str);
}
}
FALING OUTPUT:
--- Calendar SimpleDateFormst ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
--- JapaneseDate DateTimeFormatter ---
"GGGGyyyy\u5e74" \u5e73\u62100001\u5e74
Expected Result:
--- Calendar SimpleDateFormst ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74
--- JapaneseDate DateTimeFormatter ---
"GGGGyyyy\u5e74" \u5e73\u6210\u5143\u5e74