--- old/make/java/java/Makefile 2013-04-11 23:15:00.000000000 -0700 +++ new/make/java/java/Makefile 2013-04-11 23:15:00.000000000 -0700 @@ -313,6 +313,12 @@ CAL_PROPS = calendars.properties # +# Rule to copy Hijrah-umalqura calendar properties file. +# +HIJRAH_UMALQURA_PROPS = hijrah-config-umalqura.properties + + +# # Rule to copy tzmappings file on Windows # ifeq ($(PLATFORM), windows) @@ -324,7 +330,7 @@ $(call chmod-file, 444) endif -build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(TZMAP) +build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(LIBDIR)/$(HIJRAH_UMALQURA_PROPS) $(TZMAP) $(LIBDIR)/$(PROPS): $(PLATFORM_SRC)/lib/$(PROPS) $(install-file) @@ -332,6 +338,9 @@ $(LIBDIR)/$(CAL_PROPS): $(SHARE_SRC)/lib/$(CAL_PROPS) $(install-file) +$(LIBDIR)/$(HIJRAH_UMALQURA_PROPS): $(SHARE_SRC)/lib/$(HIJRAH_UMALQURA_PROPS) + $(install-file) + clean:: $(RM) -r $(LIBDIR)/$(PROPS) $(TZMAP) --- old/make/java/text/base/FILES_java.gmk 2013-04-11 23:15:01.000000000 -0700 +++ new/make/java/text/base/FILES_java.gmk 2013-04-11 23:15:01.000000000 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 2013, 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 @@ -105,5 +105,7 @@ sun/text/resources/CollationData.java \ \ sun/text/resources/FormatData.java \ + sun/text/resources/JavaTimeSupplementary.java \ sun/text/resources/en/FormatData_en.java \ - sun/text/resources/en/FormatData_en_US.java + sun/text/resources/en/FormatData_en_US.java \ + sun/text/resources/en/JavaTimeSupplementary_en.java \ --- old/make/java/util/FILES_java.gmk 2013-04-11 23:15:02.000000000 -0700 +++ new/make/java/util/FILES_java.gmk 2013-04-11 23:15:02.000000000 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2013, 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 @@ -26,6 +26,7 @@ FILES_java = \ sun/util/resources/LocaleData.java \ sun/util/resources/OpenListResourceBundle.java \ + sun/util/resources/ParallelListResourceBundle.java \ sun/util/resources/LocaleNamesBundle.java \ sun/util/resources/TimeZoneNamesBundle.java \ sun/util/resources/TimeZoneNames.java \ --- old/make/sun/text/FILES_java.gmk 2013-04-11 23:15:03.000000000 -0700 +++ new/make/sun/text/FILES_java.gmk 2013-04-11 23:15:02.000000000 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2013, 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 @@ -227,5 +227,54 @@ sun/util/resources/sv/TimeZoneNames_sv.java \ sun/util/resources/zh/TimeZoneNames_zh_CN.java \ sun/util/resources/zh/TimeZoneNames_zh_TW.java \ - sun/util/resources/zh/TimeZoneNames_zh_HK.java + sun/util/resources/zh/TimeZoneNames_zh_HK.java \ + \ + sun/text/resources/ar/JavaTimeSupplementary_ar.java \ + sun/text/resources/be/JavaTimeSupplementary_be.java \ + sun/text/resources/bg/JavaTimeSupplementary_bg.java \ + sun/text/resources/ca/JavaTimeSupplementary_ca.java \ + sun/text/resources/cs/JavaTimeSupplementary_cs.java \ + sun/text/resources/da/JavaTimeSupplementary_da.java \ + sun/text/resources/de/JavaTimeSupplementary_de.java \ + sun/text/resources/el/JavaTimeSupplementary_el.java \ + sun/text/resources/en/JavaTimeSupplementary_en_GB.java \ + sun/text/resources/en/JavaTimeSupplementary_en_SG.java \ + sun/text/resources/es/JavaTimeSupplementary_es.java \ + sun/text/resources/et/JavaTimeSupplementary_et.java \ + sun/text/resources/fi/JavaTimeSupplementary_fi.java \ + sun/text/resources/fr/JavaTimeSupplementary_fr.java \ + sun/text/resources/ga/JavaTimeSupplementary_ga.java \ + sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java \ + sun/text/resources/hr/JavaTimeSupplementary_hr.java \ + sun/text/resources/hu/JavaTimeSupplementary_hu.java \ + sun/text/resources/is/JavaTimeSupplementary_is.java \ + sun/text/resources/it/JavaTimeSupplementary_it.java \ + sun/text/resources/iw/JavaTimeSupplementary_iw.java \ + sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java \ + sun/text/resources/ja/JavaTimeSupplementary_ja.java \ + sun/text/resources/ko/JavaTimeSupplementary_ko.java \ + sun/text/resources/lt/JavaTimeSupplementary_lt.java \ + sun/text/resources/lv/JavaTimeSupplementary_lv.java \ + sun/text/resources/mk/JavaTimeSupplementary_mk.java \ + sun/text/resources/ms/JavaTimeSupplementary_ms.java \ + sun/text/resources/mt/JavaTimeSupplementary_mt.java \ + sun/text/resources/nl/JavaTimeSupplementary_nl.java \ + sun/text/resources/no/JavaTimeSupplementary_no.java \ + sun/text/resources/pl/JavaTimeSupplementary_pl.java \ + sun/text/resources/pt/JavaTimeSupplementary_pt.java \ + sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java \ + sun/text/resources/ro/JavaTimeSupplementary_ro.java \ + sun/text/resources/ru/JavaTimeSupplementary_ru.java \ + sun/text/resources/sk/JavaTimeSupplementary_sk.java \ + sun/text/resources/sl/JavaTimeSupplementary_sl.java \ + sun/text/resources/sq/JavaTimeSupplementary_sq.java \ + sun/text/resources/sr/JavaTimeSupplementary_sr.java \ + sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java \ + sun/text/resources/sv/JavaTimeSupplementary_sv.java \ + sun/text/resources/th/JavaTimeSupplementary_th.java \ + sun/text/resources/tr/JavaTimeSupplementary_tr.java \ + sun/text/resources/uk/JavaTimeSupplementary_uk.java \ + sun/text/resources/vi/JavaTimeSupplementary_vi.java \ + sun/text/resources/zh/JavaTimeSupplementary_zh.java \ + sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java --- old/make/sun/tzdb/Makefile 2013-04-11 23:15:04.000000000 -0700 +++ new/make/sun/tzdb/Makefile 2013-04-11 23:15:03.000000000 -0700 @@ -42,7 +42,6 @@ # Time zone data file creation # TZDATA_DIR := ../javazic/tzdata -TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION)) TZFILE := \ africa antarctica asia australasia europe northamerica \ pacificnew southamerica backward etcetera \ @@ -50,9 +49,7 @@ TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZFILE)) - - -TZDB_JAR = tzdb.jar +TZDB_DAT = $(LIBDIR)/tzdb.dat # # Rules @@ -62,13 +59,12 @@ # # Add to the build rule # -build: $(LIBDIR)/$(TZDB_JAR) +build: $(TZDB_DAT) -$(LIBDIR)/$(TZDB_JAR): $(TZFILES) +$(TZDB_DAT): $(TZFILES) $(prep-target) - echo build tzdb from version $(TZDATA_VER) $(BOOT_JAVA_CMD) -jar $(BUILDTOOLJARDIR)/tzdb.jar \ - -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(LIBDIR) $(TZFILE) + -srcdir $(TZDATA_DIR) -dstfile $(TZDB_DAT) $(TZFILE) clean clobber:: - $(RM) $(LIBDIR)/$(TZDB_JAR) + $(RM) $(TZDB_DAT) --- old/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java 2013-04-11 23:15:04.000000000 -0700 +++ new/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java 2013-04-11 23:15:04.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -25,6 +25,7 @@ package build.tools.cldrconverter; +import build.tools.cldrconverter.CLDRConverter.DraftType; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -88,7 +89,7 @@ } String draftValue = attributes.getValue("draft"); if (draftValue != null) { - return CLDRConverter.draftType > CLDRConverter.DRAFT_MAP.get(draftValue); + return DraftType.getDefault().ordinal() > DraftType.forKeyword(draftValue).ordinal(); } return false; } --- old/make/tools/src/build/tools/cldrconverter/Bundle.java 2013-04-11 23:15:05.000000000 -0700 +++ new/make/tools/src/build/tools/cldrconverter/Bundle.java 2013-04-11 23:15:05.000000000 -0700 @@ -266,6 +266,9 @@ handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "DayNarrows"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "AmPmMarkers"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "narrow.AmPmMarkers"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterNames"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterAbbreviations"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterNarrows"); adjustEraNames(myMap, calendarType); @@ -484,25 +487,33 @@ for (String k : patternKeys) { if (myMap.containsKey(calendarPrefix + k)) { int len = patternKeys.length; - List rawPatterns = new ArrayList<>(); - List patterns = new ArrayList<>(); + List rawPatterns = new ArrayList<>(len); + List patterns = new ArrayList<>(len); for (int i = 0; i < len; i++) { String key = calendarPrefix + patternKeys[i]; String pattern = (String) myMap.remove(key); if (pattern == null) { pattern = (String) parentsMap.remove(key); } + rawPatterns.add(i, pattern); if (pattern != null) { - rawPatterns.add(i, pattern); patterns.add(i, translateDateFormatLetters(calendarType, pattern)); + } else { + patterns.add(i, null); } } + // If patterns is empty or has any nulls, discard patterns. if (patterns.isEmpty()) { return; } + for (String p : patterns) { + if (p == null) { + return; + } + } String key = calendarPrefix + name; if (!rawPatterns.equals(patterns)) { - myMap.put("cldr." + key, rawPatterns.toArray(new String[len])); + myMap.put("java.time." + key, rawPatterns.toArray(new String[len])); } myMap.put(key, patterns.toArray(new String[len])); break; --- old/make/tools/src/build/tools/cldrconverter/CLDRConverter.java 2013-04-11 23:15:06.000000000 -0700 +++ new/make/tools/src/build/tools/cldrconverter/CLDRConverter.java 2013-04-11 23:15:06.000000000 -0700 @@ -68,25 +68,43 @@ static MetaZonesParseHandler handlerMetaZones; private static BundleGenerator bundleGenerator; - static int draftType; - private static final String DRAFT_UNCONFIRMED = "unconfirmed"; - private static final String DRAFT_PROVISIONAL = "provisional"; - private static final String DRAFT_CONTRIBUTED = "contributed"; - private static final String DRAFT_APPROVED = "approved"; - private static final String DRAFT_TRUE = "true"; - private static final String DRAFT_FALSE = "false"; - private static final String DRAFT_DEFAULT = DRAFT_APPROVED; - static final Map DRAFT_MAP = new HashMap<>(); - - static { - DRAFT_MAP.put(DRAFT_UNCONFIRMED, 0); - DRAFT_MAP.put(DRAFT_PROVISIONAL, 1); - DRAFT_MAP.put(DRAFT_CONTRIBUTED, 2); - DRAFT_MAP.put(DRAFT_APPROVED, 3); - DRAFT_MAP.put(DRAFT_TRUE, 0); - DRAFT_MAP.put(DRAFT_FALSE, 2); - draftType = DRAFT_MAP.get(DRAFT_DEFAULT); - }; + static enum DraftType { + UNCONFIRMED, + PROVISIONAL, + CONTRIBUTED, + APPROVED; + + private static final Map map = new HashMap<>(); + static { + for (DraftType dt : values()) { + map.put(dt.getKeyword(), dt); + } + } + static private DraftType defaultType = CONTRIBUTED; + + private final String keyword; + + private DraftType() { + keyword = this.name().toLowerCase(Locale.ROOT); + + } + + static DraftType forKeyword(String keyword) { + return map.get(keyword); + } + + static DraftType getDefault() { + return defaultType; + } + + static void setDefault(String keyword) { + defaultType = Objects.requireNonNull(forKeyword(keyword)); + } + + String getKeyword() { + return keyword; + } + } static boolean USE_UTF8 = false; private static boolean verbose; @@ -106,7 +124,7 @@ case "-draft": String draftDataType = args[++i]; try { - draftType = DRAFT_MAP.get(draftDataType); + DraftType.setDefault(draftDataType); } catch (NullPointerException e) { severe("Error: incorrect draft value: %s%n", draftDataType); System.exit(1); @@ -525,7 +543,7 @@ "standalone.MonthNames", "MonthAbbreviations", "standalone.MonthAbbreviations", - "MonthNarrow", + "MonthNarrows", "standalone.MonthNarrows", "DayNames", "standalone.DayNames", @@ -533,6 +551,12 @@ "standalone.DayAbbreviations", "DayNarrows", "standalone.DayNarrows", + "QuarterNames", + "standalone.QuarterNames", + "QuarterAbbreviations", + "standalone.QuarterAbbreviations", + "QuarterNarrows", + "standalone.QuarterNarrows", "AmPmMarkers", "narrow.AmPmMarkers", "long.Eras", @@ -560,7 +584,7 @@ String prefix = calendarType.keyElementName(); for (String element : FORMAT_DATA_ELEMENTS) { String key = prefix + element; - copyIfPresent(map, "cldr." + key, formatData); + copyIfPresent(map, "java.time." + key, formatData); copyIfPresent(map, key, formatData); } } --- old/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java 2013-04-11 23:15:07.000000000 -0700 +++ new/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java 2013-04-11 23:15:07.000000000 -0700 @@ -356,6 +356,44 @@ } } break; + case "quarterContext": + { + // for FormatData + // need to keep stand-alone and format, to allow for inheritance in CLDR + String type = attributes.getValue("type"); + if ("stand-alone".equals(type) || "format".equals(type)) { + pushKeyContainer(qName, attributes, type); + } else { + pushIgnoredContainer(qName); + } + } + break; + case "quarterWidth": + { + // for FormatData + // keep info about the context type so we can sort out inheritance later + String prefix = (currentCalendarType == null) ? "" : currentCalendarType.keyElementName(); + switch (attributes.getValue("type")) { + case "wide": + pushStringArrayEntry(qName, attributes, prefix + "QuarterNames/" + getContainerKey(), 4); + break; + case "abbreviated": + pushStringArrayEntry(qName, attributes, prefix + "QuarterAbbreviations/" + getContainerKey(), 4); + break; + case "narrow": + pushStringArrayEntry(qName, attributes, prefix + "QuarterNarrows/" + getContainerKey(), 4); + break; + default: + pushIgnoredContainer(qName); + break; + } + } + break; + case "quarter": + // for FormatData + // add to string array entry of quarterWidth element + pushStringArrayElement(qName, attributes, Integer.parseInt(attributes.getValue("type")) - 1); + break; // // Time zone names --- old/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java 2013-04-11 23:15:08.000000000 -0700 +++ new/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java 2013-04-11 23:15:07.000000000 -0700 @@ -58,12 +58,12 @@ import static build.tools.tzdb.Utils.*; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.ParsePosition; import java.util.ArrayList; import java.util.Arrays; @@ -71,132 +71,131 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; +import java.util.NoSuchElementException; +import java.util.Scanner; import java.util.SortedMap; -import java.util.StringTokenizer; import java.util.TreeMap; -import java.util.TreeSet; -import java.util.jar.JarOutputStream; -import java.util.zip.ZipEntry; import java.util.regex.Matcher; +import java.util.regex.MatchResult; import java.util.regex.Pattern; /** - * A builder that can read the TZDB time-zone files and build {@code ZoneRules} instances. + * A compiler that reads a set of TZDB time-zone files and builds a single + * combined TZDB data file. * * @since 1.8 */ public final class TzdbZoneRulesCompiler { - private static final Matcher YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)").matcher(""); - private static final Matcher MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)").matcher(""); - private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); - private static final Matcher TIME = Pattern.compile("(?-)?+(?[0-9]{1,2})(:(?[0-5][0-9]))?+(:(?[0-5][0-9]))?+").matcher(""); - - /** - * Constant for MJD 1972-01-01. - */ - private static final long MJD_1972_01_01 = 41317L; - - /** - * Reads a set of TZDB files and builds a single combined data file. - * - * @param args the arguments - */ public static void main(String[] args) { + new TzdbZoneRulesCompiler().compile(args); + } + + private void compile(String[] args) { if (args.length < 2) { outputHelp(); return; } - - // parse args + Path srcDir = null; + Path dstFile = null; String version = null; - File baseSrcDir = null; - File dstDir = null; - boolean verbose = false; - - // parse options + // parse args/options int i; for (i = 0; i < args.length; i++) { String arg = args[i]; - if (arg.startsWith("-") == false) { + if (!arg.startsWith("-")) { break; } if ("-srcdir".equals(arg)) { - if (baseSrcDir == null && ++i < args.length) { - baseSrcDir = new File(args[i]); - continue; - } - } else if ("-dstdir".equals(arg)) { - if (dstDir == null && ++i < args.length) { - dstDir = new File(args[i]); + if (srcDir == null && ++i < args.length) { + srcDir = Paths.get(args[i]); continue; } - } else if ("-version".equals(arg)) { - if (version == null && ++i < args.length) { - version = args[i]; + } else if ("-dstfile".equals(arg)) { + if (dstFile == null && ++i < args.length) { + dstFile = Paths.get(args[i]); continue; } } else if ("-verbose".equals(arg)) { - if (verbose == false) { + if (!verbose) { verbose = true; continue; } - } else if ("-help".equals(arg) == false) { + } else if (!"-help".equals(arg)) { System.out.println("Unrecognised option: " + arg); } outputHelp(); return; } - // check source directory - if (baseSrcDir == null) { - System.out.println("Source directory must be specified using -srcdir: " + baseSrcDir); - return; + if (srcDir == null) { + System.err.println("Source directory must be specified using -srcdir"); + System.exit(1); } - if (baseSrcDir.isDirectory() == false) { - System.out.println("Source does not exist or is not a directory: " + baseSrcDir); - return; + if (!Files.isDirectory(srcDir)) { + System.err.println("Source does not exist or is not a directory: " + srcDir); + System.exit(1); } - dstDir = (dstDir != null ? dstDir : baseSrcDir); - // parse source file names - List srcFileNames = Arrays.asList(Arrays.copyOfRange(args, i, args.length)); - if (srcFileNames.isEmpty()) { - System.out.println("Source filenames not specified, using default set"); - System.out.println("(africa antarctica asia australasia backward etcetera europe northamerica southamerica)"); - srcFileNames = Arrays.asList("africa", "antarctica", "asia", "australasia", "backward", - "etcetera", "europe", "northamerica", "southamerica"); + if (i == args.length) { + i = 0; + args = new String[] {"africa", "antarctica", "asia", "australasia", "europe", + "northamerica","southamerica", "backward", "etcetera" }; + System.out.println("Source filenames not specified, using default set ( "); + for (String name : args) { + System.out.printf(name + " "); + } + System.out.println(")"); + } + // source files in this directory + List srcFiles = new ArrayList<>(); + for (; i < args.length; i++) { + Path file = srcDir.resolve(args[i]); + if (Files.exists(file)) { + srcFiles.add(file); + } else { + System.err.println("Source directory does not contain source file: " + args[i]); + System.exit(1); + } } - - // find source directories to process - List srcDirs = new ArrayList<>(); - if (version != null) { - // if the "version" specified, as in jdk repo, the "baseSrcDir" is - // the "srcDir" that contains the tzdb data. - srcDirs.add(baseSrcDir); + // check destination file + if (dstFile == null) { + dstFile = srcDir.resolve("tzdb.dat"); } else { - File[] dirs = baseSrcDir.listFiles(); - for (File dir : dirs) { - if (dir.isDirectory() && dir.getName().matches("[12][0-9]{3}[A-Za-z0-9._-]+")) { - srcDirs.add(dir); - } + Path parent = dstFile.getParent(); + if (parent != null && !Files.exists(parent)) { + System.err.println("Destination directory does not exist: " + parent); + System.exit(1); } } - if (srcDirs.isEmpty()) { - System.out.println("Source directory contains no valid source folders: " + baseSrcDir); - return; - } - // check destination directory - if (dstDir.exists() == false && dstDir.mkdirs() == false) { - System.out.println("Destination directory could not be created: " + dstDir); - return; - } - if (dstDir.isDirectory() == false) { - System.out.println("Destination is not a directory: " + dstDir); - return; + try { + // get tzdb source version + Matcher m = Pattern.compile("tzdata(?[0-9]{4}[A-z])") + .matcher(new String(Files.readAllBytes(srcDir.resolve("VERSION")), + "ISO-8859-1")); + if (m.find()) { + version = m.group("ver"); + } else { + System.exit(1); + System.err.println("Source directory does not contain file: VERSION"); + } + printVerbose("Compiling TZDB version " + version); + // parse source files + for (Path file : srcFiles) { + printVerbose("Parsing file: " + file); + parseFile(file); + } + // build zone rules + printVerbose("Building rules"); + buildZoneRules(); + // output to file + printVerbose("Outputting tzdb file: " + dstFile); + outputFile(dstFile, version, builtZones, links); + } catch (Exception ex) { + System.out.println("Failed: " + ex.toString()); + ex.printStackTrace(); + System.exit(1); } - process(srcDirs, srcFileNames, dstDir, version, verbose); System.exit(0); } @@ -206,145 +205,35 @@ private static void outputHelp() { System.out.println("Usage: TzdbZoneRulesCompiler "); System.out.println("where options include:"); - System.out.println(" -srcdir Where to find source directories (required)"); - System.out.println(" -dstdir Where to output generated files (default srcdir)"); - System.out.println(" -version Specify the version, such as 2009a (optional)"); + System.out.println(" -srcdir Where to find tzdb source directory (required)"); + System.out.println(" -dstfile Where to output generated file (default srcdir/tzdb.dat)"); System.out.println(" -help Print this usage message"); System.out.println(" -verbose Output verbose information during compilation"); - System.out.println(" There must be one directory for each version in srcdir"); - System.out.println(" Each directory must have the name of the version, such as 2009a"); - System.out.println(" Each directory must contain the unpacked tzdb files, such as asia or europe"); - System.out.println(" Directories must match the regex [12][0-9][0-9][0-9][A-Za-z0-9._-]+"); - System.out.println(" There will be one jar file for each version and one combined jar in dstdir"); - System.out.println(" If the version is specified, only that version is processed"); - } - - /** - * Process to create the jar files. - */ - private static void process(List srcDirs, List srcFileNames, File dstDir, String version, boolean verbose) { - // build actual jar files - Map> allBuiltZones = new TreeMap<>(); - Set allRegionIds = new TreeSet(); - Set allRules = new HashSet(); - Map> allLinks = new TreeMap<>(); - - for (File srcDir : srcDirs) { - // source files in this directory - List srcFiles = new ArrayList<>(); - for (String srcFileName : srcFileNames) { - File file = new File(srcDir, srcFileName); - if (file.exists()) { - srcFiles.add(file); - } - } - if (srcFiles.isEmpty()) { - continue; // nothing to process - } - - // compile - String loopVersion = (srcDirs.size() == 1 && version != null) - ? version : srcDir.getName(); - TzdbZoneRulesCompiler compiler = new TzdbZoneRulesCompiler(loopVersion, srcFiles, verbose); - try { - // compile - compiler.compile(); - SortedMap builtZones = compiler.getZones(); - - // output version-specific file - File dstFile = version == null ? new File(dstDir, "tzdb" + loopVersion + ".jar") - : new File(dstDir, "tzdb.jar"); - if (verbose) { - System.out.println("Outputting file: " + dstFile); - } - outputFile(dstFile, loopVersion, builtZones, compiler.links); - - // create totals - allBuiltZones.put(loopVersion, builtZones); - allRegionIds.addAll(builtZones.keySet()); - allRules.addAll(builtZones.values()); - allLinks.put(loopVersion, compiler.links); - } catch (Exception ex) { - System.out.println("Failed: " + ex.toString()); - ex.printStackTrace(); - System.exit(1); - } - } - - // output merged file - if (version == null) { - File dstFile = new File(dstDir, "tzdb-all.jar"); - if (verbose) { - System.out.println("Outputting combined file: " + dstFile); - } - outputFile(dstFile, allBuiltZones, allRegionIds, allRules, allLinks); - } - } - - /** - * Outputs the file. - */ - private static void outputFile(File dstFile, - String version, - SortedMap builtZones, - Map links) { - Map> loopAllBuiltZones = new TreeMap<>(); - loopAllBuiltZones.put(version, builtZones); - Set loopAllRegionIds = new TreeSet(builtZones.keySet()); - Set loopAllRules = new HashSet(builtZones.values()); - Map> loopAllLinks = new TreeMap<>(); - loopAllLinks.put(version, links); - outputFile(dstFile, loopAllBuiltZones, loopAllRegionIds, loopAllRules, loopAllLinks); + System.out.println(" The source directory must contain the unpacked tzdb files, such as asia or europe"); } /** * Outputs the file. */ - private static void outputFile(File dstFile, - Map> allBuiltZones, - Set allRegionIds, - Set allRules, - Map> allLinks) { - try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(dstFile))) { - outputTZEntry(jos, allBuiltZones, allRegionIds, allRules, allLinks); - } catch (Exception ex) { - System.out.println("Failed: " + ex.toString()); - ex.printStackTrace(); - System.exit(1); - } - } - - /** - * Outputs the timezone entry in the JAR file. - */ - private static void outputTZEntry(JarOutputStream jos, - Map> allBuiltZones, - Set allRegionIds, - Set allRules, - Map> allLinks) { - // this format is not publicly specified - try { - jos.putNextEntry(new ZipEntry("TZDB.dat")); - DataOutputStream out = new DataOutputStream(jos); - + private void outputFile(Path dstFile, String version, + SortedMap builtZones, + Map links) { + try (DataOutputStream out = new DataOutputStream(Files.newOutputStream(dstFile))) { // file version out.writeByte(1); // group out.writeUTF("TZDB"); // versions - String[] versionArray = allBuiltZones.keySet().toArray(new String[allBuiltZones.size()]); - out.writeShort(versionArray.length); - for (String version : versionArray) { - out.writeUTF(version); - } + out.writeShort(1); + out.writeUTF(version); // regions - String[] regionArray = allRegionIds.toArray(new String[allRegionIds.size()]); + String[] regionArray = builtZones.keySet().toArray(new String[builtZones.size()]); out.writeShort(regionArray.length); for (String regionId : regionArray) { out.writeUTF(regionId); } - // rules - List rulesList = new ArrayList<>(allRules); + // rules -- hashset -> remove the dup + List rulesList = new ArrayList<>(new HashSet<>(builtZones.values())); out.writeShort(rulesList.size()); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); for (ZoneRules rules : rulesList) { @@ -357,27 +246,22 @@ out.write(bytes); } // link version-region-rules - for (String version : allBuiltZones.keySet()) { - out.writeShort(allBuiltZones.get(version).size()); - for (Map.Entry entry : allBuiltZones.get(version).entrySet()) { - int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); - int rulesIndex = rulesList.indexOf(entry.getValue()); - out.writeShort(regionIndex); - out.writeShort(rulesIndex); - } + out.writeShort(builtZones.size()); + for (Map.Entry entry : builtZones.entrySet()) { + int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); + int rulesIndex = rulesList.indexOf(entry.getValue()); + out.writeShort(regionIndex); + out.writeShort(rulesIndex); } // alias-region - for (String version : allLinks.keySet()) { - out.writeShort(allLinks.get(version).size()); - for (Map.Entry entry : allLinks.get(version).entrySet()) { - int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); - int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); - out.writeShort(aliasIndex); - out.writeShort(regionIndex); - } + out.writeShort(links.size()); + for (Map.Entry entry : links.entrySet()) { + int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); + int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); + out.writeShort(aliasIndex); + out.writeShort(regionIndex); } out.flush(); - jos.closeEntry(); } catch (Exception ex) { System.out.println("Failed: " + ex.toString()); ex.printStackTrace(); @@ -385,76 +269,30 @@ } } - //----------------------------------------------------------------------- + private static final Pattern YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)"); + private static final Pattern MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)"); + private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); + private static final Matcher TIME = Pattern.compile("(?-)?+(?[0-9]{1,2})(:(?[0-5][0-9]))?+(:(?[0-5][0-9]))?+").matcher(""); + /** The TZDB rules. */ private final Map> rules = new HashMap<>(); /** The TZDB zones. */ private final Map> zones = new HashMap<>(); - /** The TZDB links. */ + /** The TZDB links. */ private final Map links = new HashMap<>(); /** The built zones. */ private final SortedMap builtZones = new TreeMap<>(); - - /** The version to produce. */ - private final String version; - - /** The source files. */ - - private final List sourceFiles; - - /** The version to produce. */ - private final boolean verbose; - - /** - * Creates an instance if you want to invoke the compiler manually. - * - * @param version the version, such as 2009a, not null - * @param sourceFiles the list of source files, not empty, not null - * @param verbose whether to output verbose messages - */ - public TzdbZoneRulesCompiler(String version, List sourceFiles, boolean verbose) { - this.version = version; - this.sourceFiles = sourceFiles; - this.verbose = verbose; - } - - /** - * Compile the rules file. - *

- * Use {@link #getZones()} to retrieve the parsed data. - * - * @throws Exception if an error occurs - */ - public void compile() throws Exception { - printVerbose("Compiling TZDB version " + version); - parseFiles(); - buildZoneRules(); - printVerbose("Compiled TZDB version " + version); - } + /** Whether to output verbose messages. */ + private boolean verbose; /** - * Gets the parsed zone rules. - * - * @return the parsed zone rules, not null + * private contructor */ - public SortedMap getZones() { - return builtZones; - } - - /** - * Parses the source files. - * - * @throws Exception if an error occurs - */ - private void parseFiles() throws Exception { - for (File file : sourceFiles) { - printVerbose("Parsing file: " + file); - parseFile(file); - } + private TzdbZoneRulesCompiler() { } /** @@ -463,14 +301,14 @@ * @param file the file being read, not null * @throws Exception if an error occurs */ - private void parseFile(File file) throws Exception { + private void parseFile(Path file) throws Exception { int lineNumber = 1; String line = null; - BufferedReader in = null; try { - in = new BufferedReader(new FileReader(file)); + List lines = Files.readAllLines(file, StandardCharsets.ISO_8859_1); List openZone = null; - for ( ; (line = in.readLine()) != null; lineNumber++) { + for (; lineNumber < lines.size(); lineNumber++) { + line = lines.get(lineNumber); int index = line.indexOf('#'); // remove comments (doesn't handle # in quotes) if (index >= 0) { line = line.substring(0, index); @@ -478,41 +316,43 @@ if (line.trim().length() == 0) { // ignore blank lines continue; } - StringTokenizer st = new StringTokenizer(line, " \t"); - if (openZone != null && Character.isWhitespace(line.charAt(0)) && st.hasMoreTokens()) { - if (parseZoneLine(st, openZone)) { + Scanner s = new Scanner(line); + if (openZone != null && Character.isWhitespace(line.charAt(0)) && s.hasNext()) { + if (parseZoneLine(s, openZone)) { openZone = null; } } else { - if (st.hasMoreTokens()) { - String first = st.nextToken(); + if (s.hasNext()) { + String first = s.next(); if (first.equals("Zone")) { - if (st.countTokens() < 3) { + openZone = new ArrayList<>(); + try { + zones.put(s.next(), openZone); + if (parseZoneLine(s, openZone)) { + openZone = null; + } + } catch (NoSuchElementException x) { printVerbose("Invalid Zone line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Zone line"); } - openZone = new ArrayList<>(); - zones.put(st.nextToken(), openZone); - if (parseZoneLine(st, openZone)) { - openZone = null; - } } else { openZone = null; if (first.equals("Rule")) { - if (st.countTokens() < 9) { + try { + parseRuleLine(s); + } catch (NoSuchElementException x) { printVerbose("Invalid Rule line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Rule line"); } - parseRuleLine(st); - } else if (first.equals("Link")) { - if (st.countTokens() < 2) { + try { + String realId = s.next(); + String aliasId = s.next(); + links.put(aliasId, realId); + } catch (NoSuchElementException x) { printVerbose("Invalid Link line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Link line"); } - String realId = st.nextToken(); - String aliasId = st.nextToken(); - links.put(aliasId, realId); } else { throw new IllegalArgumentException("Unknown line"); @@ -522,52 +362,44 @@ } } } catch (Exception ex) { - throw new Exception("Failed while processing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex); - } finally { - try { - if (in != null) { - in.close(); - } - } catch (Exception ex) { - // ignore NPE and IOE - } + throw new Exception("Failed while parsing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex); } } /** * Parses a Rule line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null */ - private void parseRuleLine(StringTokenizer st) { + private void parseRuleLine(Scanner s) { TZDBRule rule = new TZDBRule(); - String name = st.nextToken(); + String name = s.next(); if (rules.containsKey(name) == false) { rules.put(name, new ArrayList()); } rules.get(name).add(rule); - rule.startYear = parseYear(st.nextToken(), 0); - rule.endYear = parseYear(st.nextToken(), rule.startYear); + rule.startYear = parseYear(s, 0); + rule.endYear = parseYear(s, rule.startYear); if (rule.startYear > rule.endYear) { throw new IllegalArgumentException("Year order invalid: " + rule.startYear + " > " + rule.endYear); } - parseOptional(st.nextToken()); // type is unused - parseMonthDayTime(st, rule); - rule.savingsAmount = parsePeriod(st.nextToken()); - rule.text = parseOptional(st.nextToken()); + parseOptional(s.next()); // type is unused + parseMonthDayTime(s, rule); + rule.savingsAmount = parsePeriod(s.next()); + rule.text = parseOptional(s.next()); } /** * Parses a Zone line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null * @return true if the zone is complete */ - private boolean parseZoneLine(StringTokenizer st, List zoneList) { + private boolean parseZoneLine(Scanner s, List zoneList) { TZDBZone zone = new TZDBZone(); zoneList.add(zone); - zone.standardOffset = parseOffset(st.nextToken()); - String savingsRule = parseOptional(st.nextToken()); + zone.standardOffset = parseOffset(s.next()); + String savingsRule = parseOptional(s.next()); if (savingsRule == null) { zone.fixedSavingsSecs = 0; zone.savingsRule = null; @@ -580,11 +412,11 @@ zone.savingsRule = savingsRule; } } - zone.text = st.nextToken(); - if (st.hasMoreTokens()) { - zone.year = Integer.parseInt(st.nextToken()); - if (st.hasMoreTokens()) { - parseMonthDayTime(st, zone); + zone.text = s.next(); + if (s.hasNext()) { + zone.year = Integer.parseInt(s.next()); + if (s.hasNext()) { + parseMonthDayTime(s, zone); } return false; } else { @@ -595,13 +427,13 @@ /** * Parses a Rule line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null * @param mdt the object to parse into, not null */ - private void parseMonthDayTime(StringTokenizer st, TZDBMonthDayTime mdt) { - mdt.month = parseMonth(st.nextToken()); - if (st.hasMoreTokens()) { - String dayRule = st.nextToken(); + private void parseMonthDayTime(Scanner s, TZDBMonthDayTime mdt) { + mdt.month = parseMonth(s); + if (s.hasNext()) { + String dayRule = s.next(); if (dayRule.startsWith("last")) { mdt.dayOfMonth = -1; mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4)); @@ -621,8 +453,8 @@ } mdt.dayOfMonth = Integer.parseInt(dayRule); } - if (st.hasMoreTokens()) { - String timeStr = st.nextToken(); + if (s.hasNext()) { + String timeStr = s.next(); int secsOfDay = parseSecs(timeStr); if (secsOfDay == 86400) { mdt.endOfDay = true; @@ -635,30 +467,43 @@ } } - private int parseYear(String str, int defaultYear) { - if (YEAR.reset(str).matches()) { - if (YEAR.group("min") != null) { + private int parseYear(Scanner s, int defaultYear) { + if (s.hasNext(YEAR)) { + s.next(YEAR); + MatchResult mr = s.match(); + if (mr.group(1) != null) { + return 1900; // systemv has min + } else if (mr.group(2) != null) { + return YEAR_MAX_VALUE; + } else if (mr.group(3) != null) { + return defaultYear; + } + return Integer.parseInt(mr.group(4)); + /* + if (mr.group("min") != null) { //return YEAR_MIN_VALUE; return 1900; // systemv has min - } else if (YEAR.group("max") != null) { + } else if (mr.group("max") != null) { return YEAR_MAX_VALUE; - } else if (YEAR.group("only") != null) { + } else if (mr.group("only") != null) { return defaultYear; } - return Integer.parseInt(YEAR.group("year")); + return Integer.parseInt(mr.group("year")); + */ } - throw new IllegalArgumentException("Unknown year: " + str); + throw new IllegalArgumentException("Unknown year: " + s.next()); } - private int parseMonth(String str) { - if (MONTH.reset(str).matches()) { + private int parseMonth(Scanner s) { + if (s.hasNext(MONTH)) { + s.next(MONTH); for (int moy = 1; moy < 13; moy++) { - if (MONTH.group(moy) != null) { + if (s.match().group(moy) != null) { return moy; } } } - throw new IllegalArgumentException("Unknown month: " + str); + throw new IllegalArgumentException("Unknown month: " + s.next()); } private int parseDayOfWeek(String str) { @@ -729,7 +574,6 @@ } } - //----------------------------------------------------------------------- /** * Build the rules, zones and links into real zones. * @@ -744,8 +588,7 @@ for (TZDBZone tzdbZone : tzdbZones) { bld = tzdbZone.addToBuilder(bld, rules); } - ZoneRules buildRules = bld.toRules(zoneId); - builtZones.put(zoneId, buildRules); + builtZones.put(zoneId, bld.toRules(zoneId)); } // build aliases @@ -758,25 +601,25 @@ printVerbose("Relinking alias " + aliasId + " to " + realId); realRules = builtZones.get(realId); if (realRules == null) { - throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId + "' for '" + version + "'"); + throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId); } links.put(aliasId, realId); - } builtZones.put(aliasId, realRules); } - // remove UTC and GMT - //builtZones.remove("UTC"); - //builtZones.remove("GMT"); - //builtZones.remove("GMT0"); + // builtZones.remove("UTC"); + // builtZones.remove("GMT"); + // builtZones.remove("GMT0"); builtZones.remove("GMT+0"); builtZones.remove("GMT-0"); links.remove("GMT+0"); links.remove("GMT-0"); + // remove ROC, which is not supported in j.u.tz + builtZones.remove("ROC"); + links.remove("ROC"); } - //----------------------------------------------------------------------- /** * Prints a verbose message. * @@ -788,7 +631,6 @@ } } - //----------------------------------------------------------------------- /** * Class representing a month-day-time in the TZDB file. */ @@ -893,5 +735,4 @@ return ldt; } } - } --- old/makefiles/CopyFiles.gmk 2013-04-11 23:15:09.000000000 -0700 +++ new/makefiles/CopyFiles.gmk 2013-04-11 23:15:09.000000000 -0700 @@ -174,6 +174,13 @@ COPY_FILES += $(LIBDIR)/calendars.properties +$(LIBDIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties + $(MKDIR) -p $(@D) + $(RM) $@ + $(CP) $< $@ + +COPY_FILES += $(LIBDIR)/hijrah-config-umalqura.properties + ########################################################################################## ifeq ($(OPENJDK_TARGET_OS),windows) --- old/makefiles/CreateJars.gmk 2013-04-11 23:15:10.000000000 -0700 +++ new/makefiles/CreateJars.gmk 2013-04-11 23:15:10.000000000 -0700 @@ -73,11 +73,6 @@ ########################################################################################## -$(IMAGES_OUTPUTDIR)/lib/tzdb.jar: $(JDK_OUTPUTDIR)/lib/tzdb.jar - $(install-file) - -########################################################################################## - LOCALEDATA_INCLUDE_LOCALES := ar be bg ca cs da de el es et fi fr ga hi hr hu in is it \ iw ja ko lt lv mk ms mt nl no pl pt ro ru sk sl sq sr sv \ th tr uk vi zh --- old/makefiles/GendataTZDB.gmk 2013-04-11 23:15:11.000000000 -0700 +++ new/makefiles/GendataTZDB.gmk 2013-04-11 23:15:10.000000000 -0700 @@ -29,16 +29,13 @@ # Time zone data file creation # TZDATA_DIR := $(JDK_TOPDIR)/make/sun/javazic/tzdata -TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION)) TZDATA_TZFILE := africa antarctica asia australasia europe northamerica pacificnew southamerica backward etcetera gmt jdk11_backward TZDATA_TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZDATA_TZFILE)) -GENDATA_TZDB_DST := $(JDK_OUTPUTDIR)/lib -GENDATA_TZDB_JAR := tzdb.jar +GENDATA_TZDB_DAT := $(JDK_OUTPUTDIR)/lib/tzdb.dat -$(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) : $(TZDATA_TZFILES) - $(RM) $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) - echo building tzdb from version $(TZDATA_VER) - $(TOOL_TZDB) -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(GENDATA_TZDB_DST) $(TZDATA_TZFILE) +$(GENDATA_TZDB_DAT) : $(TZDATA_TZFILES) + $(RM) $(GENDATA_TZDB_DAT) + $(TOOL_TZDB) -srcdir $(TZDATA_DIR) -dstfile $(GENDATA_TZDB_DAT) $(TZDATA_TZFILE) -GENDATA_TZDB += $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) +GENDATA_TZDB += $(GENDATA_TZDB_DAT) --- old/makefiles/profile-includes.txt 2013-04-11 23:15:12.000000000 -0700 +++ new/makefiles/profile-includes.txt 2013-04-11 23:15:11.000000000 -0700 @@ -80,7 +80,7 @@ security/java.security \ security/local_policy.jar \ security/trusted.libraries \ - tzdb.jar + tzdb.dat PROFILE_1_JRE_OTHER_FILES := \ COPYRIGHT \ @@ -100,9 +100,7 @@ resources.jar \ rt.jar \ security/US_export_policy.jar \ - security/local_policy.jar \ - tzdb.jar - + security/local_policy.jar PROFILE_2_JRE_BIN_FILES := \ rmid$(EXE_SUFFIX) \ --- old/src/share/classes/java/time/DayOfWeek.java 2013-04-11 23:15:13.000000000 -0700 +++ new/src/share/classes/java/time/DayOfWeek.java 2013-04-11 23:15:12.000000000 -0700 @@ -61,13 +61,13 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoUnit.DAYS; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -259,7 +259,7 @@ *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * range of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -269,6 +269,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -288,7 +289,7 @@ *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -297,7 +298,10 @@ * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -317,7 +321,7 @@ *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -327,6 +331,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -334,7 +339,7 @@ if (field == DAY_OF_WEEK) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -393,7 +398,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.precision()) { + if (query == TemporalQuery.precision()) { return (R) DAYS; } return TemporalAccessor.super.query(query); @@ -409,8 +414,8 @@ * passing {@link ChronoField#DAY_OF_WEEK} as the field. * Note that this adjusts forwards or backwards within a Monday to Sunday week. * See {@link WeekFields#dayOfWeek} for localized week start days. - * See {@link java.time.temporal.Adjusters Adjusters} for other adjusters - * with more control, such as {@code next(MONDAY)}. + * See {@code TemporalAdjuster} for other adjusters with more control, + * such as {@code next(MONDAY)}. *

* In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: --- old/src/share/classes/java/time/Duration.java 2013-04-11 23:15:14.000000000 -0700 +++ new/src/share/classes/java/time/Duration.java 2013-04-11 23:15:13.000000000 -0700 @@ -85,6 +85,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -302,31 +303,32 @@ //----------------------------------------------------------------------- /** - * Obtains a {@code Duration} representing the duration between two instants. - *

- * This calculates the duration between two temporal objects of the same type. - * The difference in seconds is calculated using - * {@link Temporal#periodUntil(Temporal, TemporalUnit)}. - * The difference in nanoseconds is calculated using by querying the - * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field. + * Obtains an instance of {@code Duration} from a temporal amount. *

- * The result of this method can be a negative period if the end is before the start. - * To guarantee to obtain a positive duration call {@link #abs()} on the result. - * - * @param startInclusive the start instant, inclusive, not null - * @param endExclusive the end instant, exclusive, not null - * @return a {@code Duration}, not null - * @throws ArithmeticException if the calculation exceeds the capacity of {@code Duration} - */ - public static Duration between(Temporal startInclusive, Temporal endExclusive) { - long secs = startInclusive.periodUntil(endExclusive, SECONDS); - long nanos; - try { - nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND); - } catch (DateTimeException ex) { - nanos = 0; + * This obtains a duration based on the specified amount. + * A {@code TemporalAmount} represents an amount of time, which may be + * date-based or time-based, which this factory extracts to a duration. + *

+ * The conversion loops around the set of units from the amount and uses + * the {@linkplain TemporalUnit#getDuration() duration} of the unit to + * calculate the total {@code Duration}. + * Only a subset of units are accepted by this method. The unit must either + * have an {@linkplain TemporalUnit#isDurationEstimated() exact duration} + * or be {@link ChronoUnit#DAYS} which is treated as 24 hours. + * If any other units are found then an exception is thrown. + * + * @param amount the temporal amount to convert, not null + * @return the equivalent duration, not null + * @throws DateTimeException if unable to convert to a {@code Duration} + * @throws ArithmeticException if numeric overflow occurs + */ + public static Duration from(TemporalAmount amount) { + Objects.requireNonNull(amount, "amount"); + Duration duration = ZERO; + for (TemporalUnit unit : amount.getUnits()) { + duration = duration.plus(amount.get(unit), unit); } - return ofSeconds(secs, nanos); + return duration; } //----------------------------------------------------------------------- @@ -360,14 +362,14 @@ *

* Examples: *

-     *    "PT20.345S" -> parses as "20.345 seconds"
-     *    "PT15M"     -> parses as "15 minutes" (where a minute is 60 seconds)
-     *    "PT10H"     -> parses as "10 hours" (where an hour is 3600 seconds)
-     *    "P2D"       -> parses as "2 days" (where a day is 24 hours or 86400 seconds)
-     *    "P2DT3H4M"  -> parses as "2 days, 3 hours and 4 minutes"
-     *    "P-6H3M"    -> parses as "-6 hours and +3 minutes"
-     *    "-P6H3M"    -> parses as "-6 hours and -3 minutes"
-     *    "-P-6H+3M"  -> parses as "+6 hours and -3 minutes"
+     *    "PT20.345S" -- parses as "20.345 seconds"
+     *    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
+     *    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
+     *    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+     *    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
+     *    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
+     *    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
+     *    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
      * 
* * @param text the text to parse, not null @@ -439,6 +441,44 @@ //----------------------------------------------------------------------- /** + * Obtains a {@code Duration} representing the duration between two instants. + *

+ * This calculates the duration between two temporal objects of the same type. + * The specified temporal objects must support the {@link ChronoUnit#SECONDS SECONDS} unit. + * For full accuracy, either the {@link ChronoUnit#NANOS NANOS} unit or the + * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field should be supported. + *

+ * The result of this method can be a negative period if the end is before the start. + * To guarantee to obtain a positive duration call {@link #abs()} on the result. + * + * @param startInclusive the start instant, inclusive, not null + * @param endExclusive the end instant, exclusive, not null + * @return a {@code Duration}, not null + * @throws DateTimeException if the seconds between the temporals cannot be obtained + * @throws ArithmeticException if the calculation exceeds the capacity of {@code Duration} + */ + public static Duration between(Temporal startInclusive, Temporal endExclusive) { + try { + return ofNanos(startInclusive.periodUntil(endExclusive, NANOS)); + } catch (DateTimeException | ArithmeticException ex) { + long secs = startInclusive.periodUntil(endExclusive, SECONDS); + long nanos; + try { + nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND); + if (secs > 0 && nanos < 0) { + secs++; + } else if (secs < 0 && nanos > 0) { + secs--; + } + } catch (DateTimeException ex2) { + nanos = 0; + } + return ofSeconds(secs, nanos); + } + } + + //----------------------------------------------------------------------- + /** * Obtains an instance of {@code Duration} using seconds and nanoseconds. * * @param seconds the length of the duration in seconds, positive or negative @@ -474,6 +514,7 @@ * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit * @throws DateTimeException if the unit is not supported + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override public long get(TemporalUnit unit) { @@ -482,7 +523,7 @@ } else if (unit == NANOS) { return nanos; } else { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } } @@ -637,6 +678,7 @@ * @param amountToAdd the amount of the period, measured in terms of the unit, positive or negative * @param unit the unit that the period is measured in, must have an exact duration, not null * @return a {@code Duration} based on this duration with the specified duration added, not null + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ public Duration plus(long amountToAdd, TemporalUnit unit) { @@ -645,7 +687,7 @@ return plus(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY), 0); } if (unit.isDurationEstimated()) { - throw new DateTimeException("Unit must not have an estimated duration"); + throw new UnsupportedTemporalTypeException("Unit must not have an estimated duration"); } if (amountToAdd == 0) { return this; @@ -1130,9 +1172,9 @@ * @throws ArithmeticException if numeric overflow occurs */ public long toNanos() { - long millis = Math.multiplyExact(seconds, NANOS_PER_SECOND); - millis = Math.addExact(millis, nanos); - return millis; + long totalNanos = Math.multiplyExact(seconds, NANOS_PER_SECOND); + totalNanos = Math.addExact(totalNanos, nanos); + return totalNanos; } //----------------------------------------------------------------------- @@ -1199,10 +1241,10 @@ *

* Examples: *

-     *    "20.345 seconds"                 -> "PT20.345S
-     *    "15 minutes" (15 * 60 seconds)   -> "PT15M"
-     *    "10 hours" (10 * 3600 seconds)   -> "PT10H"
-     *    "2 days" (2 * 86400 seconds)     -> "PT48H"
+     *    "20.345 seconds"                 -- "PT20.345S
+     *    "15 minutes" (15 * 60 seconds)   -- "PT15M"
+     *    "10 hours" (10 * 3600 seconds)   -- "PT10H"
+     *    "2 days" (2 * 86400 seconds)     -- "PT48H"
      * 
* Note that multiples of 24 hours are not output as days to avoid confusion * with {@code Period}. --- old/src/share/classes/java/time/Instant.java 2013-04-11 23:15:14.000000000 -0700 +++ new/src/share/classes/java/time/Instant.java 2013-04-11 23:15:14.000000000 -0700 @@ -81,7 +81,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -89,6 +88,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -148,6 +148,8 @@ *
  • other times during the day will be broadly in line with the agreed international civil time
  • *
  • the day will be divided into exactly 86400 subdivisions, referred to as "seconds"
  • *
  • the Java "second" may differ from an SI second
  • + *
  • a well-defined algorithm must be specified to map each second in the accurate agreed + * international civil time to each "second" in this time-scale
  • *

    * Agreed international civil time is the base time-scale agreed by international convention, * which in 2012 is UTC (with leap-seconds). @@ -155,6 +157,14 @@ * In 2012, the definition of the Java time-scale is the same as UTC for all days except * those where a leap-second occurs. On days where a leap-second does occur, the time-scale * effectively eliminates the leap-second, maintaining the fiction of 86400 seconds in the day. + * The approved well-defined algorithm to eliminate leap-seconds is specified as + * UTC-SLS. + *

    + * UTC-SLS is a simple algorithm that smoothes the leap-second over the last 1000 seconds of + * the day, making each of the last 1000 seconds 1/1000th longer or shorter than an SI second. + * Implementations built on an accurate leap-second aware time source should use UTC-SLS. + * Use of a different algorithm risks confusion and misinterpretation of instants around a + * leap-second and is discouraged. *

    * The main benefit of always dividing the day into 86400 subdivisions is that it matches the * expectations of most users of the API. The alternative is to force every user to understand @@ -163,16 +173,10 @@ * Most applications also do not have a problem with a second being a very small amount longer or * shorter than a real SI second during a leap-second. *

    - * If an application does have access to an accurate clock that reports leap-seconds, then the - * recommended technique to implement the Java time-scale is to use the UTC-SLS convention. - * UTC-SLS effectively smoothes the - * leap-second over the last 1000 seconds of the day, making each of the last 1000 "seconds" - * 1/1000th longer or shorter than a real SI second. - *

    * One final problem is the definition of the agreed international civil time before the * introduction of modern UTC in 1972. This includes the Java epoch of {@code 1970-01-01}. * It is intended that instants before 1972 be interpreted based on the solar day divided - * into 86400 subdivisions. + * into 86400 subdivisions, as per the principles of UT1. *

    * The Java time-scale is used for all date-time classes. * This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime}, @@ -210,7 +214,7 @@ */ public static final Instant MIN = Instant.ofEpochSecond(MIN_SECOND, 0); /** - * The minimum supported {@code Instant}, '-1000000000-01-01T00:00Z'. + * The maximum supported {@code Instant}, '1000000000-12-31T23:59:59.999999999Z'. * This could be used by an application as a "far future" instant. *

    * This is one year later than the maximum {@code LocalDateTime}. @@ -292,9 +296,9 @@ * to ensure that the stored nanosecond is in the range 0 to 999,999,999. * For example, the following will result in the exactly the same instant: *

    -     *  Instant.ofSeconds(3, 1);
    -     *  Instant.ofSeconds(4, -999_999_999);
    -     *  Instant.ofSeconds(2, 1000_000_001);
    +     *  Instant.ofEpochSecond(3, 1);
    +     *  Instant.ofEpochSecond(4, -999_999_999);
    +     *  Instant.ofEpochSecond(2, 1000_000_001);
          * 
    * * @param epochSecond the number of seconds from 1970-01-01T00:00:00Z @@ -441,7 +445,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -451,6 +455,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -469,7 +474,7 @@ * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code INSTANT_SECONDS} which is too * large to fit in an {@code int} and throws a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -478,7 +483,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -490,7 +498,7 @@ case MILLI_OF_SECOND: return nanos / 1000_000; case INSTANT_SECONDS: INSTANT_SECONDS.checkValidIntValue(seconds); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return range(field).checkValidIntValue(field.getFrom(this), field); } @@ -505,7 +513,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -515,6 +523,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -526,7 +535,7 @@ case MILLI_OF_SECOND: return nanos / 1000_000; case INSTANT_SECONDS: return seconds; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -610,7 +619,7 @@ * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -623,6 +632,7 @@ * @param newValue the new value of the field in the result * @return an {@code Instant} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -642,7 +652,7 @@ case NANO_OF_SECOND: return (newValue != nanos ? create(seconds, (int) newValue) : this); case INSTANT_SECONDS: return (newValue != seconds ? create(newValue, nanos) : this); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -668,6 +678,7 @@ * @param unit the unit to truncate to, not null * @return an {@code Instant} based on this instant with the time truncated, not null * @throws DateTimeException if the unit is invalid for truncation + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public Instant truncatedTo(TemporalUnit unit) { if (unit == ChronoUnit.NANOS) { @@ -675,11 +686,11 @@ } Duration unitDur = unit.getDuration(); if (unitDur.getSeconds() > LocalTime.SECONDS_PER_DAY) { - throw new DateTimeException("Unit is too large to be used for truncation"); + throw new UnsupportedTemporalTypeException("Unit is too large to be used for truncation"); } long dur = unitDur.toNanos(); if ((LocalTime.NANOS_PER_DAY % dur) != 0) { - throw new DateTimeException("Unit must divide into a standard day without remainder"); + throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder"); } long nod = (seconds % LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + nanos; long result = (nod / dur) * dur; @@ -754,7 +765,7 @@ * multiplied by 86,400 (24 hours). * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -767,6 +778,7 @@ * @param unit the unit of the amount to add, not null * @return an {@code Instant} based on this instant with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -782,7 +794,7 @@ case HALF_DAYS: return plusSeconds(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY / 2)); case DAYS: return plusSeconds(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -894,6 +906,7 @@ * @param unit the unit of the amount to subtract, not null * @return an {@code Instant} based on this instant with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -975,11 +988,12 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.precision()) { + if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization - if (query == Queries.chronology() || query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + if (query == TemporalQuery.chronology() || query == TemporalQuery.zoneId() || + query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; } return query.queryFrom(this); @@ -1028,14 +1042,15 @@ * For example, the period in days between two dates can be calculated * using {@code startInstant.periodUntil(endInstant, SECONDS)}. *

    - * This method operates in association with {@link TemporalUnit#between}. - * The result of this method is a {@code long} representing the amount of - * the specified unit. By contrast, the result of {@code between} is an - * object that can be used directly in addition/subtraction: + * There are two equivalent ways of using this method. + * The first is to invoke this method. + * The second is to use {@link TemporalUnit#between(Temporal, Temporal)}: *

    -     *   long period = start.periodUntil(end, SECONDS);   // this method
    -     *   dateTime.plus(SECONDS.between(start, end));      // use in plus/minus
    +     *   // these two lines are equivalent
    +     *   amount = start.periodUntil(end, SECONDS);
    +     *   amount = SECONDS.between(start, end);
          * 
    + * The choice should be made based on which makes the code more readable. *

    * The calculation is implemented in this method for {@link ChronoUnit}. * The units {@code NANOS}, {@code MICROS}, {@code MILLIS}, {@code SECONDS}, @@ -1053,6 +1068,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this date and the end date * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1074,18 +1090,26 @@ case HALF_DAYS: return secondsUntil(end) / (12 * SECONDS_PER_HOUR); case DAYS: return secondsUntil(end) / (SECONDS_PER_DAY); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endInstant); } private long nanosUntil(Instant end) { - long secs = Math.multiplyExact(secondsUntil(end), NANOS_PER_SECOND); - return Math.addExact(secs, end.nanos - nanos); + long secsDiff = Math.subtractExact(end.seconds, seconds); + long totalNanos = Math.multiplyExact(secsDiff, NANOS_PER_SECOND); + return Math.addExact(totalNanos, end.nanos - nanos); } private long secondsUntil(Instant end) { - return Math.subtractExact(end.seconds, seconds); + long secsDiff = Math.subtractExact(end.seconds, seconds); + long nanosDiff = end.nanos - nanos; + if (secsDiff > 0 && nanosDiff < 0) { + secsDiff--; + } else if (secsDiff < 0 && nanosDiff > 0) { + secsDiff++; + } + return secsDiff; } //----------------------------------------------------------------------- --- old/src/share/classes/java/time/LocalDate.java 2013-04-11 23:15:15.000000000 -0700 +++ new/src/share/classes/java/time/LocalDate.java 2013-04-11 23:15:15.000000000 -0700 @@ -69,9 +69,9 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.DataInput; @@ -87,7 +87,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -95,6 +94,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; @@ -238,7 +238,7 @@ YEAR.checkValidValue(year); Objects.requireNonNull(month, "month"); DAY_OF_MONTH.checkValidValue(dayOfMonth); - return create(year, month, dayOfMonth); + return create(year, month.getValue(), dayOfMonth); } /** @@ -258,7 +258,7 @@ YEAR.checkValidValue(year); MONTH_OF_YEAR.checkValidValue(month); DAY_OF_MONTH.checkValidValue(dayOfMonth); - return create(year, Month.of(month), dayOfMonth); + return create(year, month, dayOfMonth); } //----------------------------------------------------------------------- @@ -287,7 +287,7 @@ moy = moy.plus(1); } int dom = dayOfYear - moy.firstDayOfYear(leap) + 1; - return create(year, moy, dom); + return new LocalDate(year, moy.getValue(), dom); } //----------------------------------------------------------------------- @@ -342,7 +342,7 @@ * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code LocalDate}. *

    - * The conversion uses the {@link Queries#localDate()} query, which relies + * The conversion uses the {@link TemporalQuery#localDate()} query, which relies * on extracting the {@link ChronoField#EPOCH_DAY EPOCH_DAY} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -353,7 +353,7 @@ * @throws DateTimeException if unable to convert to a {@code LocalDate} */ public static LocalDate from(TemporalAccessor temporal) { - LocalDate date = temporal.query(Queries.localDate()); + LocalDate date = temporal.query(TemporalQuery.localDate()); if (date == null) { throw new DateTimeException("Unable to obtain LocalDate from TemporalAccessor: " + temporal.getClass()); } @@ -395,20 +395,34 @@ * Creates a local date from the year, month and day fields. * * @param year the year to represent, validated from MIN_YEAR to MAX_YEAR - * @param month the month-of-year to represent, validated not null + * @param month the month-of-year to represent, from 1 to 12, validated * @param dayOfMonth the day-of-month to represent, validated from 1 to 31 * @return the local date, not null * @throws DateTimeException if the day-of-month is invalid for the month-year */ - private static LocalDate create(int year, Month month, int dayOfMonth) { - if (dayOfMonth > 28 && dayOfMonth > month.length(IsoChronology.INSTANCE.isLeapYear(year))) { - if (dayOfMonth == 29) { - throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); - } else { - throw new DateTimeException("Invalid date '" + month.name() + " " + dayOfMonth + "'"); + private static LocalDate create(int year, int month, int dayOfMonth) { + if (dayOfMonth > 28) { + int dom = 31; + switch (month) { + case 2: + dom = (IsoChronology.INSTANCE.isLeapYear(year) ? 29 : 28); + break; + case 4: + case 6: + case 9: + case 11: + dom = 30; + break; + } + if (dayOfMonth > dom) { + if (dayOfMonth == 29) { + throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); + } else { + throw new DateTimeException("Invalid date '" + Month.of(month).name() + " " + dayOfMonth + "'"); + } } } - return new LocalDate(year, month.getValue(), dayOfMonth); + return new LocalDate(year, month, dayOfMonth); } /** @@ -431,7 +445,7 @@ day = Math.min(day, 30); break; } - return LocalDate.of(year, month, day); + return new LocalDate(year, month, day); } /** @@ -467,7 +481,7 @@ *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -498,7 +512,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -508,12 +522,13 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isDateField()) { + if (f.isDateBased()) { switch (f) { case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth()); case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear()); @@ -523,7 +538,7 @@ } return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -538,9 +553,9 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid - * values based on this date, except {@code EPOCH_DAY} and {@code EPOCH_MONTH} + * values based on this date, except {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -549,7 +564,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -570,7 +588,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -580,6 +598,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -588,8 +607,8 @@ if (field == EPOCH_DAY) { return toEpochDay(); } - if (field == EPOCH_MONTH) { - return getEpochMonth(); + if (field == PROLEPTIC_MONTH) { + return getProlepticMonth(); } return get0(field); } @@ -603,20 +622,20 @@ case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1; case DAY_OF_MONTH: return day; case DAY_OF_YEAR: return getDayOfYear(); - case EPOCH_DAY: throw new DateTimeException("Field too large for an int: " + field); + case EPOCH_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'EpochDay' for get() method, use getLong() instead"); case ALIGNED_WEEK_OF_MONTH: return ((day - 1) / 7) + 1; case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1; case MONTH_OF_YEAR: return month; - case EPOCH_MONTH: throw new DateTimeException("Field too large for an int: " + field); + case PROLEPTIC_MONTH: throw new UnsupportedTemporalTypeException("Invalid field 'ProlepticMonth' for get() method, use getLong() instead"); case YEAR_OF_ERA: return (year >= 1 ? year : 1 - year); case YEAR: return year; case ERA: return (year >= 1 ? 1 : 0); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } - private long getEpochMonth() { - return ((year - 1970) * 12L) + (month - 1); + private long getProlepticMonth() { + return (year * 12L + month - 1); } //----------------------------------------------------------------------- @@ -626,7 +645,7 @@ * The {@code Chronology} represents the calendar system in use. * The ISO-8601 calendar system is the modern civil calendar system used today * in most of the world. It is equivalent to the proleptic Gregorian calendar - * system, in which todays's rules for leap years are applied for all time. + * system, in which today's rules for leap years are applied for all time. * * @return the ISO chronology, not null */ @@ -810,7 +829,7 @@ *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -908,8 +927,8 @@ * The year will be unchanged. The day-of-month will also be unchanged, * unless it would be invalid for the new month and year. In that case, the * day-of-month is adjusted to the maximum valid value for the new month and year. - *

  • {@code EPOCH_MONTH} - - * Returns a {@code LocalDate} with the specified epoch-month. + *
  • {@code PROLEPTIC_MONTH} - + * Returns a {@code LocalDate} with the specified proleptic-month. * The day-of-month will be unchanged, unless it would be invalid for the new month * and year. In that case, the day-of-month is adjusted to the maximum valid value * for the new month and year. @@ -933,7 +952,7 @@ * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -946,6 +965,7 @@ * @param newValue the new value of the field in the result * @return a {@code LocalDate} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -963,12 +983,12 @@ case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH)); case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR)); case MONTH_OF_YEAR: return withMonth((int) newValue); - case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH)); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue)); case YEAR: return withYear((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -1137,7 +1157,7 @@ * valid value for the new month and year. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -1150,6 +1170,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code LocalDate} based on this date with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1166,7 +1187,7 @@ case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -1315,6 +1336,7 @@ * @param unit the unit of the amount to subtract, not null * @return a {@code LocalDate} based on this date with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1431,7 +1453,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.localDate()) { + if (query == TemporalQuery.localDate()) { return (R) this; } return ChronoLocalDate.super.query(query); @@ -1508,10 +1530,12 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this date and the end date * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public long periodUntil(Temporal endDate, TemporalUnit unit) { + Objects.requireNonNull(unit, "unit"); if (endDate instanceof LocalDate == false) { Objects.requireNonNull(endDate, "endDate"); throw new DateTimeException("Unable to calculate period between objects of two different types"); @@ -1528,7 +1552,7 @@ case MILLENNIA: return monthsUntil(end) / 12000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endDate); } @@ -1538,8 +1562,8 @@ } private long monthsUntil(LocalDate end) { - long packed1 = getEpochMonth() * 32L + getDayOfMonth(); // no overflow - long packed2 = end.getEpochMonth() * 32L + end.getDayOfMonth(); // no overflow + long packed1 = getProlepticMonth() * 32L + getDayOfMonth(); // no overflow + long packed2 = end.getProlepticMonth() * 32L + end.getDayOfMonth(); // no overflow return (packed2 - packed1) / 32; } @@ -1549,6 +1573,7 @@ * This calculates the period between two dates in terms of years, months and days. * The start and end points are {@code this} and the specified date. * The result will be negative if the end is before the start. + * The negative sign will be the same in each of year, month and day. *

    * The calculation is performed using the ISO calendar system. * If necessary, the input date will be converted to ISO. @@ -1561,9 +1586,6 @@ * than or equal to the start day-of-month. * For example, from {@code 2010-01-15} to {@code 2011-03-18} is "1 year, 2 months and 3 days". *

    - * The result of this method can be a negative period if the end is before the start. - * The negative sign will be the same in each of year, month and day. - *

    * There are two equivalent ways of using this method. * The first is to invoke this method. * The second is to use {@link Period#between(LocalDate, LocalDate)}: @@ -1580,7 +1602,7 @@ @Override public Period periodUntil(ChronoLocalDate endDate) { LocalDate end = LocalDate.from(endDate); - long totalMonths = end.getEpochMonth() - this.getEpochMonth(); // safe + long totalMonths = end.getProlepticMonth() - this.getProlepticMonth(); // safe int days = end.day - this.day; if (totalMonths > 0 && days < 0) { totalMonths--; @@ -1595,6 +1617,21 @@ return Period.of(Math.toIntExact(years), months, days); } + /** + * Formats this date using the specified formatter. + *

    + * This date will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this date with a time to create a {@code LocalDateTime}. @@ -1800,7 +1837,7 @@ * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)}, - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is after the specified date @@ -1829,7 +1866,7 @@ * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)}, - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is before the specified date @@ -1858,7 +1895,7 @@ * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)} - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is equal to the specified date @@ -1912,7 +1949,7 @@ /** * Outputs this date as a {@code String}, such as {@code 2007-12-03}. *

    - * The output will be in the ISO-8601 format {@code yyyy-MM-dd}. + * The output will be in the ISO-8601 format {@code uuuu-MM-dd}. * * @return a string representation of this date, not null */ @@ -1942,21 +1979,6 @@ .toString(); } - /** - * Outputs this date as a {@code String} using the formatter. - *

    - * This date will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoLocalDate.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/LocalDateTime.java 2013-04-11 23:15:16.000000000 -0700 +++ new/src/share/classes/java/time/LocalDateTime.java 2013-04-11 23:15:16.000000000 -0700 @@ -79,12 +79,10 @@ import java.io.ObjectStreamException; import java.io.Serializable; import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -92,6 +90,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Objects; @@ -546,7 +545,7 @@ *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -565,7 +564,7 @@ public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return f.isDateField() || f.isTimeField(); + return f.isDateBased() || f.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -581,7 +580,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -591,12 +590,13 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.range(field) : date.range(field)); + return (f.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); } @@ -612,9 +612,9 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY} and {@code EPOCH_MONTH} which are too large to fit in + * {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH} which are too large to fit in * an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -623,14 +623,17 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.get(field) : date.get(field)); + return (f.isTimeBased() ? time.get(field) : date.get(field)); } return ChronoLocalDateTime.super.get(field); } @@ -645,7 +648,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -655,13 +658,14 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.getLong(field) : date.getLong(field)); + return (f.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); } @@ -822,7 +826,7 @@ *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -886,7 +890,7 @@ * The {@link #isSupported(TemporalField) supported fields} will behave as per * the matching method on {@link LocalDate#with(TemporalField, long) LocalDate} * or {@link LocalTime#with(TemporalField, long) LocalTime}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -899,13 +903,14 @@ * @param newValue the new value of the field in the result * @return a {@code LocalDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public LocalDateTime with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isTimeField()) { + if (f.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); @@ -1052,6 +1057,7 @@ * @param unit the unit to truncate to, not null * @return a {@code LocalDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the field is not supported */ public LocalDateTime truncatedTo(TemporalUnit unit) { return with(date, time.truncatedTo(unit)); @@ -1106,6 +1112,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code LocalDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1312,6 +1319,7 @@ * @param unit the unit of the amount to subtract, not null * @return a {@code LocalDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1517,7 +1525,7 @@ @SuppressWarnings("unchecked") @Override // override for Javadoc public R query(TemporalQuery query) { - if (query == Queries.localDate()) { + if (query == TemporalQuery.localDate()) { return (R) date; } return ChronoLocalDateTime.super.query(query); @@ -1597,6 +1605,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1610,31 +1619,79 @@ ChronoUnit f = (ChronoUnit) unit; if (f.isTimeUnit()) { long amount = date.daysUntil(end.date); + if (amount == 0) { + return time.periodUntil(end.time, unit); + } + long timePart = end.time.toNanoOfDay() - time.toNanoOfDay(); + if (amount > 0) { + amount--; // safe + timePart += NANOS_PER_DAY; // safe + } else { + amount++; // safe + timePart -= NANOS_PER_DAY; // safe + } switch (f) { - case NANOS: amount = Math.multiplyExact(amount, NANOS_PER_DAY); break; - case MICROS: amount = Math.multiplyExact(amount, MICROS_PER_DAY); break; - case MILLIS: amount = Math.multiplyExact(amount, MILLIS_PER_DAY); break; - case SECONDS: amount = Math.multiplyExact(amount, SECONDS_PER_DAY); break; - case MINUTES: amount = Math.multiplyExact(amount, MINUTES_PER_DAY); break; - case HOURS: amount = Math.multiplyExact(amount, HOURS_PER_DAY); break; - case HALF_DAYS: amount = Math.multiplyExact(amount, 2); break; + case NANOS: + amount = Math.multiplyExact(amount, NANOS_PER_DAY); + break; + case MICROS: + amount = Math.multiplyExact(amount, MICROS_PER_DAY); + timePart = timePart / 1000; + break; + case MILLIS: + amount = Math.multiplyExact(amount, MILLIS_PER_DAY); + timePart = timePart / 1_000_000; + break; + case SECONDS: + amount = Math.multiplyExact(amount, SECONDS_PER_DAY); + timePart = timePart / NANOS_PER_SECOND; + break; + case MINUTES: + amount = Math.multiplyExact(amount, MINUTES_PER_DAY); + timePart = timePart / NANOS_PER_MINUTE; + break; + case HOURS: + amount = Math.multiplyExact(amount, HOURS_PER_DAY); + timePart = timePart / NANOS_PER_HOUR; + break; + case HALF_DAYS: + amount = Math.multiplyExact(amount, 2); + timePart = timePart / (NANOS_PER_HOUR * 12); + break; } - return Math.addExact(amount, time.periodUntil(end.time, unit)); + return Math.addExact(amount, timePart); } LocalDate endDate = end.date; - if (end.time.isBefore(time)) { + if (endDate.isAfter(date) && end.time.isBefore(time)) { endDate = endDate.minusDays(1); + } else if (endDate.isBefore(date) && end.time.isAfter(time)) { + endDate = endDate.plusDays(1); } return date.periodUntil(endDate, unit); } return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** - * Combines this time with a date to create an {@code OffsetTime}. + * Combines this date-time with an offset to create an {@code OffsetDateTime}. *

    - * This returns an {@code OffsetTime} formed from this time at the specified offset. + * This returns an {@code OffsetDateTime} formed from this date-time at the specified offset. * All possible combinations of date-time and offset are valid. * * @param offset the offset to combine with, not null @@ -1645,7 +1702,7 @@ } /** - * Combines this time with a time-zone to create a {@code ZonedDateTime}. + * Combines this date-time with a time-zone to create a {@code ZonedDateTime}. *

    * This returns a {@code ZonedDateTime} formed from this date-time at the * specified time-zone. The result will match this date-time as closely as possible. @@ -1725,7 +1782,7 @@ * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is after the specified date-time @@ -1754,7 +1811,7 @@ * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is before the specified date-time @@ -1783,7 +1840,7 @@ * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is equal to the specified date-time @@ -1834,11 +1891,11 @@ *

    * The output will be one of the following ISO-8601 formats: *

      - *
    • {@code yyyy-MM-dd'T'HH:mm}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSS}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSS}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS}
    • *

    * The format used will be the shortest that outputs the full value of * the time where the omitted parts are implied to be zero. @@ -1850,21 +1907,6 @@ return date.toString() + 'T' + time.toString(); } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date-time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoLocalDateTime.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/LocalTime.java 2013-04-11 23:15:17.000000000 -0700 +++ new/src/share/classes/java/time/LocalTime.java 2013-04-11 23:15:17.000000000 -0700 @@ -80,7 +80,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -88,6 +87,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -383,7 +383,7 @@ * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code LocalTime}. *

    - * The conversion uses the {@link Queries#localTime()} query, which relies + * The conversion uses the {@link TemporalQuery#localTime()} query, which relies * on extracting the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -394,7 +394,7 @@ * @throws DateTimeException if unable to convert to a {@code LocalTime} */ public static LocalTime from(TemporalAccessor temporal) { - LocalTime time = temporal.query(Queries.localTime()); + LocalTime time = temporal.query(TemporalQuery.localTime()); if (time == null) { throw new DateTimeException("Unable to obtain LocalTime from TemporalAccessor: " + temporal.getClass()); } @@ -505,7 +505,7 @@ @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isTimeField(); + return field.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -521,7 +521,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -531,6 +531,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -549,7 +550,7 @@ * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time, except {@code NANO_OF_DAY} and {@code MICRO_OF_DAY} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -558,7 +559,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -579,7 +583,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -589,6 +593,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -608,9 +613,9 @@ private int get0(TemporalField field) { switch ((ChronoField) field) { case NANO_OF_SECOND: return nano; - case NANO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); + case NANO_OF_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'NanoOfDay' for get() method, use getLong() instead"); case MICRO_OF_SECOND: return nano / 1000; - case MICRO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); + case MICRO_OF_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'MicroOfDay' for get() method, use getLong() instead"); case MILLI_OF_SECOND: return nano / 1000_000; case MILLI_OF_DAY: return (int) (toNanoOfDay() / 1000_000); case SECOND_OF_MINUTE: return second; @@ -623,7 +628,7 @@ case CLOCK_HOUR_OF_DAY: return (hour == 0 ? 24 : hour); case AMPM_OF_DAY: return hour / 12; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } //----------------------------------------------------------------------- @@ -760,7 +765,7 @@ * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -773,6 +778,7 @@ * @param newValue the new value of the field in the result * @return a {@code LocalTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -797,7 +803,7 @@ case CLOCK_HOUR_OF_DAY: return withHour((int) (newValue == 24 ? 0 : newValue)); case AMPM_OF_DAY: return plusHours((newValue - (hour / 12)) * 12); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -890,6 +896,7 @@ * @param unit the unit to truncate to, not null * @return a {@code LocalTime} based on this time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public LocalTime truncatedTo(TemporalUnit unit) { if (unit == ChronoUnit.NANOS) { @@ -897,11 +904,11 @@ } Duration unitDur = unit.getDuration(); if (unitDur.getSeconds() > SECONDS_PER_DAY) { - throw new DateTimeException("Unit is too large to be used for truncation"); + throw new UnsupportedTemporalTypeException("Unit is too large to be used for truncation"); } long dur = unitDur.toNanos(); if ((NANOS_PER_DAY % dur) != 0) { - throw new DateTimeException("Unit must divide into a standard day without remainder"); + throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder"); } long nod = toNanoOfDay(); return ofNanoOfDay((nod / dur) * dur); @@ -972,7 +979,7 @@ * This returns {@code this} time. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -985,6 +992,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code LocalTime} based on this time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1001,7 +1009,7 @@ case HALF_DAYS: return plusHours((amountToAdd % 2) * 12); case DAYS: return this; } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -1147,6 +1155,7 @@ * @param unit the unit of the amount to subtract, not null * @return a {@code LocalTime} based on this time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1237,13 +1246,14 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology() || query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + if (query == TemporalQuery.chronology() || query == TemporalQuery.zoneId() || + query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) this; - } else if (query == Queries.localDate()) { + } else if (query == TemporalQuery.localDate()) { return null; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1322,6 +1332,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this time and the end time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1342,11 +1353,25 @@ case HOURS: return nanosUntil / NANOS_PER_HOUR; case HALF_DAYS: return nanosUntil / (12 * NANOS_PER_HOUR); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endTime); } + /** + * Formats this time using the specified formatter. + *

    + * This time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this time with a date to create a {@code LocalDateTime}. @@ -1362,7 +1387,7 @@ } /** - * Combines this time with a date to create an {@code OffsetTime}. + * Combines this time with an offset to create an {@code OffsetTime}. *

    * This returns an {@code OffsetTime} formed from this time at the specified offset. * All possible combinations of time and offset are valid. @@ -1533,21 +1558,6 @@ return buf.toString(); } - /** - * Outputs this time as a {@code String} using the formatter. - *

    - * This time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/Month.java 2013-04-11 23:15:18.000000000 -0700 +++ new/src/share/classes/java/time/Month.java 2013-04-11 23:15:18.000000000 -0700 @@ -61,6 +61,7 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoUnit.MONTHS; @@ -69,7 +70,6 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -290,7 +290,7 @@ *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * range of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -300,6 +300,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -319,7 +320,7 @@ *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * value of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -328,7 +329,10 @@ * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -348,7 +352,7 @@ *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * value of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -358,6 +362,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -365,7 +370,7 @@ if (field == MONTH_OF_YEAR) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -554,9 +559,9 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) MONTHS; } return TemporalAccessor.super.query(query); --- old/src/share/classes/java/time/MonthDay.java 2013-04-11 23:15:19.000000000 -0700 +++ new/src/share/classes/java/time/MonthDay.java 2013-04-11 23:15:18.000000000 -0700 @@ -76,12 +76,12 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -354,7 +354,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -364,6 +364,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -386,7 +387,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this month-day. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -395,7 +396,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -413,7 +417,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this month-day. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -423,6 +427,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -433,7 +438,7 @@ case DAY_OF_MONTH: return day; case MONTH_OF_YEAR: return month; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -575,7 +580,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; } return TemporalAccessor.super.query(query); @@ -617,6 +622,20 @@ return temporal.with(DAY_OF_MONTH, Math.min(temporal.range(DAY_OF_MONTH).getMaximum(), day)); } + /** + * Formats this month-day using the specified formatter. + *

    + * This month-day will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted month-day string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this month-day with a year to create a {@code LocalDate}. @@ -722,21 +741,6 @@ .toString(); } - /** - * Outputs this month-day as a {@code String} using the formatter. - *

    - * This month-day will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted month-day string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/OffsetDateTime.java 2013-04-11 23:15:20.000000000 -0700 +++ new/src/share/classes/java/time/OffsetDateTime.java 2013-04-11 23:15:19.000000000 -0700 @@ -78,7 +78,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -86,6 +85,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Comparator; @@ -436,7 +436,7 @@ *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -469,7 +469,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -479,6 +479,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -502,9 +503,9 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too + * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -513,15 +514,20 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return dateTime.get(field); } @@ -538,7 +544,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -548,6 +554,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -790,7 +797,7 @@ *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -867,7 +874,7 @@ * the matching method on {@link LocalDateTime#with(TemporalField, long) LocalDateTime}. * In this case, the offset is not part of the calculation and will be unchanged. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -880,6 +887,7 @@ * @param newValue the new value of the field in the result * @return an {@code OffsetDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1041,6 +1049,7 @@ * @param unit the unit to truncate to, not null * @return an {@code OffsetDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public OffsetDateTime truncatedTo(TemporalUnit unit) { return with(dateTime.truncatedTo(unit), offset); @@ -1094,6 +1103,7 @@ * @param unit the unit of the amount to add, not null * @return an {@code OffsetDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1285,6 +1295,7 @@ * @param unit the unit of the amount to subtract, not null * @return an {@code OffsetDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1453,17 +1464,17 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) getOffset(); - } else if (query == Queries.zoneId()) { + } else if (query == TemporalQuery.zoneId()) { return null; - } else if (query == Queries.localDate()) { + } else if (query == TemporalQuery.localDate()) { return (R) toLocalDate(); - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1479,8 +1490,8 @@ * with the offset, date and time changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * three times, passing {@link ChronoField#OFFSET_SECONDS}, - * {@link ChronoField#EPOCH_DAY} and {@link ChronoField#NANO_OF_DAY} as the fields. + * three times, passing {@link ChronoField#EPOCH_DAY}, + * {@link ChronoField#NANO_OF_DAY} and {@link ChronoField#OFFSET_SECONDS} as the fields. *

    * In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: @@ -1499,10 +1510,14 @@ */ @Override public Temporal adjustInto(Temporal temporal) { + // OffsetDateTime is treated as three separate fields, not an instant + // this produces the most consistent set of results overall + // the offset is set after the date and time, as it is typically a small + // tweak to the result, with ZonedDateTime frequently ignoring the offset return temporal - .with(OFFSET_SECONDS, getOffset().getTotalSeconds()) .with(EPOCH_DAY, toLocalDate().toEpochDay()) - .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()); + .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()) + .with(OFFSET_SECONDS, getOffset().getTotalSeconds()); } /** @@ -1552,6 +1567,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1568,6 +1584,20 @@ return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this date-time with a time-zone to create a {@code ZonedDateTime} @@ -1796,11 +1826,11 @@ *

    * The output will be one of the following ISO-8601 formats: *

      - *
    • {@code yyyy-MM-dd'T'HH:mmXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ssXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mmXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ssXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX}
    • *

    * The format used will be the shortest that outputs the full value of * the time where the omitted parts are implied to be zero. @@ -1812,21 +1842,6 @@ return dateTime.toString() + offset.toString(); } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date-time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/OffsetTime.java 2013-04-11 23:15:20.000000000 -0700 +++ new/src/share/classes/java/time/OffsetTime.java 2013-04-11 23:15:20.000000000 -0700 @@ -79,7 +79,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -87,6 +86,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Objects; @@ -384,7 +384,7 @@ @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isTimeField() || field == OFFSET_SECONDS; + return field.isTimeBased() || field == OFFSET_SECONDS; } return field != null && field.isSupportedBy(this); } @@ -400,7 +400,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -410,6 +410,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -434,7 +435,7 @@ * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time, except {@code NANO_OF_DAY} and {@code MICRO_OF_DAY} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -443,7 +444,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -461,7 +465,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -471,6 +475,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -655,7 +660,7 @@ * the matching method on {@link LocalTime#with(TemporalField, long)} LocalTime}. * In this case, the offset is not part of the calculation and will be unchanged. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -668,6 +673,7 @@ * @param newValue the new value of the field in the result * @return an {@code OffsetTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -764,6 +770,7 @@ * @param unit the unit to truncate to, not null * @return an {@code OffsetTime} based on this time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public OffsetTime truncatedTo(TemporalUnit unit) { return with(time.truncatedTo(unit), offset); @@ -817,6 +824,7 @@ * @param unit the unit of the amount to add, not null * @return an {@code OffsetTime} based on this time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -930,6 +938,7 @@ * @param unit the unit of the amount to subtract, not null * @return an {@code OffsetTime} based on this time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1020,13 +1029,13 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) offset; - } else if (query == Queries.zoneId() | query == Queries.chronology() || query == Queries.localDate()) { + } else if (query == TemporalQuery.zoneId() | query == TemporalQuery.chronology() || query == TemporalQuery.localDate()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) time; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1042,8 +1051,8 @@ * with the offset and time changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * twice, passing {@link ChronoField#OFFSET_SECONDS} and - * {@link ChronoField#NANO_OF_DAY} as the fields. + * twice, passing {@link ChronoField#NANO_OF_DAY} and + * {@link ChronoField#OFFSET_SECONDS} as the fields. *

    * In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: @@ -1063,8 +1072,8 @@ @Override public Temporal adjustInto(Temporal temporal) { return temporal - .with(OFFSET_SECONDS, offset.getTotalSeconds()) - .with(NANO_OF_DAY, time.toNanoOfDay()); + .with(NANO_OF_DAY, time.toNanoOfDay()) + .with(OFFSET_SECONDS, offset.getTotalSeconds()); } /** @@ -1112,6 +1121,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this time and the end time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1132,14 +1142,28 @@ case HOURS: return nanosUntil / NANOS_PER_HOUR; case HALF_DAYS: return nanosUntil / (12 * NANOS_PER_HOUR); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endTime); } + /** + * Formats this time using the specified formatter. + *

    + * This time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** - * Combines this date with a time to create an {@code OffsetDateTime}. + * Combines this time with a date to create an {@code OffsetDateTime}. *

    * This returns an {@code OffsetDateTime} formed from this time and the specified date. * All possible combinations of date and time are valid. @@ -1307,27 +1331,12 @@ return time.toString() + offset.toString(); } - /** - * Outputs this time as a {@code String} using the formatter. - *

    - * This time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - - // ----------------------------------------------------------------------- + //----------------------------------------------------------------------- /** * Writes the object using a * dedicated serialized form. *

    -     *  out.writeByte(9);  // identifies this as a OffsetDateTime
    +     *  out.writeByte(9);  // identifies this as a OffsetTime
          *  out.writeObject(time);
          *  out.writeObject(offset);
          * 
    --- old/src/share/classes/java/time/Period.java 2013-04-11 23:15:21.000000000 -0700 +++ new/src/share/classes/java/time/Period.java 2013-04-11 23:15:21.000000000 -0700 @@ -79,6 +79,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.Collections; @@ -215,26 +216,40 @@ //----------------------------------------------------------------------- /** - * Obtains a {@code Period} consisting of the number of years, months, - * and days between two dates. - *

    - * The start date is included, but the end date is not. - * The period is calculated by removing complete months, then calculating - * the remaining number of days, adjusting to ensure that both have the same sign. - * The number of months is then split into years and months based on a 12 month year. - * A month is considered if the end day-of-month is greater than or equal to the start day-of-month. - * For example, from {@code 2010-01-15} to {@code 2011-03-18} is one year, two months and three days. + * Obtains an instance of {@code Period} from a temporal amount. *

    - * The result of this method can be a negative period if the end is before the start. - * The negative sign will be the same in each of year, month and day. - * - * @param startDate the start date, inclusive, not null - * @param endDate the end date, exclusive, not null - * @return the period between this date and the end date, not null - * @see ChronoLocalDate#periodUntil(ChronoLocalDate) - */ - public static Period between(LocalDate startDate, LocalDate endDate) { - return startDate.periodUntil(endDate); + * This obtains a period based on the specified amount. + * A {@code TemporalAmount} represents an amount of time, which may be + * date-based or time-based, which this factory extracts to a period. + *

    + * The conversion loops around the set of units from the amount and uses + * the {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} + * and {@link ChronoUnit#DAYS DAYS} units to create a period. + * If any other units are found then an exception is thrown. + * + * @param amount the temporal amount to convert, not null + * @return the equivalent period, not null + * @throws DateTimeException if unable to convert to a {@code Period} + * @throws ArithmeticException if the amount of years, months or days exceeds an int + */ + public static Period from(TemporalAmount amount) { + Objects.requireNonNull(amount, "amount"); + int years = 0; + int months = 0; + int days = 0; + for (TemporalUnit unit : amount.getUnits()) { + long unitAmount = amount.get(unit); + if (unit == ChronoUnit.YEARS) { + years = Math.toIntExact(unitAmount); + } else if (unit == ChronoUnit.MONTHS) { + months = Math.toIntExact(unitAmount); + } else if (unit == ChronoUnit.DAYS) { + days = Math.toIntExact(unitAmount); + } else { + throw new DateTimeException("Unit must be Years, Months or Days, but was " + unit); + } + } + return create(years, months, days); } //----------------------------------------------------------------------- @@ -298,6 +313,30 @@ //----------------------------------------------------------------------- /** + * Obtains a {@code Period} consisting of the number of years, months, + * and days between two dates. + *

    + * The start date is included, but the end date is not. + * The period is calculated by removing complete months, then calculating + * the remaining number of days, adjusting to ensure that both have the same sign. + * The number of months is then split into years and months based on a 12 month year. + * A month is considered if the end day-of-month is greater than or equal to the start day-of-month. + * For example, from {@code 2010-01-15} to {@code 2011-03-18} is one year, two months and three days. + *

    + * The result of this method can be a negative period if the end is before the start. + * The negative sign will be the same in each of year, month and day. + * + * @param startDate the start date, inclusive, not null + * @param endDate the end date, exclusive, not null + * @return the period between this date and the end date, not null + * @see ChronoLocalDate#periodUntil(ChronoLocalDate) + */ + public static Period between(LocalDate startDate, LocalDate endDate) { + return startDate.periodUntil(endDate); + } + + //----------------------------------------------------------------------- + /** * Creates an instance. * * @param years the amount @@ -336,6 +375,7 @@ * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit * @throws DateTimeException if the unit is not supported + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override public long get(TemporalUnit unit) { @@ -346,7 +386,7 @@ } else if (unit == ChronoUnit.DAYS) { return getDays(); } else { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } } @@ -499,8 +539,7 @@ /** * Returns a copy of this period with the specified period added. *

    - * This operates separately on the years, months, days and the normalized time. - * There is no further normalization beyond the normalized time. + * This operates separately on the years, months and days. *

    * For example, "1 year, 6 months and 3 days" plus "2 years, 2 months and 2 days" * returns "3 years, 8 months and 5 days". @@ -582,8 +621,7 @@ /** * Returns a copy of this period with the specified period subtracted. *

    - * This operates separately on the years, months, days and the normalized time. - * There is no further normalization beyond the normalized time. + * This operates separately on the years, months and days. *

    * For example, "1 year, 6 months and 3 days" minus "2 years, 2 months and 2 days" * returns "-1 years, 4 months and 1 day". @@ -845,9 +883,11 @@ * @return the month range, negative if not fixed range */ private long monthRange(Temporal temporal) { - ValueRange startRange = Chronology.from(temporal).range(MONTH_OF_YEAR); - if (startRange.isFixed() && startRange.isIntValue()) { - return startRange.getMaximum() - startRange.getMinimum() + 1; + if (temporal.isSupported(MONTH_OF_YEAR)) { + ValueRange startRange = Chronology.from(temporal).range(MONTH_OF_YEAR); + if (startRange.isFixed() && startRange.isIntValue()) { + return startRange.getMaximum() - startRange.getMinimum() + 1; + } } return -1; } --- old/src/share/classes/java/time/Year.java 2013-04-11 23:15:22.000000000 -0700 +++ new/src/share/classes/java/time/Year.java 2013-04-11 23:15:22.000000000 -0700 @@ -80,7 +80,6 @@ import java.time.format.SignStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -88,6 +87,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -368,7 +368,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -378,6 +378,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -398,7 +399,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -407,7 +408,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -425,7 +429,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -435,6 +439,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -445,7 +450,7 @@ case YEAR: return year; case ERA: return (year < 1 ? 0 : 1); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -544,7 +549,7 @@ * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -557,6 +562,7 @@ * @param newValue the new value of the field in the result * @return a {@code Year} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -569,7 +575,7 @@ case YEAR: return Year.of((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : Year.of(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -632,7 +638,7 @@ * is unchanged. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -645,6 +651,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code Year} based on this year with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -657,7 +664,7 @@ case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -705,9 +712,9 @@ } /** - * Returns a copy of this year-month with the specified amount subtracted. + * Returns a copy of this year with the specified amount subtracted. *

    - * This returns a {@code YearMonth}, based on this one, with the amount + * This returns a {@code Year}, based on this one, with the amount * in terms of the unit subtracted. If it is not possible to subtract the amount, * because the unit is not supported or for some other reason, an exception is thrown. *

    @@ -718,8 +725,9 @@ * * @param amountToSubtract the amount of the unit to subtract from the result, may be negative * @param unit the unit of the amount to subtract, not null - * @return a {@code YearMonth} based on this year-month with the specified amount subtracted, not null + * @return a {@code Year} based on this year with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -762,9 +770,9 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) YEARS; } return Temporal.super.query(query); @@ -846,6 +854,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this year and the end year * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -864,11 +873,25 @@ case MILLENNIA: return yearsUntil / 1000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endYear); } + /** + * Formats this year using the specified formatter. + *

    + * This year will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted year string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this year with a day-of-year to create a {@code LocalDate}. @@ -1014,21 +1037,6 @@ return Integer.toString(year); } - /** - * Outputs this year as a {@code String} using the formatter. - *

    - * This year will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted year string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/YearMonth.java 2013-04-11 23:15:23.000000000 -0700 +++ new/src/share/classes/java/time/YearMonth.java 2013-04-11 23:15:23.000000000 -0700 @@ -61,9 +61,9 @@ */ package java.time; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static java.time.temporal.ChronoUnit.MONTHS; @@ -82,7 +82,6 @@ import java.time.format.SignStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -90,6 +89,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -255,7 +255,7 @@ * Obtains an instance of {@code YearMonth} from a text string such as {@code 2007-12}. *

    * The string must represent a valid year-month. - * The format must be {@code yyyy-MM}. + * The format must be {@code uuuu-MM}. * Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol. * * @param text the text to parse such as "2007-12", not null @@ -320,7 +320,7 @@ * The supported fields are: *

      *
    • {@code MONTH_OF_YEAR} - *
    • {@code EPOCH_MONTH} + *
    • {@code PROLEPTIC_MONTH} *
    • {@code YEAR_OF_ERA} *
    • {@code YEAR} *
    • {@code ERA} @@ -339,7 +339,7 @@ public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == YEAR || field == MONTH_OF_YEAR || - field == EPOCH_MONTH || field == YEAR_OF_ERA || field == ERA; + field == PROLEPTIC_MONTH || field == YEAR_OF_ERA || field == ERA; } return field != null && field.isSupportedBy(this); } @@ -355,7 +355,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -365,6 +365,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -384,9 +385,9 @@ *

      * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid - * values based on this year-month, except {@code EPOCH_MONTH} which is too + * values based on this year-month, except {@code PROLEPTIC_MONTH} which is too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -395,7 +396,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -413,7 +417,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year-month. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -423,6 +427,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -430,18 +435,18 @@ if (field instanceof ChronoField) { switch ((ChronoField) field) { case MONTH_OF_YEAR: return month; - case EPOCH_MONTH: return getEpochMonth(); + case PROLEPTIC_MONTH: return getProlepticMonth(); case YEAR_OF_ERA: return (year < 1 ? 1 - year : year); case YEAR: return year; case ERA: return (year < 1 ? 0 : 1); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } - private long getEpochMonth() { - return ((year - 1970) * 12L) + (month - 1); + private long getProlepticMonth() { + return (year * 12L + month - 1); } //----------------------------------------------------------------------- @@ -589,8 +594,8 @@ *

    • {@code MONTH_OF_YEAR} - * Returns a {@code YearMonth} with the specified month-of-year. * The year will be unchanged. - *
    • {@code EPOCH_MONTH} - - * Returns a {@code YearMonth} with the specified epoch-month. + *
    • {@code PROLEPTIC_MONTH} - + * Returns a {@code YearMonth} with the specified proleptic-month. * This completely replaces the year and month of this object. *
    • {@code YEAR_OF_ERA} - * Returns a {@code YearMonth} with the specified year-of-era @@ -606,7 +611,7 @@ * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

      - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -619,6 +624,7 @@ * @param newValue the new value of the field in the result * @return a {@code YearMonth} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -628,12 +634,12 @@ f.checkValidValue(newValue); switch (f) { case MONTH_OF_YEAR: return withMonth((int) newValue); - case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH)); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: return withYear((int) (year < 1 ? 1 - newValue : newValue)); case YEAR: return withYear((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -728,7 +734,7 @@ * is unchanged. *

    *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -741,6 +747,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code YearMonth} based on this year-month with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -754,7 +761,7 @@ case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -838,6 +845,7 @@ * @param unit the unit of the amount to subtract, not null * @return a {@code YearMonth} based on this year-month with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -893,9 +901,9 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) MONTHS; } return Temporal.super.query(query); @@ -908,7 +916,7 @@ * with the year and month changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * passing {@link ChronoField#EPOCH_MONTH} as the field. + * passing {@link ChronoField#PROLEPTIC_MONTH} as the field. * If the specified temporal object does not use the ISO calendar system then * a {@code DateTimeException} is thrown. *

    @@ -932,7 +940,7 @@ if (Chronology.from(temporal).equals(IsoChronology.INSTANCE) == false) { throw new DateTimeException("Adjustment only supported on ISO date-time"); } - return temporal.with(EPOCH_MONTH, getEpochMonth()); + return temporal.with(PROLEPTIC_MONTH, getProlepticMonth()); } /** @@ -977,6 +985,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this year-month and the end year-month * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -987,7 +996,7 @@ } YearMonth end = (YearMonth) endYearMonth; if (unit instanceof ChronoUnit) { - long monthsUntil = end.getEpochMonth() - getEpochMonth(); // no overflow + long monthsUntil = end.getProlepticMonth() - getProlepticMonth(); // no overflow switch ((ChronoUnit) unit) { case MONTHS: return monthsUntil; case YEARS: return monthsUntil / 12; @@ -996,11 +1005,25 @@ case MILLENNIA: return monthsUntil / 12000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endYearMonth); } + /** + * Formats this year-month using the specified formatter. + *

    + * This year-month will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted year-month string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this year-month with a day-of-month to create a {@code LocalDate}. @@ -1115,7 +1138,7 @@ /** * Outputs this year-month as a {@code String}, such as {@code 2007-12}. *

    - * The output will be in the format {@code yyyy-MM}: + * The output will be in the format {@code uuuu-MM}: * * @return a string representation of this year-month, not null */ @@ -1137,21 +1160,6 @@ .toString(); } - /** - * Outputs this year-month as a {@code String} using the formatter. - *

    - * This year-month will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted year-month string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/ZoneId.java 2013-04-11 23:15:24.000000000 -0700 +++ new/src/share/classes/java/time/ZoneId.java 2013-04-11 23:15:24.000000000 -0700 @@ -66,10 +66,10 @@ import java.io.Serializable; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.zone.ZoneRules; import java.time.zone.ZoneRulesException; import java.time.zone.ZoneRulesProvider; @@ -78,6 +78,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.TimeZone; /** @@ -93,6 +94,8 @@ * the offset from UTC/Greenwich apply *

    * Most fixed offsets are represented by {@link ZoneOffset}. + * Calling {@link #normalized()} on any {@code ZoneId} will ensure that a + * fixed offset ID will be represented as a {@code ZoneOffset}. *

    * The actual rules, describing when and how the offset changes, are defined by {@link ZoneRules}. * This class is simply an ID used to obtain the underlying rules. @@ -103,28 +106,29 @@ * the ID, whereas serializing the rules sends the entire data set. * Similarly, a comparison of two IDs only examines the ID, whereas * a comparison of two rules examines the entire data set. - *

    - * The code supports loading a {@code ZoneId} on a JVM which does not have available rules - * for that ID. This allows the date-time object, such as {@link ZonedDateTime}, - * to still be queried. * *

    Time-zone IDs

    * The ID is unique within the system. - * The formats for offset and region IDs differ. + * There are three types of ID. *

    - * An ID is parsed as an offset ID if it starts with 'UTC', 'GMT', 'UT' '+' or '-', or - * is a single letter. For example, 'Z', '+02:00', '-05:00', 'UTC+05', 'GMT-6' and - * 'UT+01:00' are all valid offset IDs. - * Note that some IDs, such as 'D' or '+ABC' meet the criteria to be parsed as offset IDs, - * but have an invalid offset. + * The simplest type of ID is that from {@code ZoneOffset}. + * This consists of 'Z' and IDs starting with '+' or '-'. *

    - * All other IDs are considered to be region IDs. + * The next type of ID are offset-style IDs with some form of prefix, + * such as 'GMT+2' or 'UTC+01:00'. + * The recognised prefixes are 'UTC', 'GMT' and 'UT'. + * The offset is the suffix and will be normalized during creation. + * These IDs can be normalized to a {@code ZoneOffset} using {@code normalized()}. *

    - * Region IDs are defined by configuration, which can be thought of as a {@code Map} - * from region ID to {@code ZoneRules}, see {@link ZoneRulesProvider}. + * The third type of ID are region-based IDs. A region-based ID must be of + * two or more characters, and not start with 'UTC', 'GMT', 'UT' '+' or '-'. + * Region-based IDs are defined by configuration, see {@link ZoneRulesProvider}. + * The configuration focuses on providing the lookup from the ID to the + * underlying {@code ZoneRules}. *

    - * Time-zones are defined by governments and change frequently. There are a number of - * organizations, known here as groups, that monitor time-zone changes and collate them. + * Time-zone rules are defined by governments and change frequently. + * There are a number of organizations, known here as groups, that monitor + * time-zone changes and collate them. * The default group is the IANA Time Zone Database (TZDB). * Other organizations include IATA (the airline industry body) and Microsoft. *

    @@ -139,6 +143,20 @@ * The recommended format for region IDs from groups other than TZDB is 'group~region'. * Thus if IATA data were defined, Utrecht airport would be 'IATA~UTC'. * + *

    Serialization

    + * This class can be serialized and stores the string zone ID in the external form. + * The {@code ZoneOffset} subclass uses a dedicated format that only stores the + * offset from UTC/Greenwich. + *

    + * A {@code ZoneId} can be deserialized in a Java Runtime where the ID is unknown. + * For example, if a server-side Java Runtime has been updated with a new zone ID, but + * the client-side Java Runtime has not been updated. In this case, the {@code ZoneId} + * object will exist, and can be queried using {@code getId}, {@code equals}, + * {@code hashCode}, {@code toString}, {@code getDisplayName} and {@code normalized}. + * However, any call to {@code getRules} will fail with {@code ZoneRulesException}. + * This approach is designed to allow a {@link ZonedDateTime} to be loaded and + * queried, but not modified, on a Java Runtime with incomplete time-zone information. + * *

    Specification for implementors

    * This abstract class has two implementations, both of which are immutable and thread-safe. * One implementation models region-based IDs, the other is {@code ZoneOffset} modelling @@ -149,7 +167,15 @@ public abstract class ZoneId implements Serializable { /** - * A map of zone overrides to enable the older US time-zone names to be used. + * A map of zone overrides to enable the older short time-zone names to be used. + *

    + * Use of short zone IDs has been deprecated in {@code java.util.TimeZone}. + * This map allows the IDs to continue to be used via the + * {@link #of(String, Map)} factory method. + *

    + * This map contains an older mapping of the IDs, where 'EST', 'MST' and 'HST' + * map to IDs which include daylight savings. + * This is in line with versions of TZDB before 2005r. *

    * This maps as follows: *

      @@ -184,9 +210,17 @@ *

    * The map is unmodifiable. */ - public static final Map OLD_IDS_PRE_2005; + public static final Map OLD_SHORT_IDS; /** - * A map of zone overrides to enable the older US time-zone names to be used. + * A map of zone overrides to enable the short time-zone names to be used. + *

    + * Use of short zone IDs has been deprecated in {@code java.util.TimeZone}. + * This map allows the IDs to continue to be used via the + * {@link #of(String, Map)} factory method. + *

    + * This map contains a newer mapping of the IDs, where 'EST', 'MST' and 'HST' + * map to IDs which do not include daylight savings + * This is in line with TZDB 2005r and later. *

    * This maps as follows: *

      @@ -221,7 +255,7 @@ *

    * The map is unmodifiable. */ - public static final Map OLD_IDS_POST_2005; + public static final Map SHORT_IDS; static { Map base = new HashMap<>(); base.put("ACT", "Australia/Darwin"); @@ -253,12 +287,12 @@ pre.put("EST", "America/New_York"); pre.put("MST", "America/Denver"); pre.put("HST", "Pacific/Honolulu"); - OLD_IDS_PRE_2005 = Collections.unmodifiableMap(pre); + OLD_SHORT_IDS = Collections.unmodifiableMap(pre); Map post = new HashMap<>(base); post.put("EST", "-05:00"); post.put("MST", "-07:00"); post.put("HST", "-10:00"); - OLD_IDS_POST_2005 = Collections.unmodifiableMap(post); + SHORT_IDS = Collections.unmodifiableMap(post); } /** * Serialization version. @@ -278,7 +312,23 @@ * @throws ZoneRulesException if the converted zone region ID cannot be found */ public static ZoneId systemDefault() { - return ZoneId.of(TimeZone.getDefault().getID(), OLD_IDS_POST_2005); + return ZoneId.of(TimeZone.getDefault().getID(), SHORT_IDS); + } + + /** + * Gets the set of available zone IDs. + *

    + * This set includes the string form of all available region-based IDs. + * Offset-based zone IDs are not included in the returned set. + * The ID can be passed to {@link #of(String)} to create a {@code ZoneId}. + *

    + * The set of zone IDs can increase over time, although in a typical application + * the set of IDs is fixed. Each call to this method is thread-safe. + * + * @return a modifiable copy of the set of zone IDs, not null + */ + public static Set getAvailableZoneIds() { + return ZoneRulesProvider.getAvailableZoneIds(); } //----------------------------------------------------------------------- @@ -310,31 +360,36 @@ * Obtains an instance of {@code ZoneId} from an ID ensuring that the * ID is valid and available for use. *

    - * This method parses the ID, applies any appropriate normalization, and validates it - * against the known set of IDs for which rules are available. - *

    - * An ID is parsed as though it is an offset ID if it starts with 'UTC', 'GMT', 'UT', '+' - * or '-', or if it has less then two letters. - * The offset of {@linkplain ZoneOffset#UTC zero} may be represented in multiple ways, - * including 'Z', 'UTC', 'GMT', 'UT', 'UTC0', 'GMT0', 'UT0', '+00:00', '-00:00' and 'UTC+00:00'. - *

    - * Six forms of ID are recognized: - *

      - *
    • Z - an offset of zero, which is {@code ZoneOffset.UTC} - *
    • {offset} - a {@code ZoneOffset} ID, such as '+02:00' - *
    • {utcPrefix} - a {@code ZoneOffset} ID equal to 'Z' - *
    • {utcPrefix}0 - a {@code ZoneOffset} ID equal to 'Z' - *
    • {utcPrefix}{offset} - a {@code ZoneOffset} ID equal to '{offset}' - *
    • {regionID} - full region ID, loaded from configuration - *

    - * The {offset} is a valid format for {@link ZoneOffset#of(String)}, excluding 'Z'. - * The {utcPrefix} is 'UTC', 'GMT' or 'UT'. - * Region IDs must match the regular expression [A-Za-z][A-Za-z0-9~/._+-]+. - *

    - * The detailed format of the region ID depends on the group supplying the data. - * The default set of data is supplied by the IANA Time Zone Database (TZDB) - * This has region IDs of the form '{area}/{city}', such as 'Europe/Paris' or 'America/New_York'. - * This is compatible with most IDs from {@link java.util.TimeZone}. + * This method parses the ID producing a {@code ZoneId} or {@code ZoneOffset}. + * A {@code ZoneOffset} is returned if the ID is 'Z', or starts with '+' or '-'. + * The result will always be a valid ID for which {@link ZoneRules} can be obtained. + *

    + * Parsing matches the zone ID step by step as follows. + *

      + *
    • If the zone ID equals 'Z', the result is {@code ZoneOffset.UTC}. + *
    • If the zone ID consists of a single letter, the zone ID is invalid + * and {@code DateTimeException} is thrown. + *
    • If the zone ID starts with '+' or '-', the ID is parsed as a + * {@code ZoneOffset} using {@link ZoneOffset#of(String)}. + *
    • If the zone ID equals 'GMT', 'UTC' or 'UT' then the result is a {@code ZoneId} + * with the same ID and rules equivalent to {@code ZoneOffset.UTC}. + *
    • If the zone ID starts with 'UTC+', 'UTC-', 'GMT+', 'GMT-', 'UT+' or 'UT-' + * then the ID is a prefixed offset-based ID. The ID is split in two, with + * a two or three letter prefix and a suffix starting with the sign. + * The suffix is parsed as a {@link ZoneOffset#of(String) ZoneOffset}. + * The result will be a {@code ZoneId} with the specified UTC/GMT/UT prefix + * and the normalized offset ID as per {@link ZoneOffset#getId()}. + * The rules of the returned {@code ZoneId} will be equivalent to the + * parsed {@code ZoneOffset}. + *
    • All other IDs are parsed as region-based zone IDs. Region IDs must + * match the regular expression [A-Za-z][A-Za-z0-9~/._+-]+ + * otherwise a {@code DateTimeException} is thrown. If the zone ID is not + * in the configured set of IDs, {@code ZoneRulesException} is thrown. + * The detailed format of the region ID depends on the group supplying the data. + * The default set of data is supplied by the IANA Time Zone Database (TZDB). + * This has region IDs of the form '{area}/{city}', such as 'Europe/Paris' or 'America/New_York'. + * This is compatible with most IDs from {@link java.util.TimeZone}. + *
    * * @param zoneId the time-zone ID, not null * @return the zone ID, not null @@ -342,15 +397,29 @@ * @throws ZoneRulesException if the zone ID is a region ID that cannot be found */ public static ZoneId of(String zoneId) { + return of(zoneId, true); + } + + /** + * Parses the ID, taking a flag to indicate whether {@code ZoneRulesException} + * should be thrown or not, used in deserialization. + * + * @param zoneId the time-zone ID, not null + * @param checkAvailable whether to check if the zone ID is available + * @return the zone ID, not null + * @throws DateTimeException if the ID format is invalid + * @throws ZoneRulesException if checking availability and the ID cannot be found + */ + static ZoneId of(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); if (zoneId.length() <= 1 || zoneId.startsWith("+") || zoneId.startsWith("-")) { return ZoneOffset.of(zoneId); } else if (zoneId.startsWith("UTC") || zoneId.startsWith("GMT")) { - return ofWithPrefix(zoneId, 3); + return ofWithPrefix(zoneId, 3, checkAvailable); } else if (zoneId.startsWith("UT")) { - return ofWithPrefix(zoneId, 2); + return ofWithPrefix(zoneId, 2, checkAvailable); } - return ZoneRegion.ofId(zoneId, true); + return ZoneRegion.ofId(zoneId, checkAvailable); } /** @@ -359,22 +428,25 @@ * @param zoneId the time-zone ID, not null * @param prefixLength the length of the prefix, 2 or 3 * @return the zone ID, not null - * @return the zone ID, not null * @throws DateTimeException if the zone ID has an invalid format */ - private static ZoneId ofWithPrefix(String zoneId, int prefixLength) { - if (zoneId.length() == prefixLength || - (zoneId.length() == prefixLength + 1 && zoneId.charAt(prefixLength) == '0')) { - return ZoneOffset.UTC; + private static ZoneId ofWithPrefix(String zoneId, int prefixLength, boolean checkAvailable) { + String prefix = zoneId.substring(0, prefixLength); + if (zoneId.length() == prefixLength) { + return ZoneRegion.ofPrefixedOffset(prefix, ZoneOffset.UTC); + } + if (zoneId.charAt(prefixLength) != '+' && zoneId.charAt(prefixLength) != '-') { + return ZoneRegion.ofId(zoneId, checkAvailable); // drop through to ZoneRulesProvider } - if (zoneId.charAt(prefixLength) == '+' || zoneId.charAt(prefixLength) == '-') { - try { - return ZoneOffset.of(zoneId.substring(prefixLength)); - } catch (DateTimeException ex) { - throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex); + try { + ZoneOffset offset = ZoneOffset.of(zoneId.substring(prefixLength)); + if (offset == ZoneOffset.UTC) { + return ZoneRegion.ofPrefixedOffset(prefix, offset); } + return ZoneRegion.ofPrefixedOffset(prefix + offset.toString(), offset); + } catch (DateTimeException ex) { + throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex); } - throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId); } //----------------------------------------------------------------------- @@ -389,7 +461,7 @@ * This factory converts the arbitrary temporal object to an instance of {@code ZoneId}. *

    * The conversion will try to obtain the zone in a way that favours region-based - * zones over offset-based zones using {@link Queries#zone()}. + * zones over offset-based zones using {@link TemporalQuery#zone()}. *

    * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used in queries via method reference, {@code ZoneId::from}. @@ -399,7 +471,7 @@ * @throws DateTimeException if unable to convert to a {@code ZoneId} */ public static ZoneId from(TemporalAccessor temporal) { - ZoneId obj = temporal.query(Queries.zone()); + ZoneId obj = temporal.query(TemporalQuery.zone()); if (obj == null) { throw new DateTimeException("Unable to obtain ZoneId from TemporalAccessor: " + temporal.getClass()); } @@ -429,29 +501,6 @@ //----------------------------------------------------------------------- /** - * Gets the time-zone rules for this ID allowing calculations to be performed. - *

    - * The rules provide the functionality associated with a time-zone, - * such as finding the offset for a given instant or local date-time. - *

    - * A time-zone can be invalid if it is deserialized in a JVM which does not - * have the same rules loaded as the JVM that stored it. In this case, calling - * this method will throw an exception. - *

    - * The rules are supplied by {@link ZoneRulesProvider}. An advanced provider may - * support dynamic updates to the rules without restarting the JVM. - * If so, then the result of this method may change over time. - * Each individual call will be still remain thread-safe. - *

    - * {@link ZoneOffset} will always return a set of rules where the offset never changes. - * - * @return the rules, not null - * @throws ZoneRulesException if no rules are available for this ID - */ - public abstract ZoneRules getRules(); - - //----------------------------------------------------------------------- - /** * Gets the textual representation of the zone, such as 'British Time' or * '+02:00'. *

    @@ -466,24 +515,88 @@ * @return the text value of the zone, not null */ public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(new TemporalAccessor() { + return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(toTemporal()); + } + + /** + * Converts this zone to a {@code TemporalAccessor}. + *

    + * A {@code ZoneId} can be fully represented as a {@code TemporalAccessor}. + * However, the interface is not implemented by this class as most of the + * methods on the interface have no meaning to {@code ZoneId}. + *

    + * The returned temporal has no supported fields, with the query method + * supporting the return of the zone using {@link TemporalQuery#zoneId()}. + * + * @return a temporal equivalent to this zone, not null + */ + private TemporalAccessor toTemporal() { + return new TemporalAccessor() { @Override public boolean isSupported(TemporalField field) { return false; } @Override public long getLong(TemporalField field) { - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) ZoneId.this; } return TemporalAccessor.super.query(query); } - }); + }; + } + + //----------------------------------------------------------------------- + /** + * Gets the time-zone rules for this ID allowing calculations to be performed. + *

    + * The rules provide the functionality associated with a time-zone, + * such as finding the offset for a given instant or local date-time. + *

    + * A time-zone can be invalid if it is deserialized in a Java Runtime which + * does not have the same rules loaded as the Java Runtime that stored it. + * In this case, calling this method will throw a {@code ZoneRulesException}. + *

    + * The rules are supplied by {@link ZoneRulesProvider}. An advanced provider may + * support dynamic updates to the rules without restarting the Java Runtime. + * If so, then the result of this method may change over time. + * Each individual call will be still remain thread-safe. + *

    + * {@link ZoneOffset} will always return a set of rules where the offset never changes. + * + * @return the rules, not null + * @throws ZoneRulesException if no rules are available for this ID + */ + public abstract ZoneRules getRules(); + + /** + * Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible. + *

    + * The returns a normalized {@code ZoneId} that can be used in place of this ID. + * The result will have {@code ZoneRules} equivalent to those returned by this object, + * however the ID returned by {@code getId()} may be different. + *

    + * The normalization checks if the rules of this {@code ZoneId} have a fixed offset. + * If they do, then the {@code ZoneOffset} equal to that offset is returned. + * Otherwise {@code this} is returned. + * + * @return the time-zone unique ID, not null + */ + public ZoneId normalized() { + try { + ZoneRules rules = getRules(); + if (rules.isFixedOffset()) { + return rules.getOffset(Instant.EPOCH); + } + } catch (ZoneRulesException ex) { + // invalid ZoneRegion is not important to this method + } + return this; } //----------------------------------------------------------------------- @@ -536,6 +649,10 @@ * out.writeByte(7); // identifies this as a ZoneId (not ZoneOffset) * out.writeUTF(zoneId); * + *

    + * When read back in, the {@code ZoneId} will be created as though using + * {@link #of(String)}, but without any exception in the case where the + * ID has a valid format, but is not in the known set of region-based IDs. * * @return the instance of {@code Ser}, not null */ --- old/src/share/classes/java/time/ZoneOffset.java 2013-04-11 23:15:25.000000000 -0700 +++ new/src/share/classes/java/time/ZoneOffset.java 2013-04-11 23:15:24.000000000 -0700 @@ -61,6 +61,7 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.LocalTime.MINUTES_PER_HOUR; import static java.time.LocalTime.SECONDS_PER_HOUR; import static java.time.LocalTime.SECONDS_PER_MINUTE; @@ -73,7 +74,6 @@ import java.io.ObjectStreamException; import java.io.Serializable; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -322,7 +322,7 @@ * A {@code TemporalAccessor} represents some form of date and time information. * This factory converts the arbitrary temporal object to an instance of {@code ZoneOffset}. *

    - * The conversion uses the {@link Queries#offset()} query, which relies + * The conversion uses the {@link TemporalQuery#offset()} query, which relies * on extracting the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -333,7 +333,7 @@ * @throws DateTimeException if unable to convert to an {@code ZoneOffset} */ public static ZoneOffset from(TemporalAccessor temporal) { - ZoneOffset offset = temporal.query(Queries.offset()); + ZoneOffset offset = temporal.query(TemporalQuery.offset()); if (offset == null) { throw new DateTimeException("Unable to obtain ZoneOffset from TemporalAccessor: " + temporal.getClass()); } @@ -534,7 +534,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -544,6 +544,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -560,7 +561,7 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code OFFSET_SECONDS} field returns the value of the offset. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -569,7 +570,10 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -577,7 +581,7 @@ if (field == OFFSET_SECONDS) { return totalSeconds; } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return range(field).checkValidIntValue(getLong(field), field); } @@ -591,7 +595,7 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code OFFSET_SECONDS} field returns the value of the offset. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -601,6 +605,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -608,7 +613,7 @@ if (field == OFFSET_SECONDS) { return totalSeconds; } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -635,7 +640,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) this; } return TemporalAccessor.super.query(query); --- old/src/share/classes/java/time/ZoneRegion.java 2013-04-11 23:15:25.000000000 -0700 +++ new/src/share/classes/java/time/ZoneRegion.java 2013-04-11 23:15:25.000000000 -0700 @@ -95,11 +95,6 @@ */ private static final long serialVersionUID = 8386373296231747096L; /** - * The regex pattern for region IDs. - */ - private static final Pattern PATTERN = Pattern.compile("[A-Za-z][A-Za-z0-9~/._+-]+"); - - /** * The time-zone ID, not null. */ private final String id; @@ -109,26 +104,6 @@ private final transient ZoneRules rules; /** - * Obtains an instance of {@code ZoneRegion} from an identifier without checking - * if the time-zone has available rules. - *

    - * This method parses the ID and applies any appropriate normalization. - * It does not validate the ID against the known set of IDs for which rules are available. - *

    - * This method is intended for advanced use cases. - * For example, consider a system that always retrieves time-zone rules from a remote server. - * Using this factory would allow a {@code ZoneRegion}, and thus a {@code ZonedDateTime}, - * to be created without loading the rules from the remote server. - * - * @param zoneId the time-zone ID, not null - * @return the zone ID, not null - * @throws DateTimeException if the ID format is invalid - */ - private static ZoneRegion ofLenient(String zoneId) { - return ofId(zoneId, false); - } - - /** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null @@ -139,12 +114,7 @@ */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); - if (zoneId.length() < 2 || - zoneId.startsWith("UT") || // includes UTC - zoneId.startsWith("GMT") || - (PATTERN.matcher(zoneId).matches() == false)) { - throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); - } + checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization @@ -157,6 +127,45 @@ return new ZoneRegion(zoneId, rules); } + /** + * Checks that the given string is a legal ZondId name. + * + * @param zoneId the time-zone ID, not null + * @throws DateTimeException if the ID format is invalid + */ + private static void checkName(String zoneId) { + int n = zoneId.length(); + if (n < 2) { + throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); + } + for (int i = 0; i < n; i++) { + char c = zoneId.charAt(i); + if (c >= 'a' && c <= 'z') continue; + if (c >= 'A' && c <= 'Z') continue; + if (c == '/' && i != 0) continue; + if (c >= '0' && c <= '9' && i != 0) continue; + if (c == '~' && i != 0) continue; + if (c == '.' && i != 0) continue; + if (c == '_' && i != 0) continue; + if (c == '+' && i != 0) continue; + if (c == '-' && i != 0) continue; + throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); + } + } + + /** + * Obtains an instance of {@code ZoneId} wrapping an offset. + *

    + * For example, zone IDs like 'UTC', 'GMT', 'UT' and 'UTC+01:30' will be setup here. + * + * @param zoneId the time-zone ID, not null + * @param offset the offset, not null + * @return the zone ID, not null + */ + static ZoneRegion ofPrefixedOffset(String zoneId, ZoneOffset offset) { + return new ZoneRegion(zoneId, offset.getRules()); + } + //------------------------------------------------------------------------- /** * Constructor. @@ -218,7 +227,7 @@ static ZoneId readExternal(DataInput in) throws IOException { String id = in.readUTF(); - return ofLenient(id); + return ZoneId.of(id, false); } } --- old/src/share/classes/java/time/ZonedDateTime.java 2013-04-11 23:15:26.000000000 -0700 +++ new/src/share/classes/java/time/ZonedDateTime.java 2013-04-11 23:15:26.000000000 -0700 @@ -72,7 +72,6 @@ import java.io.ObjectStreamException; import java.io.Serializable; import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; @@ -84,6 +83,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; @@ -136,6 +136,11 @@ * used, typically "summer" time.. Two additional methods, * {@link #withEarlierOffsetAtOverlap()} and {@link #withLaterOffsetAtOverlap()}, * help manage the case of an overlap. + *

    + * In terms of design, this class should be viewed primarily as the combination + * of a {@code LocalDateTime} and a {@code ZoneId}. The {@code ZoneOffset} is + * a vital, but secondary, piece of information, used to ensure that the class + * represents an instant, especially during a daylight savings overlap. * *

    Specification for implementors

    * A {@code ZonedDateTime} holds state equivalent to three separate objects, @@ -420,6 +425,9 @@ Objects.requireNonNull(localDateTime, "localDateTime"); Objects.requireNonNull(offset, "offset"); Objects.requireNonNull(zone, "zone"); + if (zone.getRules().isValidOffset(localDateTime, offset)) { + return new ZonedDateTime(localDateTime, offset, zone); + } return create(localDateTime.toEpochSecond(offset), localDateTime.getNano(), zone); } @@ -615,17 +623,18 @@ } /** - * Resolves the offset into this zoned date-time. + * Resolves the offset into this zoned date-time for the with methods. *

    - * This will use the new offset to find the instant, which is then looked up - * using the zone ID to find the actual offset to use. + * This typically ignores the offset, unless it can be used to switch offset in a DST overlap. * * @param offset the offset, not null * @return the zoned date-time, not null */ private ZonedDateTime resolveOffset(ZoneOffset offset) { - long epSec = dateTime.toEpochSecond(offset); - return create(epSec, dateTime.getNano(), zone); + if (offset.equals(this.offset) == false && zone.getRules().isValidOffset(dateTime, offset)) { + return new ZonedDateTime(dateTime, offset, zone); + } + return this; } //----------------------------------------------------------------------- @@ -663,7 +672,7 @@ *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -696,7 +705,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -706,6 +715,7 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -729,9 +739,9 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too + * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -740,15 +750,20 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance public int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return dateTime.get(field); } @@ -765,7 +780,7 @@ * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -775,6 +790,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1115,7 +1131,7 @@ *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -1137,15 +1153,12 @@ * result = zonedDateTime.with(time); * *

    - * {@link ZoneOffset} also implements {@code TemporalAdjuster} however it is less likely - * that setting the offset will have the effect you expect. When an offset is passed in, - * the local date-time is combined with the new offset to form an {@code Instant}. - * The instant and original zone are then used to create the result. - * This algorithm means that it is quite likely that the output has a different offset - * to the specified offset. It will however work correctly when passing in the offset - * applicable for the instant of the zoned date-time, and will work correctly if passing - * one of the two valid offsets during a daylight savings overlap when the same local time - * occurs twice. + * {@link ZoneOffset} also implements {@code TemporalAdjuster} however using it + * as an argument typically has no effect. The offset of a {@code ZonedDateTime} is + * controlled primarily by the time-zone. As such, changing the offset does not generally + * make sense, because there is only one valid offset for the local date-time and zone. + * If the zoned date-time is in a daylight savings overlap, then the offset is used + * to switch between the two valid offsets. In all other cases, the offset is ignored. *

    * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the @@ -1167,6 +1180,9 @@ return resolveLocal(LocalDateTime.of(dateTime.toLocalDate(), (LocalTime) adjuster)); } else if (adjuster instanceof LocalDateTime) { return resolveLocal((LocalDateTime) adjuster); + } else if (adjuster instanceof OffsetDateTime) { + OffsetDateTime odt = (OffsetDateTime) adjuster; + return ofLocal(odt.toLocalDateTime(), zone, odt.getOffset()); } else if (adjuster instanceof Instant) { Instant instant = (Instant) adjuster; return create(instant.getEpochSecond(), instant.getNano(), zone); @@ -1197,15 +1213,13 @@ * The result will have an offset derived from the new instant and original zone. * If the new instant value is outside the valid range then a {@code DateTimeException} will be thrown. *

    - * The {@code OFFSET_SECONDS} field will return a date-time calculated using the specified offset. - * The local date-time is combined with the new offset to form an {@code Instant}. - * The instant and original zone are then used to create the result. - * This algorithm means that it is quite likely that the output has a different offset - * to the specified offset. It will however work correctly when passing in the offset - * applicable for the instant of the zoned date-time, and will work correctly if passing - * one of the two valid offsets during a daylight savings overlap when the same local time - * occurs twice. If the new offset value is outside the valid range then a - * {@code DateTimeException} will be thrown. + * The {@code OFFSET_SECONDS} field will typically be ignored. + * The offset of a {@code ZonedDateTime} is controlled primarily by the time-zone. + * As such, changing the offset does not generally make sense, because there is only + * one valid offset for the local date-time and zone. + * If the zoned date-time is in a daylight savings overlap, then the offset is used + * to switch between the two valid offsets. In all other cases, the offset is ignored. + * If the new offset value is outside the valid range then a {@code DateTimeException} will be thrown. *

    * The other {@link #isSupported(TemporalField) supported fields} will behave as per * the matching method on {@link LocalDateTime#with(TemporalField, long) LocalDateTime}. @@ -1214,7 +1228,7 @@ * then the offset will be retained if possible, otherwise the earlier offset will be used. * If in a gap, the local date-time will be adjusted forward by the length of the gap. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -1227,6 +1241,7 @@ * @param newValue the new value of the field in the result * @return a {@code ZonedDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1234,11 +1249,11 @@ if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; switch (f) { - case INSTANT_SECONDS: return create(newValue, getNano(), zone); - case OFFSET_SECONDS: { + case INSTANT_SECONDS: + return create(newValue, getNano(), zone); + case OFFSET_SECONDS: ZoneOffset offset = ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)); return resolveOffset(offset); - } } return resolveLocal(dateTime.with(field, newValue)); } @@ -1453,6 +1468,7 @@ * @param unit the unit to truncate to, not null * @return a {@code ZonedDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public ZonedDateTime truncatedTo(TemporalUnit unit) { return resolveLocal(dateTime.truncatedTo(unit)); @@ -1518,6 +1534,7 @@ * @param unit the unit of the amount to add, not null * @return a {@code ZonedDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1761,6 +1778,7 @@ * @param unit the unit of the amount to subtract, not null * @return a {@code ZonedDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -2025,6 +2043,7 @@ * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -2046,6 +2065,21 @@ return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Converts this date-time to an {@code OffsetDateTime}. @@ -2113,21 +2147,6 @@ return str; } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoZonedDateTime.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a --- old/src/share/classes/java/time/chrono/ChronoDateImpl.java 2013-04-11 23:15:27.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoDateImpl.java 2013-04-11 23:15:27.000000000 -0700 @@ -59,19 +59,18 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import java.io.Serializable; import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; +import java.util.Objects; /** * A date expressed in terms of a standard year-month-day calendar system. @@ -97,12 +96,12 @@ * // Enumerate the list of available calendars and print today for each * Set<Chronology> chronos = Chronology.getAvailableChronologies(); * for (Chronology chrono : chronos) { - * ChronoLocalDate date = chrono.dateNow(); + * ChronoLocalDate<?> date = chrono.dateNow(); * System.out.printf(" %20s: %s%n", chrono.getID(), date.toString()); * } * * // Print the Hijrah date and calendar - * ChronoLocalDate date = Chronology.of("Hijrah").dateNow(); + * ChronoLocalDate<?> date = Chronology.of("Hijrah").dateNow(); * int day = date.get(ChronoField.DAY_OF_MONTH); * int dow = date.get(ChronoField.DAY_OF_WEEK); * int month = date.get(ChronoField.MONTH_OF_YEAR); @@ -111,10 +110,10 @@ * dow, day, month, year); * // Print today's date and the last day of the year - * ChronoLocalDate now1 = Chronology.of("Hijrah").dateNow(); - * ChronoLocalDate first = now1.with(ChronoField.DAY_OF_MONTH, 1) + * ChronoLocalDate<?> now1 = Chronology.of("Hijrah").dateNow(); + * ChronoLocalDate<?> first = now1.with(ChronoField.DAY_OF_MONTH, 1) * .with(ChronoField.MONTH_OF_YEAR, 1); - * ChronoLocalDate last = first.plus(1, ChronoUnit.YEARS) + * ChronoLocalDate<?> last = first.plus(1, ChronoUnit.YEARS) * .minus(1, ChronoUnit.DAYS); * System.out.printf(" Today is %s: start: %s; end: %s%n", last.getChronology().getID(), * first, last); @@ -168,7 +167,7 @@ case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return ChronoLocalDate.super.plus(amountToAdd, unit); } @@ -323,6 +322,8 @@ */ @Override public long periodUntil(Temporal endDateTime, TemporalUnit unit) { + Objects.requireNonNull(endDateTime, "endDateTime"); + Objects.requireNonNull(unit, "unit"); if (endDateTime instanceof ChronoLocalDate == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } @@ -331,11 +332,35 @@ throw new DateTimeException("Unable to calculate period between two different chronologies"); } if (unit instanceof ChronoUnit) { - return LocalDate.from(this).periodUntil(end, unit); // TODO: this is wrong + switch ((ChronoUnit) unit) { + case DAYS: return daysUntil(end); + case WEEKS: return daysUntil(end) / 7; + case MONTHS: return monthsUntil(end); + case YEARS: return monthsUntil(end) / 12; + case DECADES: return monthsUntil(end) / 120; + case CENTURIES: return monthsUntil(end) / 1200; + case MILLENNIA: return monthsUntil(end) / 12000; + case ERAS: return end.getLong(ERA) - getLong(ERA); + } + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endDateTime); } + private long daysUntil(ChronoLocalDate end) { + return end.toEpochDay() - toEpochDay(); // no overflow + } + + private long monthsUntil(ChronoLocalDate end) { + ValueRange range = getChronology().range(MONTH_OF_YEAR); + if (range.getMaximum() != 12) { + throw new IllegalStateException("ChronoDateImpl only supports Chronologies with 12 months per year"); + } + long packed1 = getLong(PROLEPTIC_MONTH) * 32L + get(DAY_OF_MONTH); // no overflow + long packed2 = end.getLong(PROLEPTIC_MONTH) * 32L + end.get(DAY_OF_MONTH); // no overflow + return (packed2 - packed1) / 32; + } + @Override public boolean equals(Object obj) { if (this == obj) { --- old/src/share/classes/java/time/chrono/ChronoLocalDate.java 2013-04-11 23:15:28.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoLocalDate.java 2013-04-11 23:15:28.000000000 -0700 @@ -73,7 +73,6 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -81,6 +80,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.Comparator; import java.util.Objects; @@ -249,25 +249,55 @@ extends Temporal, TemporalAdjuster, Comparable> { /** - * Comparator for two {@code ChronoLocalDate}s ignoring the chronology. + * Gets a comparator that compares {@code ChronoLocalDate} in + * time-line order ignoring the chronology. *

    * This comparator differs from the comparison in {@link #compareTo} in that it * only compares the underlying date and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. - * This is equivalent to using {@code Long.compare(date1.toEpochDay(), date2.toEpochDay())}. + * on the position of the date on the local time-line. + * The underlying comparison is equivalent to comparing the epoch-day. * * @see #isAfter * @see #isBefore * @see #isEqual */ - public static final Comparator> DATE_COMPARATOR = - new Comparator>() { - @Override - public int compare(ChronoLocalDate date1, ChronoLocalDate date2) { - return Long.compare(date1.toEpochDay(), date2.toEpochDay()); + static Comparator> timeLineOrder() { + return Chronology.DATE_ORDER; + } + + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoLocalDate} from a temporal object. + *

    + * This obtains a local date based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoLocalDate}. + *

    + * The conversion extracts and combines the chronology and the date + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#date(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoLocalDate::from}. + * + * @param temporal the temporal object to convert, not null + * @return the date, not null + * @throws DateTimeException if unable to convert to a {@code ChronoLocalDate} + * @see Chronology#date(TemporalAccessor) + */ + static ChronoLocalDate from(TemporalAccessor temporal) { + if (temporal instanceof ChronoLocalDate) { + return (ChronoLocalDate) temporal; } - }; + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoLocalDate from TemporalAccessor: " + temporal.getClass()); + } + return chrono.date(temporal); + } //----------------------------------------------------------------------- /** @@ -295,7 +325,7 @@ * * @return the chronology specific era constant applicable at this date, not null */ - public default Era getEra() { + default Era getEra() { return getChronology().eraOf(get(ERA)); } @@ -310,7 +340,7 @@ * * @return true if this date is in a leap year, false otherwise */ - public default boolean isLeapYear() { + default boolean isLeapYear() { return getChronology().isLeapYear(getLong(YEAR)); } @@ -332,14 +362,14 @@ * * @return the length of the year in days */ - public default int lengthOfYear() { + default int lengthOfYear() { return (isLeapYear() ? 366 : 365); } @Override - public default boolean isSupported(TemporalField field) { + default boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isDateField(); + return field.isDateBased(); } return field != null && field.isSupportedBy(this); } @@ -352,19 +382,20 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default D with(TemporalAdjuster adjuster) { + default D with(TemporalAdjuster adjuster) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.with(adjuster)); } /** * {@inheritDoc} * @throws DateTimeException {@inheritDoc} + * @throws UnsupportedTemporalTypeException {@inheritDoc} * @throws ArithmeticException {@inheritDoc} */ @Override - public default D with(TemporalField field, long newValue) { + default D with(TemporalField field, long newValue) { if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return (D) getChronology().ensureChronoLocalDate(field.adjustInto(this, newValue)); } @@ -375,7 +406,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default D plus(TemporalAmount amount) { + default D plus(TemporalAmount amount) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.plus(amount)); } @@ -385,9 +416,9 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default D plus(long amountToAdd, TemporalUnit unit) { + default D plus(long amountToAdd, TemporalUnit unit) { if (unit instanceof ChronoUnit) { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return (D) getChronology().ensureChronoLocalDate(unit.addTo(this, amountToAdd)); } @@ -398,17 +429,18 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default D minus(TemporalAmount amount) { + default D minus(TemporalAmount amount) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.minus(amount)); } /** * {@inheritDoc} * @throws DateTimeException {@inheritDoc} + * @throws UnsupportedTemporalTypeException {@inheritDoc} * @throws ArithmeticException {@inheritDoc} */ @Override - public default D minus(long amountToSubtract, TemporalUnit unit) { + default D minus(long amountToSubtract, TemporalUnit unit) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.minus(amountToSubtract, unit)); } @@ -433,14 +465,14 @@ */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return null; - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) DAYS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -473,7 +505,7 @@ * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal.with(EPOCH_DAY, toEpochDay()); } @@ -522,7 +554,7 @@ * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc - public abstract long periodUntil(Temporal endDate, TemporalUnit unit); + long periodUntil(Temporal endDate, TemporalUnit unit); /** * Calculates the period between this date and another date as a {@code Period}. @@ -530,13 +562,11 @@ * This calculates the period between two dates in terms of years, months and days. * The start and end points are {@code this} and the specified date. * The result will be negative if the end is before the start. + * The negative sign will be the same in each of year, month and day. *

    - * The calculation is performed using the the chronology of this date. + * The calculation is performed using the chronology of this date. * If necessary, the input date will be converted to match. *

    - * The result of this method can be a negative period if the end is before the start. - * The negative sign will be the same in each of year, month and day. - *

    * This instance is immutable and unaffected by this method call. * * @param endDate the end date, exclusive, which may be in any chronology, not null @@ -544,7 +574,26 @@ * @throws DateTimeException if the period cannot be calculated * @throws ArithmeticException if numeric overflow occurs */ - public abstract Period periodUntil(ChronoLocalDate endDate); + Period periodUntil(ChronoLocalDate endDate); + + /** + * Formats this date using the specified formatter. + *

    + * This date will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } //----------------------------------------------------------------------- /** @@ -556,7 +605,7 @@ * @param localTime the local time to use, not null * @return the local date-time formed from this date and the specified time, not null */ - public default ChronoLocalDateTime atTime(LocalTime localTime) { + default ChronoLocalDateTime atTime(LocalTime localTime) { return (ChronoLocalDateTime)ChronoLocalDateTimeImpl.of(this, localTime); } @@ -572,7 +621,7 @@ * * @return the Epoch Day equivalent to this date */ - public default long toEpochDay() { + default long toEpochDay() { return getLong(EPOCH_DAY); } @@ -606,7 +655,7 @@ * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoLocalDate other) { + default int compareTo(ChronoLocalDate other) { int cmp = Long.compare(toEpochDay(), other.toEpochDay()); if (cmp == 0) { cmp = getChronology().compareTo(other.getChronology()); @@ -628,7 +677,7 @@ * @param other the other date to compare to, not null * @return true if this is after the specified date */ - public default boolean isAfter(ChronoLocalDate other) { + default boolean isAfter(ChronoLocalDate other) { return this.toEpochDay() > other.toEpochDay(); } @@ -646,7 +695,7 @@ * @param other the other date to compare to, not null * @return true if this is before the specified date */ - public default boolean isBefore(ChronoLocalDate other) { + default boolean isBefore(ChronoLocalDate other) { return this.toEpochDay() < other.toEpochDay(); } @@ -664,7 +713,7 @@ * @param other the other date to compare to, not null * @return true if the underlying date is equal to the specified date */ - public default boolean isEqual(ChronoLocalDate other) { + default boolean isEqual(ChronoLocalDate other) { return this.toEpochDay() == other.toEpochDay(); } @@ -695,28 +744,11 @@ /** * Outputs this date as a {@code String}. *

    - * The output will include the full local date and the chronology ID. + * The output will include the full local date. * * @return the formatted date, not null */ @Override String toString(); - /** - * Outputs this date as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - } --- old/src/share/classes/java/time/chrono/ChronoLocalDateTime.java 2013-04-11 23:15:29.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoLocalDateTime.java 2013-04-11 23:15:28.000000000 -0700 @@ -73,7 +73,6 @@ import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -119,29 +118,57 @@ extends Temporal, TemporalAdjuster, Comparable> { /** - * Comparator for two {@code ChronoLocalDateTime} instances ignoring the chronology. + * Gets a comparator that compares {@code ChronoLocalDateTime} in + * time-line order ignoring the chronology. *

    - * This method differs from the comparison in {@link #compareTo} in that it - * only compares the underlying date and not the chronology. + * This comparator differs from the comparison in {@link #compareTo} in that it + * only compares the underlying date-time and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. + * on the position of the date-time on the local time-line. + * The underlying comparison is equivalent to comparing the epoch-day and nano-of-day. * * @see #isAfter * @see #isBefore * @see #isEqual */ - Comparator> DATE_TIME_COMPARATOR = - new Comparator>() { - @Override - public int compare(ChronoLocalDateTime datetime1, ChronoLocalDateTime datetime2) { - int cmp = Long.compare(datetime1.toLocalDate().toEpochDay(), datetime2.toLocalDate().toEpochDay()); - if (cmp == 0) { - cmp = Long.compare(datetime1.toLocalTime().toNanoOfDay(), datetime2.toLocalTime().toNanoOfDay()); - } - return cmp; + static Comparator> timeLineOrder() { + return Chronology.DATE_TIME_ORDER; + } + + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoLocalDateTime} from a temporal object. + *

    + * This obtains a local date-time based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoLocalDateTime}. + *

    + * The conversion extracts and combines the chronology and the date-time + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#localDateTime(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoLocalDateTime::from}. + * + * @param temporal the temporal object to convert, not null + * @return the date-time, not null + * @throws DateTimeException if unable to convert to a {@code ChronoLocalDateTime} + * @see Chronology#localDateTime(TemporalAccessor) + */ + static ChronoLocalDateTime from(TemporalAccessor temporal) { + if (temporal instanceof ChronoLocalDateTime) { + return (ChronoLocalDateTime) temporal; + } + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoLocalDateTime from TemporalAccessor: " + temporal.getClass()); } - }; + return chrono.localDateTime(temporal); + } + //----------------------------------------------------------------------- /** * Gets the local date part of this date-time. *

    @@ -163,7 +190,7 @@ LocalTime toLocalTime(); @Override // Override to provide javadoc - public boolean isSupported(TemporalField field); + boolean isSupported(TemporalField field); //----------------------------------------------------------------------- // override for covariant return type @@ -173,7 +200,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime with(TemporalAdjuster adjuster) { + default ChronoLocalDateTime with(TemporalAdjuster adjuster) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.with(adjuster))); } @@ -191,7 +218,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime plus(TemporalAmount amount) { + default ChronoLocalDateTime plus(TemporalAmount amount) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.plus(amount))); } @@ -209,7 +236,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime minus(TemporalAmount amount) { + default ChronoLocalDateTime minus(TemporalAmount amount) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.minus(amount))); } @@ -219,7 +246,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime minus(long amountToSubtract, TemporalUnit unit) { + default ChronoLocalDateTime minus(long amountToSubtract, TemporalUnit unit) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.minus(amountToSubtract, unit))); } @@ -244,14 +271,14 @@ */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) toLocalDate().getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -285,12 +312,31 @@ * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal .with(EPOCH_DAY, toLocalDate().toEpochDay()) .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this time with a time-zone to create a {@code ChronoZonedDateTime}. @@ -334,7 +380,7 @@ * @param offset the offset to use for the conversion, not null * @return an {@code Instant} representing the same instant, not null */ - public default Instant toInstant(ZoneOffset offset) { + default Instant toInstant(ZoneOffset offset) { return Instant.ofEpochSecond(toEpochSecond(offset), toLocalTime().getNano()); } @@ -352,7 +398,7 @@ * @param offset the offset to use for the conversion, not null * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ - public default long toEpochSecond(ZoneOffset offset) { + default long toEpochSecond(ZoneOffset offset) { Objects.requireNonNull(offset, "offset"); long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); @@ -388,7 +434,7 @@ * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoLocalDateTime other) { + default int compareTo(ChronoLocalDateTime other) { int cmp = toLocalDate().compareTo(other.toLocalDate()); if (cmp == 0) { cmp = toLocalTime().compareTo(other.toLocalTime()); @@ -413,7 +459,7 @@ * @param other the other date-time to compare to, not null * @return true if this is after the specified date-time */ - public default boolean isAfter(ChronoLocalDateTime other) { + default boolean isAfter(ChronoLocalDateTime other) { long thisEpDay = this.toLocalDate().toEpochDay(); long otherEpDay = other.toLocalDate().toEpochDay(); return thisEpDay > otherEpDay || @@ -434,7 +480,7 @@ * @param other the other date-time to compare to, not null * @return true if this is before the specified date-time */ - public default boolean isBefore(ChronoLocalDateTime other) { + default boolean isBefore(ChronoLocalDateTime other) { long thisEpDay = this.toLocalDate().toEpochDay(); long otherEpDay = other.toLocalDate().toEpochDay(); return thisEpDay < otherEpDay || @@ -455,7 +501,7 @@ * @param other the other date-time to compare to, not null * @return true if the underlying date-time is equal to the specified date-time on the timeline */ - public default boolean isEqual(ChronoLocalDateTime other) { + default boolean isEqual(ChronoLocalDateTime other) { // Do the time check first, it is cheaper than computing EPOCH day. return this.toLocalTime().toNanoOfDay() == other.toLocalTime().toNanoOfDay() && this.toLocalDate().toEpochDay() == other.toLocalDate().toEpochDay(); @@ -484,27 +530,11 @@ /** * Outputs this date-time as a {@code String}. *

    - * The output will include the full local date-time and the chronology ID. + * The output will include the full local date-time. * * @return a string representation of this date-time, not null */ @Override String toString(); - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } } --- old/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java 2013-04-11 23:15:30.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java 2013-04-11 23:15:29.000000000 -0700 @@ -171,6 +171,7 @@ * @param time the local time, not null * @return the local date-time, not null */ + @SuppressWarnings("rawtypes") static ChronoLocalDateTimeImpl of(ChronoLocalDate date, LocalTime time) { return new ChronoLocalDateTimeImpl(date, time); } @@ -201,8 +202,8 @@ return this; } // Validate that the new Temporal is a ChronoLocalDate (and not something else) - D cd = (D)date.getChronology().ensureChronoLocalDate(newDate); - return new ChronoLocalDateTimeImpl<>((D)cd, newTime); + D cd = (D) date.getChronology().ensureChronoLocalDate(newDate); + return new ChronoLocalDateTimeImpl<>(cd, newTime); } //----------------------------------------------------------------------- @@ -221,7 +222,7 @@ public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return f.isDateField() || f.isTimeField(); + return f.isDateBased() || f.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -230,7 +231,7 @@ public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.range(field) : date.range(field)); + return (f.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); } @@ -239,7 +240,7 @@ public int get(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.get(field) : date.get(field)); + return (f.isTimeBased() ? time.get(field) : date.get(field)); } return range(field).checkValidIntValue(getLong(field), field); } @@ -248,7 +249,7 @@ public long getLong(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.getLong(field) : date.getLong(field)); + return (f.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); } @@ -272,7 +273,7 @@ public ChronoLocalDateTimeImpl with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isTimeField()) { + if (f.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); @@ -376,7 +377,7 @@ } D endDate = end.toLocalDate(); if (end.toLocalTime().isBefore(time)) { - endDate = (D)endDate.minus(1, ChronoUnit.DAYS); + endDate = endDate.minus(1, ChronoUnit.DAYS); } return date.periodUntil(endDate, unit); } @@ -403,7 +404,7 @@ } static ChronoLocalDateTime readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - ChronoLocalDate date = (ChronoLocalDate) in.readObject(); + ChronoLocalDate date = (ChronoLocalDate) in.readObject(); LocalTime time = (LocalTime) in.readObject(); return date.atTime(time); } --- old/src/share/classes/java/time/chrono/ChronoZonedDateTime.java 2013-04-11 23:15:30.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoZonedDateTime.java 2013-04-11 23:15:30.000000000 -0700 @@ -73,7 +73,6 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -81,6 +80,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Comparator; import java.util.Objects; @@ -119,30 +119,59 @@ extends Temporal, Comparable> { /** - * Comparator for two {@code ChronoZonedDateTime} instances ignoring the chronology. + * Gets a comparator that compares {@code ChronoZonedDateTime} in + * time-line order ignoring the chronology. *

    - * This method differs from the comparison in {@link #compareTo} in that it - * only compares the underlying date and not the chronology. + * This comparator differs from the comparison in {@link #compareTo} in that it + * only compares the underlying instant and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. + * on the position of the date-time on the instant time-line. + * The underlying comparison is equivalent to comparing the epoch-second and nano-of-second. * * @see #isAfter * @see #isBefore * @see #isEqual */ - Comparator> INSTANT_COMPARATOR = new Comparator>() { - @Override - public int compare(ChronoZonedDateTime datetime1, ChronoZonedDateTime datetime2) { - int cmp = Long.compare(datetime1.toEpochSecond(), datetime2.toEpochSecond()); - if (cmp == 0) { - cmp = Long.compare(datetime1.toLocalTime().toNanoOfDay(), datetime2.toLocalTime().toNanoOfDay()); - } - return cmp; + static Comparator> timeLineOrder() { + return Chronology.INSTANT_ORDER; + } + + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoZonedDateTime} from a temporal object. + *

    + * This creates a zoned date-time based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoZonedDateTime}. + *

    + * The conversion extracts and combines the chronology, date, time and zone + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#zonedDateTime(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoZonedDateTime::from}. + * + * @param temporal the temporal objec t to convert, not null + * @return the date-time, not null + * @throws DateTimeException if unable to convert to a {@code ChronoZonedDateTime} + * @see Chronology#zonedDateTime(TemporalAccessor) + */ + static ChronoZonedDateTime from(TemporalAccessor temporal) { + if (temporal instanceof ChronoZonedDateTime) { + return (ChronoZonedDateTime) temporal; + } + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass()); } - }; + return chrono.zonedDateTime(temporal); + } + //----------------------------------------------------------------------- @Override - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) { return field.range(); @@ -153,11 +182,13 @@ } @Override - public default int get(TemporalField field) { + default int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return toLocalDateTime().get(field); } @@ -165,7 +196,7 @@ } @Override - public default long getLong(TemporalField field) { + default long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case INSTANT_SECONDS: return toEpochSecond(); @@ -184,7 +215,7 @@ * * @return the date part of this date-time, not null */ - public default D toLocalDate() { + default D toLocalDate() { return toLocalDateTime().toLocalDate(); } @@ -196,7 +227,7 @@ * * @return the time part of this date-time, not null */ - public default LocalTime toLocalTime() { + default LocalTime toLocalTime() { return toLocalDateTime().toLocalTime(); } @@ -306,7 +337,7 @@ ChronoZonedDateTime withZoneSameInstant(ZoneId zone); @Override // Override to provide javadoc - public boolean isSupported(TemporalField field); + boolean isSupported(TemporalField field); //----------------------------------------------------------------------- // override for covariant return type @@ -316,7 +347,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime with(TemporalAdjuster adjuster) { + default ChronoZonedDateTime with(TemporalAdjuster adjuster) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.with(adjuster))); } @@ -334,7 +365,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime plus(TemporalAmount amount) { + default ChronoZonedDateTime plus(TemporalAmount amount) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.plus(amount))); } @@ -352,7 +383,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime minus(TemporalAmount amount) { + default ChronoZonedDateTime minus(TemporalAmount amount) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.minus(amount))); } @@ -362,7 +393,7 @@ * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime minus(long amountToSubtract, TemporalUnit unit) { + default ChronoZonedDateTime minus(long amountToSubtract, TemporalUnit unit) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.minus(amountToSubtract, unit))); } @@ -387,16 +418,16 @@ */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zone() || query == Queries.zoneId()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zone() || query == TemporalQuery.zoneId()) { return (R) getZone(); - } else if (query == Queries.offset()) { + } else if (query == TemporalQuery.offset()) { return (R) getOffset(); - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) toLocalDate().getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -404,6 +435,25 @@ return query.queryFrom(this); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Converts this date-time to an {@code Instant}. @@ -415,7 +465,7 @@ * * @return an {@code Instant} representing the same instant, not null */ - public default Instant toInstant() { + default Instant toInstant() { return Instant.ofEpochSecond(toEpochSecond(), toLocalTime().getNano()); } @@ -430,7 +480,7 @@ * * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ - public default long toEpochSecond() { + default long toEpochSecond() { long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= getOffset().getTotalSeconds(); @@ -454,7 +504,7 @@ * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoZonedDateTime other) { + default int compareTo(ChronoZonedDateTime other) { int cmp = Long.compare(toEpochSecond(), other.toEpochSecond()); if (cmp == 0) { cmp = toLocalTime().getNano() - other.toLocalTime().getNano(); @@ -484,7 +534,7 @@ * @param other the other date-time to compare to, not null * @return true if this point is before the specified date-time */ - public default boolean isBefore(ChronoZonedDateTime other) { + default boolean isBefore(ChronoZonedDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec < otherEpochSec || @@ -504,7 +554,7 @@ * @param other the other date-time to compare to, not null * @return true if this is after the specified date-time */ - public default boolean isAfter(ChronoZonedDateTime other) { + default boolean isAfter(ChronoZonedDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec > otherEpochSec || @@ -524,7 +574,7 @@ * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ - public default boolean isEqual(ChronoZonedDateTime other) { + default boolean isEqual(ChronoZonedDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); } @@ -555,28 +605,11 @@ /** * Outputs this date-time as a {@code String}. *

    - * The output will include the full zoned date-time and the chronology ID. + * The output will include the full zoned date-time. * * @return a string representation of this date-time, not null */ @Override String toString(); - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - } --- old/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java 2013-04-11 23:15:31.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java 2013-04-11 23:15:31.000000000 -0700 @@ -167,6 +167,7 @@ * @param zone the zone identifier, not null * @return the zoned date-time, not null */ + @SuppressWarnings("rawtypes") static ChronoZonedDateTimeImpl ofInstant(Chronology chrono, Instant instant, ZoneId zone) { ZoneRules rules = zone.getRules(); ZoneOffset offset = rules.getOffset(instant); --- old/src/share/classes/java/time/chrono/Chronology.java 2013-04-11 23:15:32.000000000 -0700 +++ new/src/share/classes/java/time/chrono/Chronology.java 2013-04-11 23:15:32.000000000 -0700 @@ -61,38 +61,57 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.TemporalAdjuster.nextOrSame; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectStreamException; +import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; +import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import sun.util.logging.PlatformLogger; + /** * A calendar system, used to organize and identify dates. *

    @@ -106,7 +125,7 @@ * for use by any {@code Chronology} implementation: *

      *   LocalDate isoDate = ...
    - *   ChronoLocalDate<ThaiBuddhistChronology> thaiDate = ...
    + *   ThaiBuddhistDate thaiDate = ...
      *   int isoYear = isoDate.get(ChronoField.YEAR);
      *   int thaiYear = thaiDate.get(ChronoField.YEAR);
      * 
    @@ -154,8 +173,8 @@ *

    * Each chronology must define a chronology ID that is unique within the system. * If the chronology represents a calendar system defined by the - * Unicode Locale Data Markup Language (LDML) specification then that - * calendar type should also be specified. + * CLDR specification then the calendar type is the concatenation of the + * CLDR type and, if applicable, the CLDR variant, * *

    Specification for implementors

    * This class must be implemented with care to ensure other classes operate correctly. @@ -167,6 +186,36 @@ public abstract class Chronology implements Comparable { /** + * ChronoLocalDate order constant. + */ + static final Comparator> DATE_ORDER = + (Comparator> & Serializable) (date1, date2) -> { + return Long.compare(date1.toEpochDay(), date2.toEpochDay()); + }; + /** + * ChronoLocalDateTime order constant. + */ + static final Comparator> DATE_TIME_ORDER = + (Comparator> & Serializable) (dateTime1, dateTime2) -> { + int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay()); + if (cmp == 0) { + cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay()); + } + return cmp; + }; + /** + * ChronoZonedDateTime order constant. + */ + static final Comparator> INSTANT_ORDER = + (Comparator> & Serializable) (dateTime1, dateTime2) -> { + int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond()); + if (cmp == 0) { + cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano()); + } + return cmp; + }; + + /** * Map of available calendars by ID. */ private static final ConcurrentHashMap CHRONOS_BY_ID = new ConcurrentHashMap<>(); @@ -176,19 +225,35 @@ private static final ConcurrentHashMap CHRONOS_BY_TYPE = new ConcurrentHashMap<>(); /** + * Register a Chronology by its ID and type for lookup by {@link #of(java.lang.String)}. + * Chronologies must not be registered until they are completely constructed. + * Specifically, not in the constructor of Chronology. + * + * @param chrono the chronology to register; not null + * @return the already registered Chronology if any, may be null + */ + static Chronology registerChrono(Chronology chrono) { + return registerChrono(chrono, chrono.getId()); + } + + /** * Register a Chronology by ID and type for lookup by {@link #of(java.lang.String)}. * Chronos must not be registered until they are completely constructed. * Specifically, not in the constructor of Chronology. + * * @param chrono the chronology to register; not null + * @param id the ID to register the chronology; not null + * @return the already registered Chronology if any, may be null */ - private static void registerChrono(Chronology chrono) { - Chronology prev = CHRONOS_BY_ID.putIfAbsent(chrono.getId(), chrono); + static Chronology registerChrono(Chronology chrono, String id) { + Chronology prev = CHRONOS_BY_ID.putIfAbsent(id, chrono); if (prev == null) { String type = chrono.getCalendarType(); if (type != null) { CHRONOS_BY_TYPE.putIfAbsent(type, chrono); } } + return prev; } /** @@ -209,18 +274,25 @@ private static boolean initCache() { if (CHRONOS_BY_ID.get("ISO") == null) { // Initialization is incomplete - @SuppressWarnings("rawtypes") - ServiceLoader loader = ServiceLoader.load(Chronology.class, null); - for (Chronology chrono : loader) { - registerChrono(chrono); - } - // Register these calendars; the ServiceLoader configuration is not used + // Register built-in Chronologies registerChrono(HijrahChronology.INSTANCE); registerChrono(JapaneseChronology.INSTANCE); registerChrono(MinguoChronology.INSTANCE); registerChrono(ThaiBuddhistChronology.INSTANCE); + // Register Chronologies from the ServiceLoader + @SuppressWarnings("rawtypes") + ServiceLoader loader = ServiceLoader.load(Chronology.class, null); + for (Chronology chrono : loader) { + String id = chrono.getId(); + if (id.equals("ISO") || registerChrono(chrono) != null) { + // Log the attempt to replace an existing Chronology + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.warning("Ignoring duplicate Chronology, from ServiceLoader configuration " + id); + } + } + // finally, register IsoChronology to mark initialization is complete registerChrono(IsoChronology.INSTANCE); return true; @@ -236,7 +308,7 @@ * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code Chronology}. *

    - * The conversion will obtain the chronology using {@link Queries#chronology()}. + * The conversion will obtain the chronology using {@link TemporalQuery#chronology()}. * If the specified temporal object does not have a chronology, {@link IsoChronology} is returned. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -248,7 +320,7 @@ */ public static Chronology from(TemporalAccessor temporal) { Objects.requireNonNull(temporal, "temporal"); - Chronology obj = temporal.query(Queries.chronology()); + Chronology obj = temporal.query(TemporalQuery.chronology()); return (obj != null ? obj : IsoChronology.INSTANCE); } @@ -266,13 +338,16 @@ *

    * The {@code Locale} class also supports an extension mechanism that * can be used to identify a calendar system. The mechanism is a form - * of key-value pairs, where the calendar system has the key "ca". + * of key-value pairs, where the calendar system has the key "ca" + * and an optional variant key "cv". * For example, the locale "en-JP-u-ca-japanese" represents the English * language as used in Japan with the Japanese calendar system. *

    * This method finds the desired calendar system by in a manner equivalent * to passing "ca" to {@link Locale#getUnicodeLocaleType(String)}. * If the "ca" key is not present, then {@code IsoChronology} is returned. + * The variant, if present, is appended to the "ca" value separated by "-" + * and the concatenated value is used to find the calendar system by type. *

    * Note that the behavior of this method differs from the older * {@link java.util.Calendar#getInstance(Locale)} method. @@ -299,6 +374,10 @@ if (type == null || "iso".equals(type) || "iso8601".equals(type)) { return IsoChronology.INSTANCE; } + String variant = locale.getUnicodeLocaleType("cv"); + if (variant != null && !variant.isEmpty()) { + type = type + '-' + variant; + } // Not pre-defined; lookup by the type do { Chronology chrono = CHRONOS_BY_TYPE.get(type); @@ -307,6 +386,16 @@ } // If not found, do the initialization (once) and repeat the lookup } while (initCache()); + + // Look for a Chronology using ServiceLoader of the Thread's ContextClassLoader + // Application provided Chronologies must not be cached + @SuppressWarnings("rawtypes") + ServiceLoader loader = ServiceLoader.load(Chronology.class); + for (Chronology chrono : loader) { + if (type.equals(chrono.getCalendarType())) { + return chrono; + } + } throw new DateTimeException("Unknown calendar system: " + type); } @@ -317,7 +406,8 @@ *

    * This returns a chronology based on either the ID or the type. * The {@link #getId() chronology ID} uniquely identifies the chronology. - * The {@link #getCalendarType() calendar system type} is defined by the LDML specification. + * The {@link #getCalendarType() calendar system type} is defined by the + * CLDR specification. *

    * The chronology may be a system chronology or a chronology * provided by the application via ServiceLoader configuration. @@ -379,7 +469,7 @@ */ public static Set getAvailableChronologies() { initCache(); // force initialization - HashSet chronos = new HashSet(CHRONOS_BY_ID.values()); + HashSet chronos = new HashSet<>(CHRONOS_BY_ID.values()); /// Add in Chronologies from the ServiceLoader configuration @SuppressWarnings("rawtypes") @@ -406,9 +496,9 @@ * @throws ClassCastException if the date-time cannot be cast to ChronoLocalDate * or the chronology is not equal this Chronology */ - ChronoLocalDate ensureChronoLocalDate(Temporal temporal) { + ChronoLocalDate ensureChronoLocalDate(Temporal temporal) { @SuppressWarnings("unchecked") - ChronoLocalDate other = (ChronoLocalDate) temporal; + ChronoLocalDate other = (ChronoLocalDate) temporal; if (this.equals(other.getChronology()) == false) { throw new ClassCastException("Chronology mismatch, expected: " + getId() + ", actual: " + other.getChronology().getId()); } @@ -464,15 +554,16 @@ public abstract String getId(); /** - * Gets the calendar type of the underlying calendar system. + * Gets the calendar type of the calendar system. *

    - * The calendar type is an identifier defined by the - * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. - * It can also be used as part of a locale, accessible via - * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. + * The calendar type is an identifier defined by the CLDR and + * Unicode Locale Data Markup Language (LDML) specifications + * to uniquely identification a calendar. + * The {@code getCalendarType} is the concatenation of the CLDR calendar type + * and the variant, if applicable, is appended separated by "-". + * The calendar type is used to lookup the {@code Chronology} using {@link #of(String)}. * - * @return the calendar system type, null if the calendar is not defined by LDML + * @return the calendar system type, null if the calendar is not defined * @see #getId() */ public abstract String getCalendarType(); @@ -488,8 +579,9 @@ * @param dayOfMonth the chronology day-of-month * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ - public ChronoLocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + public ChronoLocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } @@ -503,7 +595,7 @@ * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date */ - public abstract ChronoLocalDate date(int prolepticYear, int month, int dayOfMonth); + public abstract ChronoLocalDate date(int prolepticYear, int month, int dayOfMonth); /** * Obtains a local date in this chronology from the era, year-of-era and @@ -514,8 +606,9 @@ * @param dayOfYear the chronology day-of-year * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ - public ChronoLocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + public ChronoLocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } @@ -528,7 +621,19 @@ * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date */ - public abstract ChronoLocalDate dateYearDay(int prolepticYear, int dayOfYear); + public abstract ChronoLocalDate dateYearDay(int prolepticYear, int dayOfYear); + + /** + * Obtains a local date in this chronology from the epoch-day. + *

    + * The definition of {@link ChronoField#EPOCH_DAY EPOCH_DAY} is the same + * for all calendar systems, thus it can be used for conversion. + * + * @param epochDay the epoch day + * @return the local date in this chronology, not null + * @throws DateTimeException if unable to create the date + */ + public abstract ChronoLocalDate dateEpochDay(long epochDay); //----------------------------------------------------------------------- /** @@ -545,7 +650,7 @@ * @return the current local date using the system clock and default time-zone, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow() { + public ChronoLocalDate dateNow() { return dateNow(Clock.systemDefaultZone()); } @@ -562,7 +667,7 @@ * @return the current local date using the system clock, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow(ZoneId zone) { + public ChronoLocalDate dateNow(ZoneId zone) { return dateNow(Clock.system(zone)); } @@ -577,7 +682,7 @@ * @return the current local date, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow(Clock clock) { + public ChronoLocalDate dateNow(Clock clock) { Objects.requireNonNull(clock, "clock"); return date(LocalDate.now(clock)); } @@ -586,7 +691,7 @@ /** * Obtains a local date in this chronology from another temporal object. *

    - * This creates a date in this chronology based on the specified temporal. + * This obtains a date in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoLocalDate}. *

    @@ -599,13 +704,14 @@ * @param temporal the temporal object to convert, not null * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @see ChronoLocalDate#from(TemporalAccessor) */ - public abstract ChronoLocalDate date(TemporalAccessor temporal); + public abstract ChronoLocalDate date(TemporalAccessor temporal); /** * Obtains a local date-time in this chronology from another temporal object. *

    - * This creates a date-time in this chronology based on the specified temporal. + * This obtains a date-time in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoLocalDateTime}. *

    @@ -621,6 +727,7 @@ * @param temporal the temporal object to convert, not null * @return the local date-time in this chronology, not null * @throws DateTimeException if unable to create the date-time + * @see ChronoLocalDateTime#from(TemporalAccessor) */ public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { try { @@ -633,7 +740,7 @@ /** * Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object. *

    - * This creates a zoned date-time in this chronology based on the specified temporal. + * This obtains a zoned date-time in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoZonedDateTime}. *

    @@ -652,6 +759,7 @@ * @param temporal the temporal object to convert, not null * @return the zoned date-time in this chronology, not null * @throws DateTimeException if unable to create the date-time + * @see ChronoZonedDateTime#from(TemporalAccessor) */ public ChronoZonedDateTime zonedDateTime(TemporalAccessor temporal) { try { @@ -661,6 +769,7 @@ return zonedDateTime(instant, zone); } catch (DateTimeException ex1) { + @SuppressWarnings("rawtypes") ChronoLocalDateTimeImpl cldt = ensureChronoLocalDateTime(localDateTime(temporal)); return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null); } @@ -672,7 +781,7 @@ /** * Obtains a {@code ChronoZonedDateTime} in this chronology from an {@code Instant}. *

    - * This creates a zoned date-time with the same instant as that specified. + * This obtains a zoned date-time with the same instant as that specified. * * @param instant the instant to create the date-time from, not null * @param zone the time-zone, not null @@ -703,11 +812,17 @@ * Calculates the proleptic-year given the era and year-of-era. *

    * This combines the era and year-of-era into the single proleptic-year field. + *

    + * If the chronology makes active use of eras, such as {@code JapaneseChronology} + * then the year-of-era will be validated against the era. + * For other chronologies, validation is optional. * * @param era the era of the correct type for the chronology, not null * @param yearOfEra the chronology year-of-era * @return the proleptic-year - * @throws DateTimeException if unable to convert + * @throws DateTimeException if unable to convert to a proleptic-year, + * such as if the year is invalid for the era + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ public abstract int prolepticYear(Era era, int yearOfEra); @@ -775,24 +890,175 @@ * @return the text value of the chronology, not null */ public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder().appendChronologyText(style).toFormatter(locale).format(new TemporalAccessor() { + return new DateTimeFormatterBuilder().appendChronologyText(style).toFormatter(locale).format(toTemporal()); + } + + /** + * Converts this chronology to a {@code TemporalAccessor}. + *

    + * A {@code Chronology} can be fully represented as a {@code TemporalAccessor}. + * However, the interface is not implemented by this class as most of the + * methods on the interface have no meaning to {@code Chronology}. + *

    + * The returned temporal has no supported fields, with the query method + * supporting the return of the chronology using {@link TemporalQuery#chronology()}. + * + * @return a temporal equivalent to this chronology, not null + */ + private TemporalAccessor toTemporal() { + return new TemporalAccessor() { @Override public boolean isSupported(TemporalField field) { return false; } @Override public long getLong(TemporalField field) { - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) Chronology.this; } return TemporalAccessor.super.query(query); } - }); + }; + } + + //----------------------------------------------------------------------- + /** + * Resolves parsed {@code ChronoField} values into a date during parsing. + *

    + * Most {@code TemporalField} implementations are resolved using the + * resolve method on the field. By contrast, the {@code ChronoField} class + * defines fields that only have meaning relative to the chronology. + * As such, {@code ChronoField} date fields are resolved here in the + * context of a specific chronology. + *

    + * The default implementation is suitable for most calendar systems. + * If {@link ChronoField#YEAR_OF_ERA} is found without an {@link ChronoField#ERA} + * then the last era in {@link #eras()} is used. + * The implementation assumes a 7 day week, that the first day-of-month + * has the value 1, and that first day-of-year has the value 1. + * + * @param fieldValues the map of fields to values, which can be updated, not null + * @param resolverStyle the requested type of resolve, not null + * @return the resolved date, null if insufficient information to create a date + * @throws DateTimeException if the date cannot be resolved, typically + * because of a conflict in the input data + */ + public ChronoLocalDate resolveDate(Map fieldValues, ResolverStyle resolverStyle) { + // check epoch-day before inventing era + if (fieldValues.containsKey(EPOCH_DAY)) { + return dateEpochDay(fieldValues.remove(EPOCH_DAY)); + } + + // fix proleptic month before inventing era + Long pMonth = fieldValues.remove(PROLEPTIC_MONTH); + if (pMonth != null) { + // first day-of-month is likely to be safest for setting proleptic-month + // cannot add to year zero, as not all chronologies have a year zero + ChronoLocalDate chronoDate = dateNow() + .with(DAY_OF_MONTH, 1).with(PROLEPTIC_MONTH, pMonth); + addFieldValue(fieldValues, MONTH_OF_YEAR, chronoDate.get(MONTH_OF_YEAR)); + addFieldValue(fieldValues, YEAR, chronoDate.get(YEAR)); + } + + // invent era if necessary to resolve year-of-era + Long yoeLong = fieldValues.remove(YEAR_OF_ERA); + if (yoeLong != null) { + Long eraLong = fieldValues.remove(ERA); + int yoe = range(YEAR_OF_ERA).checkValidIntValue(yoeLong, YEAR_OF_ERA); + if (eraLong != null) { + Era eraObj = eraOf(Math.toIntExact(eraLong)); + addFieldValue(fieldValues, YEAR, prolepticYear(eraObj, yoe)); + } else if (fieldValues.containsKey(YEAR)) { + int year = range(YEAR).checkValidIntValue(fieldValues.get(YEAR), YEAR); + ChronoLocalDate chronoDate = dateYearDay(year, 1); + addFieldValue(fieldValues, YEAR, prolepticYear(chronoDate.getEra(), yoe)); + } else { + List eras = eras(); + if (eras.isEmpty()) { + addFieldValue(fieldValues, YEAR, yoe); + } else { + Era eraObj = eras.get(eras.size() - 1); + addFieldValue(fieldValues, YEAR, prolepticYear(eraObj, yoe)); + } + } + } + + // build date + if (fieldValues.containsKey(YEAR)) { + if (fieldValues.containsKey(MONTH_OF_YEAR)) { + if (fieldValues.containsKey(DAY_OF_MONTH)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int dom = range(DAY_OF_MONTH).checkValidIntValue(fieldValues.remove(DAY_OF_MONTH), DAY_OF_MONTH); + return date(y, moy, dom); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_MONTH)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int aw = range(ALIGNED_WEEK_OF_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), ALIGNED_WEEK_OF_MONTH); + int ad = range(ALIGNED_DAY_OF_WEEK_IN_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), ALIGNED_DAY_OF_WEEK_IN_MONTH); + ChronoLocalDate chronoDate = date(y, moy, 1); + return chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int aw = range(ALIGNED_WEEK_OF_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), ALIGNED_WEEK_OF_MONTH); + int dow = range(DAY_OF_WEEK).checkValidIntValue(fieldValues.remove(DAY_OF_WEEK), DAY_OF_WEEK); + ChronoLocalDate chronoDate = date(y, moy, 1); + return chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); + } + } + } + if (fieldValues.containsKey(DAY_OF_YEAR)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR); + return dateYearDay(y, doy); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_YEAR)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR); + int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR); + ChronoLocalDate chronoDate = dateYearDay(y, 1); + return chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR); + int dow = range(DAY_OF_WEEK).checkValidIntValue(fieldValues.remove(DAY_OF_WEEK), DAY_OF_WEEK); + ChronoLocalDate chronoDate = dateYearDay(y, 1); + return chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); + } + } + } + return null; + } + + /** + * Adds a field-value pair to the map, checking for conflicts. + *

    + * If the field is not already present, then the field-value pair is added to the map. + * If the field is already present and it has the same value as that specified, no action occurs. + * If the field is already present and it has a different value to that specified, then + * an exception is thrown. + * + * @param field the field to add, not null + * @param value the value to add, not null + * @throws DateTimeException if the field is already present with a different value + */ + void addFieldValue(Map fieldValues, ChronoField field, long value) { + Long old = fieldValues.get(field); // check first for better error message + if (old != null && old.longValue() != value) { + throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value); + } + fieldValues.put(field, value); } //----------------------------------------------------------------------- @@ -861,16 +1127,16 @@ //----------------------------------------------------------------------- /** - * Writes the object using a - * dedicated serialized form. + * Writes the Chronology using a + * dedicated serialized form. *

    -     *  out.writeByte(7);  // identifies this as a Chronology
    -     * out.writeUTF(chronoId);
    +     *  out.writeByte(1);  // identifies this as a Chronology
    +     *  out.writeUTF(getId());
          * 
    * * @return the instance of {@code Ser}, not null */ - private Object writeReplace() { + protected Object writeReplace() { return new Ser(Ser.CHRONO_TYPE, this); } --- old/src/share/classes/java/time/chrono/Era.java 2013-04-11 23:15:33.000000000 -0700 +++ new/src/share/classes/java/time/chrono/Era.java 2013-04-11 23:15:32.000000000 -0700 @@ -65,10 +65,10 @@ import static java.time.temporal.ChronoUnit.ERAS; import java.time.DateTimeException; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -120,55 +120,6 @@ */ int getValue(); - /** - * Gets the chronology of this era. - *

    - * The {@code Chronology} represents the calendar system in use. - * This always returns the standard form of the chronology. - * - * @return the chronology, not null - */ - Chronology getChronology(); - - //----------------------------------------------------------------------- - /** - * Obtains a date in this era given the year-of-era, month, and day. - *

    - * This era is combined with the given date fields to form a date. - * The year specified must be the year-of-era. - * Methods to create a date from the proleptic-year are on {@code Chronology}. - * This always uses the standard form of the chronology. - *

    - * This default implementation invokes the factory method on {@link Chronology}. - * - * @param yearOfEra the calendar system year-of-era - * @param month the calendar system month-of-year - * @param day the calendar system day-of-month - * @return a local date based on this era and the specified year-of-era, month and day - */ - public default ChronoLocalDate date(int yearOfEra, int month, int day) { - return getChronology().date(this, yearOfEra, month, day); - } - - - /** - * Obtains a date in this era given year-of-era and day-of-year fields. - *

    - * This era is combined with the given date fields to form a date. - * The year specified must be the year-of-era. - * Methods to create a date from the proleptic-year are on {@code Chronology}. - * This always uses the standard form of the chronology. - *

    - * This default implementation invokes the factory method on {@link Chronology}. - * - * @param yearOfEra the calendar system year-of-era - * @param dayOfYear the calendar system day-of-year - * @return a local date based on this era and the specified year-of-era and day-of-year - */ - public default ChronoLocalDate dateYearDay(int yearOfEra, int dayOfYear) { - return getChronology().dateYearDay(this, yearOfEra, dayOfYear); - } - //----------------------------------------------------------------------- /** * Checks if the specified field is supported. @@ -190,7 +141,7 @@ * @return true if the field is supported on this era, false if not */ @Override - public default boolean isSupported(TemporalField field) { + default boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == ERA; } @@ -207,19 +158,23 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the range. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} * passing {@code this} as the argument. * Whether the range can be obtained is determined by the field. + *

    + * The default implementation must return a range for {@code ERA} from + * zero to one, suitable for two era calendar systems such as ISO. * * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override // override for Javadoc - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { return TemporalAccessor.super.range(field); } @@ -233,7 +188,7 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the value of the era. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -242,15 +197,18 @@ * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance - public default int get(TemporalField field) { + default int get(TemporalField field) { if (field == ERA) { return getValue(); } - return range(field).checkValidIntValue(getLong(field), field); + return TemporalAccessor.super.get(field); } /** @@ -262,7 +220,7 @@ *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the value of the era. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -272,14 +230,15 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override - public default long getLong(TemporalField field) { + default long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -305,10 +264,8 @@ */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) getChronology(); - } else if (query == Queries.precision()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.precision()) { return (R) ERAS; } return TemporalAccessor.super.query(query); @@ -339,7 +296,7 @@ * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal.with(ERA, getValue()); } @@ -359,7 +316,7 @@ * @param locale the locale to use, not null * @return the text value of the era, not null */ - public default String getDisplayName(TextStyle style, Locale locale) { + default String getDisplayName(TextStyle style, Locale locale) { return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this); } --- old/src/share/classes/java/time/chrono/HijrahChronology.java 2013-04-11 23:15:33.000000000 -0700 +++ new/src/share/classes/java/time/chrono/HijrahChronology.java 2013-04-11 23:15:33.000000000 -0700 @@ -59,9 +59,13 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; -import java.text.ParseException; +import java.security.AccessController; +import java.security.PrivilegedActionException; import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; @@ -73,106 +77,135 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; + +import sun.util.logging.PlatformLogger; /** - * The Hijrah calendar system. + * The Hijrah calendar is a lunar calendar supporting Islamic calendars. *

    - * This chronology defines the rules of the Hijrah calendar system. + * The HijrahChronology follows the rules of the Hijrah calendar system. The Hijrah + * calendar has several variants based on differences in when the new moon is + * determined to have occurred and where the observation is made. + * In some variants the length of each month is + * computed algorithmically from the astronomical data for the moon and earth and + * in others the length of the month is determined by an authorized sighting + * of the new moon. For the algorithmically based calendars the calendar + * can project into the future. + * For sighting based calendars only historical data from past + * sightings is available. *

    - * The implementation follows the Freeman-Grenville algorithm (*1) and has following features. - *

      - *
    • A year has 12 months.
    • - *
    • Over a cycle of 30 years there are 11 leap years.
    • - *
    • There are 30 days in month number 1, 3, 5, 7, 9, and 11, - * and 29 days in month number 2, 4, 6, 8, 10, and 12.
    • - *
    • In a leap year month 12 has 30 days.
    • - *
    • In a 30 year cycle, year 2, 5, 7, 10, 13, 16, 18, 21, 24, - * 26, and 29 are leap years.
    • - *
    • Total of 10631 days in a 30 years cycle.
    • - *

    - *

    - * The table shows the features described above. - *

    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    Hijrah Calendar Months
    # of monthName of monthNumber of days
    1Muharram30
    2Safar29
    3Rabi'al-Awwal30
    4Rabi'ath-Thani29
    5Jumada l-Ula30
    6Jumada t-Tania29
    7Rajab30
    8Sha`ban29
    9Ramadan30
    10Shawwal29
    11Dhu 'l-Qa`da30
    12Dhu 'l-Hijja29, but 30 days in years 2, 5, 7, 10,
    - * 13, 16, 18, 21, 24, 26, and 29
    - *
    + * The length of each month is 29 or 30 days. + * Ordinary years have 354 days; leap years have 355 days. + * *

    - * (*1) The algorithm is taken from the book, - * The Muslim and Christian Calendars by G.S.P. Freeman-Grenville. + * CLDR and LDML identify variants: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Chronology IDCalendar TypeLocale extension, see {@link java.util.Locale}Description
    Hijrah-umalquraislamic-umalquraca-islamic-cv-umalquraIslamic - Umm Al-Qura calendar of Saudi Arabia
    + *

    Additional variants may be available through {@link Chronology#getAvailableChronologies()}. + * + *

    Example

    *

    + * Selecting the chronology from the locale uses {@link Chronology#ofLocale} + * to find the Chronology based on Locale supported BCP 47 extension mechanism + * to request a specific calendar ("ca") and variant ("cv"). For example, + *

    + *
    + *      Locale locale = Locale.forLanguageTag("en-US-u-ca-islamic-cv-umalqura");
    + *      Chronology chrono = Chronology.ofLocale(locale);
    + * 
    * *

    Specification for implementors

    * This class is immutable and thread-safe. + *

    Implementation Note for Hijrah Calendar Variant Configuration

    + * Each Hijrah variant is configured individually. Each variant is defined by a + * property resource that defines the {@code ID}, the {@code calendar type}, + * the start of the calendar, the alignment with the + * ISO calendar, and the length of each month for a range of years. + * The variants are identified in the {@code calendars.properties} file. + * The new properties are prefixed with {@code "calendars.hijrah."}: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Property NameProperty valueDescription
    calendars.hijrah.{ID}The property resource defining the {@code {ID}} variantThe property resource is located with the {@code calendars.properties} file
    calendars.hijrah.{ID}.typeThe calendar typeLDML defines the calendar type names
    + *

    + * The Hijrah property resource is a set of properties that describe the calendar. + * The syntax is defined by {@code java.util.Properties#load(Reader)}. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Property Name Property value Description
    idChronology Id, for example, "Hijrah-umalqura"The Id of the calendar in common usage
    typeCalendar type, for example, "islamic-umalqura"LDML defines the calendar types
    versionVersion, for example: "1.8.0_1"The version of the Hijrah variant data
    iso-startISO start date, formatted as {@code yyyy-MM-dd}, for example: "1900-04-30"The ISO date of the first day of the minimum Hijrah year.
    yyyy - a numeric 4 digit year, for example "1434"The value is a sequence of 12 month lengths, + * for example: "29 30 29 30 29 30 30 30 29 30 29 29"The lengths of the 12 months of the year separated by whitespace. + * A numeric year property must be present for every year without any gaps. + * The month lengths must be between 29-32 inclusive. + *
    * * @since 1.8 */ @@ -182,336 +215,161 @@ * The Hijrah Calendar id. */ private final String typeId; - /** * The Hijrah calendarType. */ - private final String calendarType; - - /** - * The singleton instance for the era before the current one - Before Hijrah - - * which has the value 0. - */ - public static final Era ERA_BEFORE_AH = HijrahEra.BEFORE_AH; - /** - * The singleton instance for the current era - Hijrah - which has the value 1. - */ - public static final Era ERA_AH = HijrahEra.AH; + private transient final String calendarType; /** * Serialization version. */ private static final long serialVersionUID = 3127340209035924785L; /** - * The minimum valid year-of-era. - */ - public static final int MIN_YEAR_OF_ERA = 1; - /** - * The maximum valid year-of-era. - * This is currently set to 9999 but may be changed to increase the valid range - * in a future version of the specification. - */ - public static final int MAX_YEAR_OF_ERA = 9999; - - /** - * Number of Gregorian day of July 19, year 622 (Gregorian), which is epoch day - * of Hijrah calendar. - */ - private static final int HIJRAH_JAN_1_1_GREGORIAN_DAY = -492148; - /** - * 0-based, for number of day-of-year in the beginning of month in normal - * year. - */ - private static final int NUM_DAYS[] = - {0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325}; - /** - * 0-based, for number of day-of-year in the beginning of month in leap year. - */ - private static final int LEAP_NUM_DAYS[] = - {0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325}; - /** - * 0-based, for day-of-month in normal year. - */ - private static final int MONTH_LENGTH[] = - {30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29}; - /** - * 0-based, for day-of-month in leap year. - */ - private static final int LEAP_MONTH_LENGTH[] = - {30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30}; - - /** - *

    -     *                            Greatest       Least
    -     * Field name        Minimum   Minimum     Maximum     Maximum
    -     * ----------        -------   -------     -------     -------
    -     * ERA                     0         0           1           1
    -     * YEAR_OF_ERA             1         1        9999        9999
    -     * MONTH_OF_YEAR           1         1          12          12
    -     * DAY_OF_MONTH            1         1          29          30
    -     * DAY_OF_YEAR             1         1         354         355
    -     * 
    - * - * Minimum values. - */ - private static final int MIN_VALUES[] = - { - 0, - MIN_YEAR_OF_ERA, - 0, - 1, - 0, - 1, - 1 - }; - - /** - * Least maximum values. - */ - private static final int LEAST_MAX_VALUES[] = - { - 1, - MAX_YEAR_OF_ERA, - 11, - 51, - 5, - 29, - 354 - }; - - /** - * Maximum values. - */ - private static final int MAX_VALUES[] = - { - 1, - MAX_YEAR_OF_ERA, - 11, - 52, - 6, - 30, - 355 - }; - - /** - * Position of day-of-month. This value is used to get the min/max value - * from an array. - */ - private static final int POSITION_DAY_OF_MONTH = 5; - /** - * Position of day-of-year. This value is used to get the min/max value from - * an array. - */ - private static final int POSITION_DAY_OF_YEAR = 6; - /** - * Zero-based start date of cycle year. - */ - private static final int CYCLEYEAR_START_DATE[] = - { - 0, - 354, - 709, - 1063, - 1417, - 1772, - 2126, - 2481, - 2835, - 3189, - 3544, - 3898, - 4252, - 4607, - 4961, - 5315, - 5670, - 6024, - 6379, - 6733, - 7087, - 7442, - 7796, - 8150, - 8505, - 8859, - 9214, - 9568, - 9922, - 10277 - }; - - /** - * Holding the adjusted month days in year. The key is a year (Integer) and - * the value is the all the month days in year (int[]). - */ - private final HashMap ADJUSTED_MONTH_DAYS = new HashMap<>(); - /** - * Holding the adjusted month length in year. The key is a year (Integer) - * and the value is the all the month length in year (int[]). + * Singleton instance of the Islamic Umm Al-Qura calendar of Saudi Arabia. + * Other Hijrah chronology variants may be available from + * {@link Chronology#getAvailableChronologies}. */ - private final HashMap ADJUSTED_MONTH_LENGTHS = new HashMap<>(); - /** - * Holding the adjusted days in the 30 year cycle. The key is a cycle number - * (Integer) and the value is the all the starting days of the year in the - * cycle (int[]). - */ - private final HashMap ADJUSTED_CYCLE_YEARS = new HashMap<>(); - /** - * Holding the adjusted cycle in the 1 - 30000 year. The key is the cycle - * number (Integer) and the value is the starting days in the cycle in the - * term. - */ - private final long[] ADJUSTED_CYCLES; + public static final HijrahChronology INSTANCE; /** - * Holding the adjusted min values. + * Array of epoch days indexed by Hijrah Epoch month. + * Computed by {@link #loadCalendarData}. */ - private final int[] ADJUSTED_MIN_VALUES; + private transient int[] hijrahEpochMonthStartDays; /** - * Holding the adjusted max least max values. + * The minimum epoch day of this Hijrah calendar. + * Computed by {@link #loadCalendarData}. */ - private final int[] ADJUSTED_LEAST_MAX_VALUES; + private transient int minEpochDay; /** - * Holding adjusted max values. + * The maximum epoch day for which calendar data is available. + * Computed by {@link #loadCalendarData}. */ - private final int[] ADJUSTED_MAX_VALUES; + private transient int maxEpochDay; /** - * Holding the non-adjusted month days in year for non leap year. + * The minimum epoch month. + * Computed by {@link #loadCalendarData}. */ - private static final int[] DEFAULT_MONTH_DAYS; + private transient int hijrahStartEpochMonth; /** - * Holding the non-adjusted month days in year for leap year. + * The minimum length of a month. + * Computed by {@link #createEpochMonths}. */ - private static final int[] DEFAULT_LEAP_MONTH_DAYS; + private transient int minMonthLength; /** - * Holding the non-adjusted month length for non leap year. + * The maximum length of a month. + * Computed by {@link #createEpochMonths}. */ - private static final int[] DEFAULT_MONTH_LENGTHS; + private transient int maxMonthLength; /** - * Holding the non-adjusted month length for leap year. + * The minimum length of a year in days. + * Computed by {@link #createEpochMonths}. */ - private static final int[] DEFAULT_LEAP_MONTH_LENGTHS; + private transient int minYearLength; /** - * Holding the non-adjusted 30 year cycle starting day. + * The maximum length of a year in days. + * Computed by {@link #createEpochMonths}. */ - private static final int[] DEFAULT_CYCLE_YEARS; + private transient int maxYearLength; /** - * number of 30-year cycles to hold the deviation data. + * A reference to the properties stored in + * ${java.home}/lib/calendars.properties */ - private static final int MAX_ADJUSTED_CYCLE = 334; // to support year 9999 + private transient final static Properties calendarProperties; - - /** - * Narrow names for eras. - */ - private static final HashMap ERA_NARROW_NAMES = new HashMap<>(); - /** - * Short names for eras. - */ - private static final HashMap ERA_SHORT_NAMES = new HashMap<>(); /** - * Full names for eras. + * Prefix of property names for Hijrah calendar variants. */ - private static final HashMap ERA_FULL_NAMES = new HashMap<>(); + private static final String PROP_PREFIX = "calendar.hijrah."; /** - * Fallback language for the era names. + * Suffix of property names containing the calendar type of a variant. */ - private static final String FALLBACK_LANGUAGE = "en"; - - /** - * Singleton instance of the Hijrah chronology. - * Must be initialized after the rest of the static initialization. - */ - public static final HijrahChronology INSTANCE; + private static final String PROP_TYPE_SUFFIX = ".type"; /** * Name data. */ static { - ERA_NARROW_NAMES.put(FALLBACK_LANGUAGE, new String[]{"BH", "HE"}); - ERA_SHORT_NAMES.put(FALLBACK_LANGUAGE, new String[]{"B.H.", "H.E."}); - ERA_FULL_NAMES.put(FALLBACK_LANGUAGE, new String[]{"Before Hijrah", "Hijrah Era"}); - - DEFAULT_MONTH_DAYS = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); - - DEFAULT_LEAP_MONTH_DAYS = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); - - DEFAULT_MONTH_LENGTHS = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - - DEFAULT_LEAP_MONTH_LENGTHS = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - - DEFAULT_CYCLE_YEARS = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); + try { + calendarProperties = sun.util.calendar.BaseCalendar.getCalendarProperties(); + } catch (IOException ioe) { + throw new InternalError("Can't initialize lib/calendars.properties", ioe); + } - INSTANCE = new HijrahChronology(); + try { + INSTANCE = new HijrahChronology("Hijrah-umalqura"); + // Register it by its aliases + Chronology.registerChrono(INSTANCE, "Hijrah"); + Chronology.registerChrono(INSTANCE, "islamic"); + + } catch (Exception ex) { + // Absence of Hijrah calendar is fatal to initializing this class. + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex); + throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause()); + } + registerVariants(); + } - String extraCalendars = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.time.chrono.HijrahCalendars")); - if (extraCalendars != null) { - try { - // Split on whitespace - String[] splits = extraCalendars.split("\\s"); - for (String cal : splits) { - if (!cal.isEmpty()) { - // Split on the delimiter between typeId "-" calendarType - String[] type = cal.split("-"); - Chronology cal2 = new HijrahChronology(type[0], type.length > 1 ? type[1] : type[0]); - } + /** + * For each Hijrah variant listed, create the HijrahChronology and register it. + * Exceptions during initialization are logged but otherwise ignored. + */ + private static void registerVariants() { + for (String name : calendarProperties.stringPropertyNames()) { + if (name.startsWith(PROP_PREFIX)) { + String id = name.substring(PROP_PREFIX.length()); + if (id.indexOf('.') >= 0) { + continue; // no name or not a simple name of a calendar + } + if (id.equals(INSTANCE.getId())) { + continue; // do not duplicate the default + } + try { + // Create and register the variant + HijrahChronology chrono = new HijrahChronology(id); + Chronology.registerChrono(chrono); + } catch (Exception ex) { + // Log error and continue + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.severe("Unable to initialize Hijrah calendar: " + id, ex); } - } catch (Exception ex) { - // Log the error - // ex.printStackTrace(); } } } /** - * Restricted constructor. - */ - private HijrahChronology() { - this("Hijrah", "islamicc"); - } - /** - * Constructor for name and type HijrahChronology. + * Create a HijrahChronology for the named variant. + * The resource and calendar type are retrieved from properties + * in the {@code calendars.properties}. + * The property names are {@code "calendar.hijrah." + id} + * and {@code "calendar.hijrah." + id + ".type"} * @param id the id of the calendar - * @param calendarType the calendar type + * @throws Exception if the resource can not be accessed or + * the format is invalid */ - private HijrahChronology(String id, String calendarType) { + private HijrahChronology(String id) throws Exception { + if (id.isEmpty()) { + throw new IllegalArgumentException("calendar id is empty"); + } this.typeId = id; - this.calendarType = calendarType; - - ADJUSTED_CYCLES = new long[MAX_ADJUSTED_CYCLE]; - for (int i = 0; i < ADJUSTED_CYCLES.length; i++) { - ADJUSTED_CYCLES[i] = (10631L * i); - } - // Initialize min values, least max values and max values. - ADJUSTED_MIN_VALUES = Arrays.copyOf(MIN_VALUES, MIN_VALUES.length); - ADJUSTED_LEAST_MAX_VALUES = Arrays.copyOf(LEAST_MAX_VALUES, LEAST_MAX_VALUES.length); - ADJUSTED_MAX_VALUES = Arrays.copyOf(MAX_VALUES,MAX_VALUES.length); + this.calendarType = calendarProperties.getProperty(PROP_PREFIX + id + PROP_TYPE_SUFFIX); try { - // Implicitly reads deviation data for this HijrahChronology. - boolean any = HijrahDeviationReader.readDeviation(typeId, calendarType, this::addDeviationAsHijrah); - } catch (IOException | ParseException e) { - // do nothing. Log deviation config errors. - //e.printStackTrace(); + String resource = calendarProperties.getProperty(PROP_PREFIX + id); + Objects.requireNonNull(resource, "Resource missing for calendar"); + loadCalendarData(resource); + } catch (Exception ex) { + throw new Exception("Unable to initialize HijrahCalendar: " + id, ex); } } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** - * Gets the ID of the chronology - 'Hijrah'. + * Gets the ID of the chronology. *

    - * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * The ID uniquely identifies the {@code Chronology}. It can be used to + * lookup the {@code Chronology} using {@link #of(String)}. * - * @return the chronology ID - 'Hijrah' + * @return the chronology ID, non-null * @see #getCalendarType() */ @Override @@ -520,15 +378,14 @@ } /** - * Gets the calendar type of the underlying calendar system - 'islamicc'. + * Gets the calendar type of the Islamic calendar. *

    * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. * It can be used to lookup the {@code Chronology} using {@link #of(String)}. - * It can also be used as part of a locale, accessible via - * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * - * @return the calendar system type - 'islamicc' + * @return the calendar system type; non-null if the calendar has + * a standard type, otherwise null * @see #getId() */ @Override @@ -537,33 +394,78 @@ } //----------------------------------------------------------------------- + /** + * Obtains a local date in Hijrah calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Hijrah era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code HijrahEra} + */ @Override - public HijrahDate date(int prolepticYear, int month, int dayOfMonth) { - return HijrahDate.of(this, prolepticYear, month, dayOfMonth); + public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } + /** + * Obtains a local date in Hijrah calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ @Override - public HijrahDate dateYearDay(int prolepticYear, int dayOfYear) { - return HijrahDate.of(this, prolepticYear, 1, 1).plusDays(dayOfYear - 1); // TODO better + public HijrahDate date(int prolepticYear, int month, int dayOfMonth) { + return HijrahDate.of(this, prolepticYear, month, dayOfMonth); } + /** + * Obtains a local date in Hijrah calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Hijrah era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code HijrahEra} + */ @Override - public HijrahDate date(TemporalAccessor temporal) { - if (temporal instanceof HijrahDate) { - return (HijrahDate) temporal; - } - return HijrahDate.ofEpochDay(this, temporal.getLong(EPOCH_DAY)); + public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } + /** + * Obtains a local date in Hijrah calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ @Override - public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); - + public HijrahDate dateYearDay(int prolepticYear, int dayOfYear) { + return HijrahDate.of(this, prolepticYear, 1, 1).plusDays(dayOfYear - 1); // TODO better } - @Override - public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Hijrah calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public HijrahDate dateEpochDay(long epochDay) { + return HijrahDate.ofEpochDay(this, epochDay); } @Override @@ -582,47 +484,50 @@ } @Override + public HijrahDate date(TemporalAccessor temporal) { + if (temporal instanceof HijrahDate) { + return (HijrahDate) temporal; + } + return HijrahDate.ofEpochDay(this, temporal.getLong(EPOCH_DAY)); + } + + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { - return (ChronoLocalDateTime)super.localDateTime(temporal); + return (ChronoLocalDateTime) super.localDateTime(temporal); } @Override public ChronoZonedDateTime zonedDateTime(TemporalAccessor temporal) { - return (ChronoZonedDateTime)super.zonedDateTime(temporal); + return (ChronoZonedDateTime) super.zonedDateTime(temporal); } @Override public ChronoZonedDateTime zonedDateTime(Instant instant, ZoneId zone) { - return (ChronoZonedDateTime)super.zonedDateTime(instant, zone); + return (ChronoZonedDateTime) super.zonedDateTime(instant, zone); } //----------------------------------------------------------------------- @Override public boolean isLeapYear(long prolepticYear) { - return isLeapYear0(prolepticYear); - } - /** - * Returns if the year is a leap year. - * @param prolepticYear he year to compute from - * @return {@code true} if the year is a leap year, otherwise {@code false} - */ - private static boolean isLeapYear0(long prolepticYear) { - return (14 + 11 * (prolepticYear > 0 ? prolepticYear : -prolepticYear)) % 30 < 11; + int epochMonth = yearToEpochMonth((int) prolepticYear); + if (epochMonth < 0 || epochMonth > maxEpochDay) { + throw new DateTimeException("Hijrah date out of range"); + } + int len = getYearLength((int) prolepticYear); + return (len > 354); } @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof HijrahEra == false) { - throw new DateTimeException("Era must be HijrahEra"); + throw new ClassCastException("Era must be HijrahEra"); } - return (era == HijrahEra.AH ? yearOfEra : 1 - yearOfEra); + return yearOfEra; } @Override public Era eraOf(int eraValue) { switch (eraValue) { - case 0: - return HijrahEra.BEFORE_AH; case 1: return HijrahEra.AH; default: @@ -638,746 +543,482 @@ //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) { + if (field instanceof ChronoField) { + ChronoField f = field; + switch (f) { + case DAY_OF_MONTH: + return ValueRange.of(1, 1, getMinimumMonthLength(), getMaximumMonthLength()); + case DAY_OF_YEAR: + return ValueRange.of(1, getMaximumDayOfYear()); + case ALIGNED_WEEK_OF_MONTH: + return ValueRange.of(1, 5); + case YEAR: + case YEAR_OF_ERA: + return ValueRange.of(getMinimumYear(), getMaximumYear()); + default: + return field.range(); + } + } return field.range(); } /** - * Check the validity of a yearOfEra. - * @param yearOfEra the year to check + * Check the validity of a year. + * + * @param prolepticYear the year to check */ - void checkValidYearOfEra(int yearOfEra) { - if (yearOfEra < MIN_YEAR_OF_ERA || - yearOfEra > MAX_YEAR_OF_ERA) { - throw new DateTimeException("Invalid year of Hijrah Era"); - } + int checkValidYear(long prolepticYear) { + if (prolepticYear < getMinimumYear() || prolepticYear > getMaximumYear()) { + throw new DateTimeException("Invalid Hijrah year: " + prolepticYear); + } + return (int) prolepticYear; } void checkValidDayOfYear(int dayOfYear) { - if (dayOfYear < 1 || - dayOfYear > getMaximumDayOfYear()) { - throw new DateTimeException("Invalid day of year of Hijrah date"); - } + if (dayOfYear < 1 || dayOfYear > getMaximumDayOfYear()) { + throw new DateTimeException("Invalid Hijrah day of year: " + dayOfYear); + } } void checkValidMonth(int month) { - if (month < 1 || month > 12) { - throw new DateTimeException("Invalid month of Hijrah date"); - } - } - - void checkValidDayOfMonth(int dayOfMonth) { - if (dayOfMonth < 1 || - dayOfMonth > getMaximumDayOfMonth()) { - throw new DateTimeException("Invalid day of month of Hijrah date, day " - + dayOfMonth + " greater than " + getMaximumDayOfMonth() + " or less than 1"); - } + if (month < 1 || month > 12) { + throw new DateTimeException("Invalid Hijrah month: " + month); + } } //----------------------------------------------------------------------- /** - * Returns the int array containing the following field from the julian day. + * Returns an array containing the Hijrah year, month and day + * computed from the epoch day. * - * int[0] = ERA - * int[1] = YEAR - * int[2] = MONTH - * int[3] = DATE - * int[4] = DAY_OF_YEAR - * int[5] = DAY_OF_WEEK - * - * @param gregorianDays a julian day. - */ - int[] getHijrahDateInfo(long gregorianDays) { - int era, year, month, date, dayOfWeek, dayOfYear; - - int cycleNumber, yearInCycle, dayOfCycle; - - long epochDay = gregorianDays - HIJRAH_JAN_1_1_GREGORIAN_DAY; - - if (epochDay >= 0) { - cycleNumber = getCycleNumber(epochDay); // 0 - 99. - dayOfCycle = getDayOfCycle(epochDay, cycleNumber); // 0 - 10631. - yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29. - dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle); - // 0 - 354/355 - year = cycleNumber * 30 + yearInCycle + 1; // 1-based year. - month = getMonthOfYear(dayOfYear, year); // 0-based month-of-year - date = getDayOfMonth(dayOfYear, month, year); // 0-based date - ++date; // Convert from 0-based to 1-based - era = HijrahEra.AH.getValue(); - } else { - cycleNumber = (int) epochDay / 10631; // 0 or negative number. - dayOfCycle = (int) epochDay % 10631; // -10630 - 0. - if (dayOfCycle == 0) { - dayOfCycle = -10631; - cycleNumber++; - } - yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29. - dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle); - year = cycleNumber * 30 - yearInCycle; // negative number. - year = 1 - year; - dayOfYear = (isLeapYear(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - month = getMonthOfYear(dayOfYear, year); - date = getDayOfMonth(dayOfYear, month, year); - ++date; // Convert from 0-based to 1-based - era = HijrahEra.BEFORE_AH.getValue(); - } - // Hijrah day zero is a Friday - dayOfWeek = (int) ((epochDay + 5) % 7); - dayOfWeek += (dayOfWeek <= 0) ? 7 : 0; - - int dateInfo[] = new int[6]; - dateInfo[0] = era; - dateInfo[1] = year; - dateInfo[2] = month + 1; // change to 1-based. - dateInfo[3] = date; - dateInfo[4] = dayOfYear + 1; // change to 1-based. - dateInfo[5] = dayOfWeek; + * @param epochDay the EpochDay + * @return int[0] = YEAR, int[1] = MONTH, int[2] = DATE + */ + int[] getHijrahDateInfo(int epochDay) { + if (epochDay < minEpochDay || epochDay >= maxEpochDay) { + throw new DateTimeException("Hijrah date out of range"); + } + + int epochMonth = epochDayToEpochMonth(epochDay); + int year = epochMonthToYear(epochMonth); + int month = epochMonthToMonth(epochMonth); + int day1 = epochMonthToEpochDay(epochMonth); + int date = epochDay - day1; // epochDay - dayOfEpoch(year, month); + + int dateInfo[] = new int[3]; + dateInfo[0] = year; + dateInfo[1] = month + 1; // change to 1-based. + dateInfo[2] = date + 1; // change to 1-based. return dateInfo; } /** - * Return Gregorian epoch day from Hijrah year, month, and day. + * Return the epoch day computed from Hijrah year, month, and day. * - * @param prolepticYear the year to represent, caller calculated - * @param monthOfYear the month-of-year to represent, caller calculated - * @param dayOfMonth the day-of-month to represent, caller calculated - * @return a julian day - */ - long getGregorianEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) { - long day = yearToGregorianEpochDay(prolepticYear); - day += getMonthDays(monthOfYear - 1, prolepticYear); - day += dayOfMonth; - return day; - } - - /** - * Returns the Gregorian epoch day from the proleptic year - * @param prolepticYear the proleptic year - * @return the Epoch day + * @param prolepticYear the year to represent, 0-origin + * @param monthOfYear the month-of-year to represent, 1-origin + * @param dayOfMonth the day-of-month to represent, 1-origin + * @return the epoch day */ - private long yearToGregorianEpochDay(int prolepticYear) { - - int cycleNumber = (prolepticYear - 1) / 30; // 0-based. - int yearInCycle = (prolepticYear - 1) % 30; // 0-based. - - int dayInCycle = getAdjustedCycle(cycleNumber)[Math.abs(yearInCycle)] - ; - - if (yearInCycle < 0) { - dayInCycle = -dayInCycle; + long getEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) { + checkValidMonth(monthOfYear); + int epochMonth = yearToEpochMonth(prolepticYear) + (monthOfYear - 1); + if (epochMonth < 0 || epochMonth >= hijrahEpochMonthStartDays.length) { + throw new DateTimeException("Invalid Hijrah date, year: " + + prolepticYear + ", month: " + monthOfYear); } - - Long cycleDays; - - try { - cycleDays = ADJUSTED_CYCLES[cycleNumber]; - } catch (ArrayIndexOutOfBoundsException e) { - cycleDays = null; - } - - if (cycleDays == null) { - cycleDays = new Long(cycleNumber * 10631); + if (dayOfMonth < 1 || dayOfMonth > getMonthLength(prolepticYear, monthOfYear)) { + throw new DateTimeException("Invalid Hijrah day of month: " + dayOfMonth); } - - return (cycleDays.longValue() + dayInCycle + HIJRAH_JAN_1_1_GREGORIAN_DAY - 1); + return epochMonthToEpochDay(epochMonth) + (dayOfMonth - 1); } /** - * Returns the 30 year cycle number from the epoch day. + * Returns day of year for the year and month. * - * @param epochDay an epoch day - * @return a cycle number + * @param prolepticYear a proleptic year + * @param month a month, 1-origin + * @return the day of year, 1-origin */ - private int getCycleNumber(long epochDay) { - long[] days = ADJUSTED_CYCLES; - int cycleNumber; - try { - for (int i = 0; i < days.length; i++) { - if (epochDay < days[i]) { - return i - 1; - } - } - cycleNumber = (int) epochDay / 10631; - } catch (ArrayIndexOutOfBoundsException e) { - cycleNumber = (int) epochDay / 10631; - } - return cycleNumber; + int getDayOfYear(int prolepticYear, int month) { + return yearMonthToDayOfYear(prolepticYear, (month - 1)); } /** - * Returns day of cycle from the epoch day and cycle number. + * Returns month length for the year and month. * - * @param epochDay an epoch day - * @param cycleNumber a cycle number - * @return a day of cycle + * @param prolepticYear a proleptic year + * @param monthOfYear a month, 1-origin. + * @return the length of the month */ - private int getDayOfCycle(long epochDay, int cycleNumber) { - Long day; - - try { - day = ADJUSTED_CYCLES[cycleNumber]; - } catch (ArrayIndexOutOfBoundsException e) { - day = null; - } - if (day == null) { - day = new Long(cycleNumber * 10631); + int getMonthLength(int prolepticYear, int monthOfYear) { + int epochMonth = yearToEpochMonth(prolepticYear) + (monthOfYear - 1); + if (epochMonth < 0 || epochMonth >= hijrahEpochMonthStartDays.length) { + throw new DateTimeException("Invalid Hijrah date, year: " + + prolepticYear + ", month: " + monthOfYear); } - return (int) (epochDay - day.longValue()); + return epochMonthLength(epochMonth); } /** - * Returns the year in cycle from the cycle number and day of cycle. + * Returns year length. + * Note: The 12th month must exist in the data. * - * @param cycleNumber a cycle number - * @param dayOfCycle day of cycle - * @return a year in cycle + * @param prolepticYear a proleptic year + * @return year length in days */ - private int getYearInCycle(int cycleNumber, long dayOfCycle) { - int[] cycles = getAdjustedCycle(cycleNumber); - if (dayOfCycle == 0) { - return 0; - } - - if (dayOfCycle > 0) { - for (int i = 0; i < cycles.length; i++) { - if (dayOfCycle < cycles[i]) { - return i - 1; - } - } - return 29; - } else { - dayOfCycle = -dayOfCycle; - for (int i = 0; i < cycles.length; i++) { - if (dayOfCycle <= cycles[i]) { - return i - 1; - } - } - return 29; - } + int getYearLength(int prolepticYear) { + return yearMonthToDayOfYear(prolepticYear, 12); } /** - * Returns adjusted 30 year cycle starting day as Integer array from the - * cycle number specified. + * Return the minimum supported Hijrah year. * - * @param cycleNumber a cycle number - * @return an Integer array + * @return the minimum */ - int[] getAdjustedCycle(int cycleNumber) { - int[] cycles; - try { - cycles = ADJUSTED_CYCLE_YEARS.get(cycleNumber); - } catch (ArrayIndexOutOfBoundsException e) { - cycles = null; - } - if (cycles == null) { - cycles = DEFAULT_CYCLE_YEARS; - } - return cycles; + int getMinimumYear() { + return epochMonthToYear(0); } /** - * Returns adjusted month days as Integer array form the year specified. + * Return the maximum supported Hijrah ear. * - * @param year a year - * @return an Integer array + * @return the minimum */ - int[] getAdjustedMonthDays(int year) { - int[] newMonths; - try { - newMonths = ADJUSTED_MONTH_DAYS.get(year); - } catch (ArrayIndexOutOfBoundsException e) { - newMonths = null; - } - if (newMonths == null) { - if (isLeapYear0(year)) { - newMonths = DEFAULT_LEAP_MONTH_DAYS; - } else { - newMonths = DEFAULT_MONTH_DAYS; - } - } - return newMonths; + int getMaximumYear() { + return epochMonthToYear(hijrahEpochMonthStartDays.length - 1) - 1; } /** - * Returns adjusted month length as Integer array form the year specified. + * Returns maximum day-of-month. * - * @param year a year - * @return an Integer array + * @return maximum day-of-month */ - int[] getAdjustedMonthLength(int year) { - int[] newMonths; - try { - newMonths = ADJUSTED_MONTH_LENGTHS.get(year); - } catch (ArrayIndexOutOfBoundsException e) { - newMonths = null; - } - if (newMonths == null) { - if (isLeapYear0(year)) { - newMonths = DEFAULT_LEAP_MONTH_LENGTHS; - } else { - newMonths = DEFAULT_MONTH_LENGTHS; - } - } - return newMonths; + int getMaximumMonthLength() { + return maxMonthLength; } /** - * Returns day-of-year. + * Returns smallest maximum day-of-month. * - * @param cycleNumber a cycle number - * @param dayOfCycle day of cycle - * @param yearInCycle year in cycle - * @return day-of-year + * @return smallest maximum day-of-month */ - private int getDayOfYear(int cycleNumber, int dayOfCycle, int yearInCycle) { - int[] cycles = getAdjustedCycle(cycleNumber); - - if (dayOfCycle > 0) { - return dayOfCycle - cycles[yearInCycle]; - } else { - return cycles[yearInCycle] + dayOfCycle; - } + int getMinimumMonthLength() { + return minMonthLength; } /** - * Returns month-of-year. 0-based. + * Returns maximum day-of-year. * - * @param dayOfYear day-of-year - * @param year a year - * @return month-of-year + * @return maximum day-of-year */ - private int getMonthOfYear(int dayOfYear, int year) { - - int[] newMonths = getAdjustedMonthDays(year); - - if (dayOfYear >= 0) { - for (int i = 0; i < newMonths.length; i++) { - if (dayOfYear < newMonths[i]) { - return i - 1; - } - } - return 11; - } else { - dayOfYear = (isLeapYear0(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - for (int i = 0; i < newMonths.length; i++) { - if (dayOfYear < newMonths[i]) { - return i - 1; - } - } - return 11; - } + int getMaximumDayOfYear() { + return maxYearLength; } /** - * Returns day-of-month. + * Returns smallest maximum day-of-year. * - * @param dayOfYear day of year - * @param month month - * @param year year - * @return day-of-month + * @return smallest maximum day-of-year */ - private int getDayOfMonth(int dayOfYear, int month, int year) { - - int[] newMonths = getAdjustedMonthDays(year); - - if (dayOfYear >= 0) { - if (month > 0) { - return dayOfYear - newMonths[month]; - } else { - return dayOfYear; - } - } else { - dayOfYear = (isLeapYear0(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - if (month > 0) { - return dayOfYear - newMonths[month]; - } else { - return dayOfYear; - } - } + int getSmallestMaximumDayOfYear() { + return minYearLength; } - /** - * Returns month days from the beginning of year. + * Returns the epochMonth found by locating the epochDay in the table. The + * epochMonth is the index in the table * - * @param month month (0-based) - * @parma year year - * @return month days from the beginning of year + * @param epochDay + * @return The index of the element of the start of the month containing the + * epochDay. */ - private int getMonthDays(int month, int year) { - int[] newMonths = getAdjustedMonthDays(year); - return newMonths[month]; + private int epochDayToEpochMonth(int epochDay) { + // binary search + int ndx = Arrays.binarySearch(hijrahEpochMonthStartDays, epochDay); + if (ndx < 0) { + ndx = -ndx - 2; + } + return ndx; } /** - * Returns month length. + * Returns the year computed from the epochMonth * - * @param month month (0-based) - * @param year year - * @return month length + * @param epochMonth the epochMonth + * @return the Hijrah Year */ - private int getMonthLength(int month, int year) { - int[] newMonths = getAdjustedMonthLength(year); - return newMonths[month]; + private int epochMonthToYear(int epochMonth) { + return (epochMonth + hijrahStartEpochMonth) / 12; } /** - * Returns year length. + * Returns the epochMonth for the Hijrah Year. * - * @param year year - * @return year length + * @param year the HijrahYear + * @return the epochMonth for the beginning of the year. */ - int getYearLength(int year) { - - int cycleNumber = (year - 1) / 30; - int[] cycleYears; - try { - cycleYears = ADJUSTED_CYCLE_YEARS.get(cycleNumber); - } catch (ArrayIndexOutOfBoundsException e) { - cycleYears = null; - } - if (cycleYears != null) { - int yearInCycle = (year - 1) % 30; - if (yearInCycle == 29) { - return (int)(ADJUSTED_CYCLES[cycleNumber + 1] - - ADJUSTED_CYCLES[cycleNumber] - - cycleYears[yearInCycle]); - } - return cycleYears[yearInCycle + 1] - - cycleYears[yearInCycle]; - } else { - return isLeapYear0(year) ? 355 : 354; - } + private int yearToEpochMonth(int year) { + return (year * 12) - hijrahStartEpochMonth; } - /** - * Returns maximum day-of-month. + * Returns the Hijrah month from the epochMonth. * - * @return maximum day-of-month + * @param epochMonth the epochMonth + * @return the month of the Hijrah Year */ - int getMaximumDayOfMonth() { - return ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH]; + private int epochMonthToMonth(int epochMonth) { + return (epochMonth + hijrahStartEpochMonth) % 12; } /** - * Returns smallest maximum day-of-month. + * Returns the epochDay for the start of the epochMonth. * - * @return smallest maximum day-of-month + * @param epochMonth the epochMonth + * @return the epochDay for the start of the epochMonth. */ - int getSmallestMaximumDayOfMonth() { - return ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH]; + private int epochMonthToEpochDay(int epochMonth) { + return hijrahEpochMonthStartDays[epochMonth]; + } /** - * Returns maximum day-of-year. + * Returns the day of year for the requested HijrahYear and month. * - * @return maximum day-of-year + * @param prolepticYear the Hijrah year + * @param month the Hijrah month + * @return the day of year for the start of the month of the year */ - int getMaximumDayOfYear() { - return ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR]; + private int yearMonthToDayOfYear(int prolepticYear, int month) { + int epochMonthFirst = yearToEpochMonth(prolepticYear); + return epochMonthToEpochDay(epochMonthFirst + month) + - epochMonthToEpochDay(epochMonthFirst); } /** - * Returns smallest maximum day-of-year. + * Returns the length of the epochMonth. It is computed from the start of + * the following month minus the start of the requested month. * - * @return smallest maximum day-of-year + * @param epochMonth the epochMonth; assumed to be within range + * @return the length in days of the epochMonth */ - int getSmallestMaximumDayOfYear() { - return ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR]; + private int epochMonthLength(int epochMonth) { + // The very last entry in the epochMonth table is not the start of a month + return hijrahEpochMonthStartDays[epochMonth + 1] + - hijrahEpochMonthStartDays[epochMonth]; } - // ----- Deviation handling -----// + //----------------------------------------------------------------------- + private static final String KEY_ID = "id"; + private static final String KEY_TYPE = "type"; + private static final String KEY_VERSION = "version"; + private static final String KEY_ISO_START = "iso-start"; /** - * Adds deviation definition. The year and month specified should be the - * calculated Hijrah year and month. The month is 1 based. e.g. 9 for - * Ramadan (9th month) Addition of anything minus deviation days is - * calculated negatively in the case the user wants to subtract days from - * the calendar. For example, adding -1 days will subtract one day from the - * current date. + * Return the configuration properties from the resource. + *

    + * The default location of the variant configuration resource is: + *

    +     *   "$java.home/lib/" + resource-name
    +     * 
    * - * @param startYear start year, 1 origin - * @param startMonth start month, 1 origin - * @param endYear end year, 1 origin - * @param endMonth end month, 1 origin - * @param offset offset -2, -1, +1, +2 + * @param resource the name of the calendar property resource + * @return a Properties containing the properties read from the resource. + * @throws Exception if access to the property resource fails */ - private void addDeviationAsHijrah(Deviation entry) { - int startYear = entry.startYear; - int startMonth = entry.startMonth - 1 ; - int endYear = entry.endYear; - int endMonth = entry.endMonth - 1; - int offset = entry.offset; - - if (startYear < 1) { - throw new IllegalArgumentException("startYear < 1"); - } - if (endYear < 1) { - throw new IllegalArgumentException("endYear < 1"); - } - if (startMonth < 0 || startMonth > 11) { - throw new IllegalArgumentException( - "startMonth < 0 || startMonth > 11"); - } - if (endMonth < 0 || endMonth > 11) { - throw new IllegalArgumentException("endMonth < 0 || endMonth > 11"); - } - if (endYear > 9999) { - throw new IllegalArgumentException("endYear > 9999"); - } - if (endYear < startYear) { - throw new IllegalArgumentException("startYear > endYear"); - } - if (endYear == startYear && endMonth < startMonth) { - throw new IllegalArgumentException( - "startYear == endYear && endMonth < startMonth"); - } - - // Adjusting start year. - boolean isStartYLeap = isLeapYear0(startYear); - - // Adjusting the number of month. - int[] orgStartMonthNums = ADJUSTED_MONTH_DAYS.get(startYear); - if (orgStartMonthNums == null) { - if (isStartYLeap) { - orgStartMonthNums = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); - } else { - orgStartMonthNums = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); - } + private static Properties readConfigProperties(final String resource) throws Exception { + try { + return AccessController + .doPrivileged((java.security.PrivilegedExceptionAction) + () -> { + String libDir = System.getProperty("java.home") + File.separator + "lib"; + File file = new File(libDir, resource); + Properties props = new Properties(); + try (InputStream is = new FileInputStream(file)) { + props.load(is); + } + return props; + }); + } catch (PrivilegedActionException pax) { + throw pax.getException(); } + } - int[] newStartMonthNums = new int[orgStartMonthNums.length]; - - for (int month = 0; month < 12; month++) { - if (month > startMonth) { - newStartMonthNums[month] = (orgStartMonthNums[month] - offset); - } else { - newStartMonthNums[month] = (orgStartMonthNums[month]); + /** + * Loads and processes the Hijrah calendar properties file. + * The starting Hijrah date and the corresponding ISO date are + * extracted and used to calculate the epochDate offset. + * The version number is identified and ignored. + * Everything else is the data for a year with containing the length of each + * of 12 months. + * + * @param resourceName containing the properties defining the calendar, not null + * @throws IllegalArgumentException if any of the values are malformed + * @throws NumberFormatException if numbers, including properties that should + * be years are invalid + * @throws IOException if access to the property resource fails. + */ + private void loadCalendarData(String resourceName) throws Exception { + Properties props = readConfigProperties(resourceName); + + Map years = new HashMap<>(); + int minYear = Integer.MAX_VALUE; + int maxYear = Integer.MIN_VALUE; + String id = null; + String type = null; + String version = null; + int isoStart = 0; + for (Map.Entry entry : props.entrySet()) { + String key = (String) entry.getKey(); + switch (key) { + case KEY_ID: + id = (String)entry.getValue(); + break; + case KEY_TYPE: + type = (String)entry.getValue(); + break; + case KEY_VERSION: + version = (String)entry.getValue(); + break; + case KEY_ISO_START: { + int[] ymd = parseYMD((String) entry.getValue()); + isoStart = (int) LocalDate.of(ymd[0], ymd[1], ymd[2]).toEpochDay(); + break; + } + default: + try { + // Everything else is either a year or invalid + int year = Integer.valueOf(key); + int[] months = parseMonths((String) entry.getValue()); + years.put(year, months); + maxYear = Math.max(maxYear, year); + minYear = Math.min(minYear, year); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException("bad key: " + key); + } } } - ADJUSTED_MONTH_DAYS.put(startYear, newStartMonthNums); - - // Adjusting the days of month. - - int[] orgStartMonthLengths = ADJUSTED_MONTH_LENGTHS.get(startYear); - if (orgStartMonthLengths == null) { - if (isStartYLeap) { - orgStartMonthLengths = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - } else { - orgStartMonthLengths = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - } + if (!getId().equals(id)) { + throw new IllegalArgumentException("Configuration is for a different calendar: " + id); } - - int[] newStartMonthLengths = new int[orgStartMonthLengths.length]; - - for (int month = 0; month < 12; month++) { - if (month == startMonth) { - newStartMonthLengths[month] = orgStartMonthLengths[month] - offset; - } else { - newStartMonthLengths[month] = orgStartMonthLengths[month]; - } + if (!getCalendarType().equals(type)) { + throw new IllegalArgumentException("Configuration is for a different calendar type: " + type); } - - ADJUSTED_MONTH_LENGTHS.put(startYear, newStartMonthLengths); - - if (startYear != endYear) { - // System.out.println("over year"); - // Adjusting starting 30 year cycle. - int sCycleNumber = (startYear - 1) / 30; - int sYearInCycle = (startYear - 1) % 30; // 0-based. - int[] startCycles = ADJUSTED_CYCLE_YEARS.get(sCycleNumber); - if (startCycles == null) { - startCycles = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); - } - - for (int j = sYearInCycle + 1; j < CYCLEYEAR_START_DATE.length; j++) { - startCycles[j] = startCycles[j] - offset; - } - - // System.out.println(sCycleNumber + ":" + sYearInCycle); - ADJUSTED_CYCLE_YEARS.put(sCycleNumber, startCycles); - - int sYearInMaxY = (startYear - 1) / 30; - int sEndInMaxY = (endYear - 1) / 30; - - if (sYearInMaxY != sEndInMaxY) { - // System.out.println("over 30"); - // Adjusting starting 30 * MAX_ADJUSTED_CYCLE year cycle. - // System.out.println(sYearInMaxY); - - for (int j = sYearInMaxY + 1; j < ADJUSTED_CYCLES.length; j++) { - ADJUSTED_CYCLES[j] = ADJUSTED_CYCLES[j] - offset; - } - - // Adjusting ending 30 * MAX_ADJUSTED_CYCLE year cycles. - for (int j = sEndInMaxY + 1; j < ADJUSTED_CYCLES.length; j++) { - ADJUSTED_CYCLES[j] = ADJUSTED_CYCLES[j] + offset; - } - } - - // Adjusting ending 30 year cycle. - int eCycleNumber = (endYear - 1) / 30; - int sEndInCycle = (endYear - 1) % 30; // 0-based. - int[] endCycles = ADJUSTED_CYCLE_YEARS.get(eCycleNumber); - if (endCycles == null) { - endCycles = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); - } - for (int j = sEndInCycle + 1; j < CYCLEYEAR_START_DATE.length; j++) { - endCycles[j] = endCycles[j] + offset; - } - ADJUSTED_CYCLE_YEARS.put(eCycleNumber, endCycles); + if (version == null || version.isEmpty()) { + throw new IllegalArgumentException("Configuration does not contain a version"); } - - // Adjusting ending year. - boolean isEndYLeap = isLeapYear0(endYear); - - int[] orgEndMonthDays = ADJUSTED_MONTH_DAYS.get(endYear); - - if (orgEndMonthDays == null) { - if (isEndYLeap) { - orgEndMonthDays = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); - } else { - orgEndMonthDays = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); - } + if (isoStart == 0) { + throw new IllegalArgumentException("Configuration does not contain a ISO start date"); } - int[] newEndMonthDays = new int[orgEndMonthDays.length]; + // Now create and validate the array of epochDays indexed by epochMonth + hijrahStartEpochMonth = minYear * 12; + minEpochDay = isoStart; + hijrahEpochMonthStartDays = createEpochMonths(minEpochDay, minYear, maxYear, years); + maxEpochDay = hijrahEpochMonthStartDays[hijrahEpochMonthStartDays.length - 1]; - for (int month = 0; month < 12; month++) { - if (month > endMonth) { - newEndMonthDays[month] = orgEndMonthDays[month] + offset; - } else { - newEndMonthDays[month] = orgEndMonthDays[month]; - } + // Compute the min and max year length in days. + for (int year = minYear; year < maxYear; year++) { + int length = getYearLength(year); + minYearLength = Math.min(minYearLength, length); + maxYearLength = Math.max(maxYearLength, length); } + } - ADJUSTED_MONTH_DAYS.put(endYear, newEndMonthDays); - - // Adjusting the days of month. - int[] orgEndMonthLengths = ADJUSTED_MONTH_LENGTHS.get(endYear); + /** + * Converts the map of year to month lengths ranging from minYear to maxYear + * into a linear contiguous array of epochDays. The index is the hijrahMonth + * computed from year and month and offset by minYear. The value of each + * entry is the epochDay corresponding to the first day of the month. + * + * @param minYear The minimum year for which data is provided + * @param maxYear The maximum year for which data is provided + * @param years a Map of year to the array of 12 month lengths + * @return array of epochDays for each month from min to max + */ + private int[] createEpochMonths(int epochDay, int minYear, int maxYear, Map years) { + // Compute the size for the array of dates + int numMonths = (maxYear - minYear + 1) * 12 + 1; - if (orgEndMonthLengths == null) { - if (isEndYLeap) { - orgEndMonthLengths = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - } else { - orgEndMonthLengths = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - } - } + // Initialize the running epochDay as the corresponding ISO Epoch day + int epochMonth = 0; // index into array of epochMonths + int[] epochMonths = new int[numMonths]; + minMonthLength = Integer.MAX_VALUE; + maxMonthLength = Integer.MIN_VALUE; - int[] newEndMonthLengths = new int[orgEndMonthLengths.length]; + // Only whole years are valid, any zero's in the array are illegal + for (int year = minYear; year <= maxYear; year++) { + int[] months = years.get(year);// must not be gaps + for (int month = 0; month < 12; month++) { + int length = months[month]; + epochMonths[epochMonth++] = epochDay; - for (int month = 0; month < 12; month++) { - if (month == endMonth) { - newEndMonthLengths[month] = orgEndMonthLengths[month] + offset; - } else { - newEndMonthLengths[month] = orgEndMonthLengths[month]; + if (length < 29 || length > 32) { + throw new IllegalArgumentException("Invalid month length in year: " + minYear); + } + epochDay += length; + minMonthLength = Math.min(minMonthLength, length); + maxMonthLength = Math.max(maxMonthLength, length); } } - ADJUSTED_MONTH_LENGTHS.put(endYear, newEndMonthLengths); - - int[] startMonthLengths = ADJUSTED_MONTH_LENGTHS.get(startYear); - int[] endMonthLengths = ADJUSTED_MONTH_LENGTHS.get(endYear); - int[] startMonthDays = ADJUSTED_MONTH_DAYS.get(startYear); - int[] endMonthDays = ADJUSTED_MONTH_DAYS.get(endYear); - - int startMonthLength = startMonthLengths[startMonth]; - int endMonthLength = endMonthLengths[endMonth]; - int startMonthDay = startMonthDays[11] + startMonthLengths[11]; - int endMonthDay = endMonthDays[11] + endMonthLengths[11]; - - int maxMonthLength = ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH]; - int leastMaxMonthLength = ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH]; - - if (maxMonthLength < startMonthLength) { - maxMonthLength = startMonthLength; - } - if (maxMonthLength < endMonthLength) { - maxMonthLength = endMonthLength; - } - ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH] = maxMonthLength; - - if (leastMaxMonthLength > startMonthLength) { - leastMaxMonthLength = startMonthLength; - } - if (leastMaxMonthLength > endMonthLength) { - leastMaxMonthLength = endMonthLength; - } - ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH] = leastMaxMonthLength; + // Insert the final epochDay + epochMonths[epochMonth++] = epochDay; - int maxMonthDay = ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR]; - int leastMaxMonthDay = ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR]; - - if (maxMonthDay < startMonthDay) { - maxMonthDay = startMonthDay; - } - if (maxMonthDay < endMonthDay) { - maxMonthDay = endMonthDay; + if (epochMonth != epochMonths.length) { + throw new IllegalStateException("Did not fill epochMonths exactly: ndx = " + epochMonth + + " should be " + epochMonths.length); } - ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR] = maxMonthDay; - - if (leastMaxMonthDay > startMonthDay) { - leastMaxMonthDay = startMonthDay; - } - if (leastMaxMonthDay > endMonthDay) { - leastMaxMonthDay = endMonthDay; - } - ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR] = leastMaxMonthDay; + return epochMonths; } /** - * Package private Entry for suppling deviations from the Reader. - * Each entry consists of a range using the Hijrah calendar, - * start year, month, end year, end month, and an offset. - * The offset is used to modify the length of the month +2, +1, -1, -2. + * Parses the 12 months lengths from a property value for a specific year. + * + * @param line the value of a year property + * @return an array of int[12] containing the 12 month lengths + * @throws IllegalArgumentException if the number of months is not 12 + * @throws NumberFormatException if the 12 tokens are not numbers */ - static final class Deviation { - - Deviation(int startYear, int startMonth, int endYear, int endMonth, int offset) { - this.startYear = startYear; - this.startMonth = startMonth; - this.endYear = endYear; - this.endMonth = endMonth; - this.offset = offset; + private int[] parseMonths(String line) { + int[] months = new int[12]; + String[] numbers = line.split("\\s"); + if (numbers.length != 12) { + throw new IllegalArgumentException("wrong number of months on line: " + Arrays.toString(numbers) + "; count: " + numbers.length); } - - final int startYear; - final int startMonth; - final int endYear; - final int endMonth; - final int offset; - - int getStartYear() { - return startYear; - } - - int getStartMonth() { - return startMonth; - } - - int getEndYear() { - return endYear; - } - - int getEndMonth() { - return endMonth; - } - - int getOffset() { - return offset; + for (int i = 0; i < 12; i++) { + try { + months[i] = Integer.valueOf(numbers[i]); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException("bad key: " + numbers[i]); + } } + return months; + } - @Override - public String toString() { - return String.format("[year: %4d, month: %2d, offset: %+d]", startYear, startMonth, offset); + /** + * Parse yyyy-MM-dd into a 3 element array [yyyy, mm, dd]. + * + * @param string the input string + * @return the 3 element array with year, month, day + */ + private int[] parseYMD(String string) { + // yyyy-MM-dd + string = string.trim(); + try { + if (string.charAt(4) != '-' || string.charAt(7) != '-') { + throw new IllegalArgumentException("date must be yyyy-MM-dd"); + } + int[] ymd = new int[3]; + ymd[0] = Integer.valueOf(string.substring(0, 4)); + ymd[1] = Integer.valueOf(string.substring(5, 7)); + ymd[2] = Integer.valueOf(string.substring(8, 10)); + return ymd; + } catch (NumberFormatException ex) { + throw new IllegalArgumentException("date must be yyyy-MM-dd", ex); } } - } --- old/src/share/classes/java/time/chrono/HijrahDate.java 2013-04-11 23:15:34.000000000 -0700 +++ new/src/share/classes/java/time/chrono/HijrahDate.java 2013-04-11 23:15:34.000000000 -0700 @@ -70,55 +70,38 @@ import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; -import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalTime; import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; -import java.util.Objects; /** * A date in the Hijrah calendar system. *

    - * This date operates using the {@linkplain HijrahChronology Hijrah calendar}. + * This date operates using one of several variants of the + * {@linkplain HijrahChronology Hijrah calendar}. *

    * The Hijrah calendar has a different total of days in a year than - * Gregorian calendar, and a month is based on the period of a complete - * revolution of the moon around the earth (as between successive new moons). - * The calendar cycles becomes longer and unstable, and sometimes a manual - * adjustment (for entering deviation) is necessary for correctness - * because of the complex algorithm. + * Gregorian calendar, and the length of each month is based on the period + * of a complete revolution of the moon around the earth + * (as between successive new moons). + * Refer to the {@link HijrahChronology} for details of supported variants. *

    - * HijrahDate supports the manual adjustment feature by providing a configuration - * file. The configuration file contains the adjustment (deviation) data with following format. - *

    - *   StartYear/StartMonth(0-based)-EndYear/EndMonth(0-based):Deviation day (1, 2, -1, or -2)
    - *   Line separator or ";" is used for the separator of each deviation data.
    - * Here is the example. - *
    - *     1429/0-1429/1:1
    - *     1429/2-1429/7:1;1429/6-1429/11:1
    - *     1429/11-9999/11:1
    - * The default location of the configuration file is: - *
    - *   $CLASSPATH/java/time/i18n
    - * And the default file name is: - *
    - *   hijrah_deviation.cfg
    - * The default location and file name can be overriden by setting - * following two Java's system property. - *
    - *   Location: java.time.i18n.HijrahDate.deviationConfigDir
    - *   File name: java.time.i18n.HijrahDate.deviationConfigFile
    - * + * Each HijrahDate is created bound to a particular HijrahChronology, + * The same chronology is propagated to each HijrahDate computed from the date. + * To use a different Hijrah variant, its HijrahChronology can be used + * to create new HijrahDate instances. + * Alternatively, the {@link #withVariant} method can be used to convert + * to a new HijrahChronology. *

    Specification for implementors

    * This class is immutable and thread-safe. * @@ -132,19 +115,14 @@ * Serialization version. */ private static final long serialVersionUID = -5207853542612002020L; - /** * The Chronology of this HijrahDate. */ private final HijrahChronology chrono; /** - * The era. + * The proleptic year. */ - private final transient HijrahEra era; - /** - * The year. - */ - private final transient int yearOfEra; + private final transient int prolepticYear; /** * The month-of-year. */ @@ -153,69 +131,36 @@ * The day-of-month. */ private final transient int dayOfMonth; - /** - * The day-of-year. - */ - private final transient int dayOfYear; - /** - * The day-of-week. - */ - private final transient DayOfWeek dayOfWeek; - /** - * Gregorian days for this object. Holding number of days since 1970/01/01. - * The number of days are calculated with pure Gregorian calendar - * based. - */ - private final long gregorianEpochDay; - /** - * True if year is leap year. - */ - private final transient boolean isLeapYear; //------------------------------------------------------------------------- /** - * Obtains an instance of {@code HijrahDate} from the Hijrah era year, - * month-of-year and day-of-month. This uses the Hijrah era. + * Obtains an instance of {@code HijrahDate} from the Hijrah proleptic year, + * month-of-year and day-of-month. * - * @param prolepticYear the proleptic year to represent in the Hijrah + * @param prolepticYear the proleptic year to represent in the Hijrah calendar * @param monthOfYear the month-of-year to represent, from 1 to 12 * @param dayOfMonth the day-of-month to represent, from 1 to 30 * @return the Hijrah date, never null * @throws DateTimeException if the value of any field is out of range */ static HijrahDate of(HijrahChronology chrono, int prolepticYear, int monthOfYear, int dayOfMonth) { - return (prolepticYear >= 1) ? - HijrahDate.of(chrono, HijrahEra.AH, prolepticYear, monthOfYear, dayOfMonth) : - HijrahDate.of(chrono, HijrahEra.BEFORE_AH, 1 - prolepticYear, monthOfYear, dayOfMonth); + return new HijrahDate(chrono, prolepticYear, monthOfYear, dayOfMonth); } /** - * Obtains an instance of {@code HijrahDate} from the era, year-of-era - * month-of-year and day-of-month. - * - * @param era the era to represent, not null - * @param yearOfEra the year-of-era to represent, from 1 to 9999 - * @param monthOfYear the month-of-year to represent, from 1 to 12 - * @param dayOfMonth the day-of-month to represent, from 1 to 31 - * @return the Hijrah date, never null - * @throws DateTimeException if the value of any field is out of range + * Returns a HijrahDate for the chronology and epochDay. + * @param chrono The Hijrah chronology + * @param epochDay the epoch day + * @return a HijrahDate for the epoch day; non-null */ - private static HijrahDate of(HijrahChronology chrono, HijrahEra era, int yearOfEra, int monthOfYear, int dayOfMonth) { - Objects.requireNonNull(era, "era"); - chrono.checkValidYearOfEra(yearOfEra); - chrono.checkValidMonth(monthOfYear); - chrono.checkValidDayOfMonth(dayOfMonth); - long gregorianDays = chrono.getGregorianEpochDay(era.prolepticYear(yearOfEra), monthOfYear, dayOfMonth); - return new HijrahDate(chrono, gregorianDays); - } - static HijrahDate ofEpochDay(HijrahChronology chrono, long epochDay) { return new HijrahDate(chrono, epochDay); } //----------------------------------------------------------------------- /** - * Obtains the current {@code HijrahDate} from the system clock in the default time-zone. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * in the default time-zone. *

    * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current date. @@ -230,7 +175,8 @@ } /** - * Obtains the current {@code HijrahDate} from the system clock in the specified time-zone. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * in the specified time-zone. *

    * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date. * Specifying the time-zone avoids dependence on the default time-zone. @@ -246,7 +192,8 @@ } /** - * Obtains the current {@code HijrahDate} from the specified clock. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * from the specified clock. *

    * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. @@ -261,8 +208,8 @@ } /** - * Obtains a {@code HijrahDate} representing a date in the Hijrah calendar - * system from the proleptic-year, month-of-year and day-of-month fields. + * Obtains a {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * from the proleptic-year, month-of-year and day-of-month fields. *

    * This returns a {@code HijrahDate} with the specified fields. * The day must be valid for the year and month, otherwise an exception will be thrown. @@ -279,7 +226,7 @@ } /** - * Obtains a {@code HijrahDate} from a temporal object. + * Obtains a {@code HijrahDate} of the Islamic Umm Al-Qura calendar from a temporal object. *

    * This obtains a date in the Hijrah calendar system based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, @@ -301,35 +248,93 @@ //----------------------------------------------------------------------- /** - * Constructs an instance with the specified date. + * Constructs an {@code HijrahDate} with the proleptic-year, month-of-year and + * day-of-month fields. * - * @param gregorianDay the number of days from 0001/01/01 (Gregorian), caller calculated - */ - private HijrahDate(HijrahChronology chrono, long gregorianDay) { + * @param chrono The chronology to create the date with + * @param prolepticYear the proleptic year + * @param monthOfYear the month of year + * @param dayOfMonth the day of month + */ + private HijrahDate(HijrahChronology chrono, int prolepticYear, int monthOfYear, int dayOfMonth) { + // Computing the Gregorian day checks the valid ranges + chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth); + this.chrono = chrono; - int[] dateInfo = chrono.getHijrahDateInfo(gregorianDay); + this.prolepticYear = prolepticYear; + this.monthOfYear = monthOfYear; + this.dayOfMonth = dayOfMonth; + } - chrono.checkValidYearOfEra(dateInfo[1]); - chrono.checkValidMonth(dateInfo[2]); - chrono.checkValidDayOfMonth(dateInfo[3]); - chrono.checkValidDayOfYear(dateInfo[4]); - - this.era = HijrahEra.of(dateInfo[0]); - this.yearOfEra = dateInfo[1]; - this.monthOfYear = dateInfo[2]; - this.dayOfMonth = dateInfo[3]; - this.dayOfYear = dateInfo[4]; - this.dayOfWeek = DayOfWeek.of(dateInfo[5]); - this.gregorianEpochDay = gregorianDay; - this.isLeapYear = chrono.isLeapYear(this.yearOfEra); + /** + * Constructs an instance with the Epoch Day. + * + * @param epochDay the epochDay + */ + private HijrahDate(HijrahChronology chrono, long epochDay) { + int[] dateInfo = chrono.getHijrahDateInfo((int)epochDay); + + this.chrono = chrono; + this.prolepticYear = dateInfo[0]; + this.monthOfYear = dateInfo[1]; + this.dayOfMonth = dateInfo[2]; } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Hijrah calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Hijrah chronology, not null + */ @Override public HijrahChronology getChronology() { return chrono; } + /** + * Gets the era applicable at this date. + *

    + * The Hijrah calendar system has one era, 'AH', + * defined by {@link HijrahEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public HijrahEra getEra() { + return HijrahEra.AH; + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths in the Hijrah calendar system vary between 29 and 30 days. + * + * @return the length of the month in days + */ + @Override + public int lengthOfMonth() { + return chrono.getMonthLength(prolepticYear, monthOfYear); + } + + /** + * Returns the length of the year represented by this date. + *

    + * This returns the length of the year in days. + * A Hijrah calendar system year is typically shorter than + * that of the ISO calendar system. + * + * @return the length of the year in days + */ + @Override + public int lengthOfYear() { + return chrono.getYearLength(prolepticYear); + } + + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -339,83 +344,106 @@ case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth()); case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear()); case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 5); // TODO - case YEAR_OF_ERA: return ValueRange.of(1, 1000); // TODO + // TODO does the limited range of valid years cause years to + // start/end part way through? that would affect range } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } - @Override // Override for javadoc - public int get(TemporalField field) { - return super.get(field); - } - @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case DAY_OF_WEEK: return dayOfWeek.getValue(); - case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((dayOfWeek.getValue() - 1) % 7) + 1; - case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((dayOfYear - 1) % 7) + 1; + case DAY_OF_WEEK: return getDayOfWeek(); + case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((getDayOfWeek() - 1) % 7) + 1; + case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1; case DAY_OF_MONTH: return this.dayOfMonth; - case DAY_OF_YEAR: return this.dayOfYear; + case DAY_OF_YEAR: return this.getDayOfYear(); case EPOCH_DAY: return toEpochDay(); case ALIGNED_WEEK_OF_MONTH: return ((dayOfMonth - 1) / 7) + 1; - case ALIGNED_WEEK_OF_YEAR: return ((dayOfYear - 1) / 7) + 1; + case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1; case MONTH_OF_YEAR: return monthOfYear; - case YEAR_OF_ERA: return yearOfEra; - case YEAR: return yearOfEra; - case ERA: return era.getValue(); + case PROLEPTIC_MONTH: return getProlepticMonth(); + case YEAR_OF_ERA: return prolepticYear; + case YEAR: return prolepticYear; + case ERA: return getEraValue(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } + private long getProlepticMonth() { + return prolepticYear * 12L + monthOfYear - 1; + } + @Override public HijrahDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - f.checkValidValue(newValue); // TODO: validate value + // not using checkValidIntValue so EPOCH_DAY and PROLEPTIC_MONTH work + chrono.range(f).checkValidValue(newValue, f); // TODO: validate value int nvalue = (int) newValue; switch (f) { - case DAY_OF_WEEK: return plusDays(newValue - dayOfWeek.getValue()); + case DAY_OF_WEEK: return plusDays(newValue - getDayOfWeek()); case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH)); case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR)); - case DAY_OF_MONTH: return resolvePreviousValid(yearOfEra, monthOfYear, nvalue); - case DAY_OF_YEAR: return resolvePreviousValid(yearOfEra, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1); - case EPOCH_DAY: return new HijrahDate(chrono, nvalue); + case DAY_OF_MONTH: return resolvePreviousValid(prolepticYear, monthOfYear, nvalue); + case DAY_OF_YEAR: return resolvePreviousValid(prolepticYear, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1); + case EPOCH_DAY: return new HijrahDate(chrono, newValue); case ALIGNED_WEEK_OF_MONTH: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_MONTH)) * 7); case ALIGNED_WEEK_OF_YEAR: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_YEAR)) * 7); - case MONTH_OF_YEAR: return resolvePreviousValid(yearOfEra, nvalue, dayOfMonth); - case YEAR_OF_ERA: return resolvePreviousValid(yearOfEra >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth); + case MONTH_OF_YEAR: return resolvePreviousValid(prolepticYear, nvalue, dayOfMonth); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); + case YEAR_OF_ERA: return resolvePreviousValid(prolepticYear >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth); case YEAR: return resolvePreviousValid(nvalue, monthOfYear, dayOfMonth); - case ERA: return resolvePreviousValid(1 - yearOfEra, monthOfYear, dayOfMonth); + case ERA: return resolvePreviousValid(1 - prolepticYear, monthOfYear, dayOfMonth); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } - return (HijrahDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } - private HijrahDate resolvePreviousValid(int yearOfEra, int month, int day) { - int monthDays = getMonthDays(month - 1, yearOfEra); + private HijrahDate resolvePreviousValid(int prolepticYear, int month, int day) { + int monthDays = chrono.getMonthLength(prolepticYear, month); if (day > monthDays) { day = monthDays; } - return HijrahDate.of(chrono, yearOfEra, month, day); + return HijrahDate.of(chrono, prolepticYear, month, day); } /** * {@inheritDoc} - * @throws DateTimeException {@inheritDoc} + * @throws DateTimeException if unable to make the adjustment. + * For example, if the adjuster requires an ISO chronology * @throws ArithmeticException {@inheritDoc} */ @Override public HijrahDate with(TemporalAdjuster adjuster) { - return (HijrahDate)super.with(adjuster); + return super.with(adjuster); + } + + /** + * Returns a {@code HijrahDate} with the Chronology requested. + *

    + * The year, month, and day are checked against the new requested + * HijrahChronology. If the chronology has a shorter month length + * for the month, the day is reduced to be the last day of the month. + * + * @param chronology the new HijrahChonology, non-null + * @return a HijrahDate with the requested HijrahChronology, non-null + */ + public HijrahDate withVariant(HijrahChronology chronology) { + if (chrono == chronology) { + return this; + } + // Like resolvePreviousValid the day is constrained to stay in the same month + int monthDays = chronology.getDayOfYear(prolepticYear, monthOfYear); + return HijrahDate.of(chronology, prolepticYear, monthOfYear,(dayOfMonth > monthDays) ? monthDays : dayOfMonth ); } /** @@ -425,7 +453,7 @@ */ @Override public HijrahDate plus(TemporalAmount amount) { - return (HijrahDate)super.plus(amount); + return super.plus(amount); } /** @@ -435,12 +463,42 @@ */ @Override public HijrahDate minus(TemporalAmount amount) { - return (HijrahDate)super.minus(amount); + return super.minus(amount); } @Override public long toEpochDay() { - return chrono.getGregorianEpochDay(yearOfEra, monthOfYear, dayOfMonth); + return chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth); + } + + /** + * Gets the day-of-year field. + *

    + * This method returns the primitive {@code int} value for the day-of-year. + * + * @return the day-of-year + */ + private int getDayOfYear() { + return chrono.getDayOfYear(prolepticYear, monthOfYear); + } + + /** + * Gets the day-of-week value. + * + * @return the day-of-week; computed from the epochday + */ + private int getDayOfWeek() { + int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7); + return dow0 + 1; + } + + /** + * Gets the Era of this date. + * + * @return the Era of this date; computed from epochDay + */ + private int getEraValue() { + return (prolepticYear > 1 ? 1 : 0); } //----------------------------------------------------------------------- @@ -451,7 +509,7 @@ */ @Override public boolean isLeapYear() { - return this.isLeapYear; + return chrono.isLeapYear(prolepticYear); } //----------------------------------------------------------------------- @@ -460,111 +518,72 @@ if (years == 0) { return this; } - int newYear = Math.addExact(this.yearOfEra, (int)years); - return HijrahDate.of(chrono, this.era, newYear, this.monthOfYear, this.dayOfMonth); + int newYear = Math.addExact(this.prolepticYear, (int)years); + return resolvePreviousValid(newYear, monthOfYear, dayOfMonth); } @Override - HijrahDate plusMonths(long months) { - if (months == 0) { + HijrahDate plusMonths(long monthsToAdd) { + if (monthsToAdd == 0) { return this; } - int newMonth = this.monthOfYear - 1; - newMonth = newMonth + (int)months; - int years = newMonth / 12; - newMonth = newMonth % 12; - while (newMonth < 0) { - newMonth += 12; - years = Math.subtractExact(years, 1); - } - int newYear = Math.addExact(this.yearOfEra, years); - return HijrahDate.of(chrono, this.era, newYear, newMonth + 1, this.dayOfMonth); + long monthCount = prolepticYear * 12L + (monthOfYear - 1); + long calcMonths = monthCount + monthsToAdd; // safe overflow + int newYear = chrono.checkValidYear(Math.floorDiv(calcMonths, 12L)); + int newMonth = (int)Math.floorMod(calcMonths, 12L) + 1; + return resolvePreviousValid(newYear, newMonth, dayOfMonth); } @Override HijrahDate plusWeeks(long weeksToAdd) { - return (HijrahDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override HijrahDate plusDays(long days) { - return new HijrahDate(chrono, this.gregorianEpochDay + days); + return new HijrahDate(chrono, toEpochDay() + days); } @Override public HijrahDate plus(long amountToAdd, TemporalUnit unit) { - return (HijrahDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public HijrahDate minus(long amountToSubtract, TemporalUnit unit) { - return (HijrahDate)super.minus(amountToSubtract, unit); + return super.minus(amountToSubtract, unit); } @Override HijrahDate minusYears(long yearsToSubtract) { - return (HijrahDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override HijrahDate minusMonths(long monthsToSubtract) { - return (HijrahDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override HijrahDate minusWeeks(long weeksToSubtract) { - return (HijrahDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override HijrahDate minusDays(long daysToSubtract) { - return (HijrahDate)super.minusDays(daysToSubtract); - } - - /** - * Returns month days from the beginning of year. - * - * @param month month (0-based) - * @parma year year - * @return month days from the beginning of year - */ - private int getMonthDays(int month, int year) { - int[] newMonths = chrono.getAdjustedMonthDays(year); - return newMonths[month]; - } - - /** - * Returns month length. - * - * @param month month (0-based) - * @param year year - * @return month length - */ - private int getMonthLength(int month, int year) { - int[] newMonths = chrono.getAdjustedMonthLength(year); - return newMonths[month]; - } - - @Override - public int lengthOfMonth() { - return getMonthLength(monthOfYear - 1, yearOfEra); - } - - @Override - public int lengthOfYear() { - return chrono.getYearLength(yearOfEra); // TODO: proleptic year + return super.minusDays(daysToSubtract); } @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override public Period periodUntil(ChronoLocalDate endDate) { // TODO: untested - HijrahDate end = (HijrahDate) getChronology().date(endDate); - long totalMonths = (end.yearOfEra - this.yearOfEra) * 12 + (end.monthOfYear - this.monthOfYear); // safe + HijrahDate end = getChronology().date(endDate); + long totalMonths = (end.prolepticYear - this.prolepticYear) * 12 + (end.monthOfYear - this.monthOfYear); // safe int days = end.dayOfMonth - this.dayOfMonth; if (totalMonths > 0 && days < 0) { totalMonths--; @@ -604,7 +623,7 @@ } static ChronoLocalDate readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - HijrahChronology chrono = (HijrahChronology)in.readObject(); + HijrahChronology chrono = (HijrahChronology) in.readObject(); int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); --- old/src/share/classes/java/time/chrono/HijrahEra.java 2013-04-11 23:15:35.000000000 -0700 +++ new/src/share/classes/java/time/chrono/HijrahEra.java 2013-04-11 23:15:34.000000000 -0700 @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,16 +61,22 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ERA; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.time.DateTimeException; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; /** * An era in the Hijrah calendar system. *

    - * The Hijrah calendar system has two eras. - * The date {@code 0001-01-01 (Hijrah)} is {@code 622-06-19 (ISO)}. + * The Hijrah calendar system has only one era covering the + * proleptic years greater than zero. *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}. * Use {@code getValue()} instead. @@ -75,80 +86,76 @@ * * @since 1.8 */ -enum HijrahEra implements Era { +public enum HijrahEra implements Era { /** - * The singleton instance for the era before the current one, 'Before Anno Hegirae', - * which has the value 0. - */ - BEFORE_AH, - /** - * The singleton instance for the current era, 'Anno Hegirae', which has the value 1. + * The singleton instance for the current era, 'Anno Hegirae', + * which has the numeric value 1. */ AH; //----------------------------------------------------------------------- /** - * Obtains an instance of {@code HijrahEra} from a value. + * Obtains an instance of {@code HijrahEra} from an {@code int} value. *

    - * The current era (from ISO date 622-06-19 onwards) has the value 1 - * The previous era has the value 0. + * The current era, which is the only accepted value, has the value 1 * - * @param hijrahEra the era to represent, from 0 to 1 - * @return the HijrahEra singleton, never null - * @throws DateTimeException if the era is invalid + * @param hijrahEra the era to represent, only 1 supported + * @return the HijrahEra.AH singleton, not null + * @throws DateTimeException if the value is invalid */ public static HijrahEra of(int hijrahEra) { - switch (hijrahEra) { - case 0: - return BEFORE_AH; - case 1: - return AH; - default: - throw new DateTimeException("HijrahEra not valid"); + if (hijrahEra == 1 ) { + return AH; + } else { + throw new DateTimeException("Invalid era: " + hijrahEra); } } //----------------------------------------------------------------------- /** - * Gets the era numeric value. + * Gets the numeric era {@code int} value. *

    - * The current era (from ISO date 622-06-19 onwards) has the value 1. - * The previous era has the value 0. + * The era AH has the value 1. * - * @return the era value, from 0 (BEFORE_AH) to 1 (AH) + * @return the era value, 1 (AH) */ @Override public int getValue() { - return ordinal(); + return 1; } - @Override - public HijrahChronology getChronology() { - return HijrahChronology.INSTANCE; - } - - // JDK8 default methods: //----------------------------------------------------------------------- - @Override - public HijrahDate date(int year, int month, int day) { - return (HijrahDate)(getChronology().date(this, year, month, day)); - } - - @Override - public HijrahDate dateYearDay(int year, int dayOfYear) { - return (HijrahDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - - //------------------------------------------------------------------------- /** - * Returns the proleptic year from this era and year of era. + * Gets the range of valid values for the specified field. + *

    + * The range object expresses the minimum and maximum valid values for a field. + * This era is used to enhance the accuracy of the returned range. + * If it is not possible to return the range, because the field is not supported + * or for some other reason, an exception is thrown. + *

    + * If the field is a {@link ChronoField} then the query is implemented here. + * The {@code ERA} field returns the range. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. + *

    + * If the field is not a {@code ChronoField}, then the result of this method + * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} + * passing {@code this} as the argument. + * Whether the range can be obtained is determined by the field. + *

    + * The {@code ERA} field returns a range for the one valid Hijrah era. * - * @param yearOfEra the year of Era - * @return the computed prolepticYear + * @param field the field to query the range for, not null + * @return the range of valid values for the field, not null + * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported */ - int prolepticYear(int yearOfEra) { - return (this == HijrahEra.AH ? yearOfEra : 1 - yearOfEra); + @Override // override as super would return range from 0 to 1 + public ValueRange range(TemporalField field) { + if (field == ERA) { + return ValueRange.of(1, 1); + } + return Era.super.range(field); } //----------------------------------------------------------------------- --- old/src/share/classes/java/time/chrono/IsoChronology.java 2013-04-11 23:15:35.000000000 -0700 +++ new/src/share/classes/java/time/chrono/IsoChronology.java 2013-04-11 23:15:35.000000000 -0700 @@ -61,20 +61,41 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.TemporalAdjuster.nextOrSame; + import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; +import java.time.Year; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; /** @@ -111,20 +132,6 @@ * Singleton instance of the ISO chronology. */ public static final IsoChronology INSTANCE = new IsoChronology(); - /** - * The singleton instance for the era BCE - 'Before Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the BCE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 0}. - */ - public static final Era ERA_BCE = IsoEra.BCE; - /** - * The singleton instance for the era CE - 'Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the CE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 1}. - */ - public static final Era ERA_CE = IsoEra.CE; /** * Serialization version. @@ -137,15 +144,6 @@ private IsoChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ISO'. @@ -189,6 +187,7 @@ * @param dayOfMonth the ISO day-of-month * @return the ISO local date, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the type of {@code era} is not {@code IsoEra} */ @Override // override with covariant return type public LocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { @@ -241,6 +240,20 @@ return LocalDate.ofYearDay(prolepticYear, dayOfYear); } + /** + * Obtains an ISO local date from the epoch-day. + *

    + * This is equivalent to {@link LocalDate#ofEpochDay(long)}. + * + * @param epochDay the epoch day + * @return the ISO local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public LocalDate dateEpochDay(long epochDay) { + return LocalDate.ofEpochDay(epochDay); + } + //----------------------------------------------------------------------- /** * Obtains an ISO local date from another date-time object. @@ -379,7 +392,7 @@ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof IsoEra == false) { - throw new DateTimeException("Era must be IsoEra"); + throw new ClassCastException("Era must be IsoEra"); } return (era == IsoEra.CE ? yearOfEra : 1 - yearOfEra); } @@ -395,6 +408,282 @@ } //----------------------------------------------------------------------- + /** + * Resolves parsed {@code ChronoField} values into a date during parsing. + *

    + * Most {@code TemporalField} implementations are resolved using the + * resolve method on the field. By contrast, the {@code ChronoField} class + * defines fields that only have meaning relative to the chronology. + * As such, {@code ChronoField} date fields are resolved here in the + * context of a specific chronology. + *

    + * {@code ChronoField} instances on the ISO calendar system are resolved + * as follows. + *

      + *
    • {@code EPOCH_DAY} - If present, this is converted to a {@code LocalDate} + * all other date fields are then cross-checked against the date + *
    • {@code PROLEPTIC_MONTH} - If present, then it is split into the + * {@code YEAR} and {@code MONTH_OF_YEAR}. If the mode is strict or smart + * then the field is validated. + *
    • {@code YEAR_OF_ERA} and {@code ERA} - If both are present, then they + * are combined to form a {@code YEAR}. In lenient mode, the {@code YEAR_OF_ERA} + * range is not validated, in smart and strict mode it is. The {@code ERA} is + * validated for range in all three modes. If only the {@code YEAR_OF_ERA} is + * present, and the mode is smart or lenient, then the current era (CE/AD) + * is assumed. In strict mode, no ers is assumed and the {@code YEAR_OF_ERA} is + * left untouched. If only the {@code ERA} is present, then it is left untouched. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. If the mode is smart or strict, + * then the month and day are validated, with the day validated from 1 to 31. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in months, then the difference in days. + * If the mode is smart, and the day-of-month is greater than the maximum for + * the year-month, then the day-of-month is adjusted to the last day-of-month. + * If the mode is strict, then the three fields must form a valid date. + *
    • {@code YEAR} and {@code DAY_OF_YEAR} - + * If both are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in days. + * If the mode is smart or strict, then the two fields must form a valid date. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR}, {@code ALIGNED_WEEK_OF_MONTH} and + * {@code ALIGNED_DAY_OF_WEEK_IN_MONTH} - + * If all four are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in months, then the difference in weeks, then in days. + * If the mode is smart or strict, then the all four fields are validated to + * their outer ranges. The date is then combined in a manner equivalent to + * creating a date on the first day of the requested year and month, then adding + * the amount in weeks and days to reach their values. If the mode is strict, + * the date is additionally validated to check that the day and week adjustment + * did not change the month. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR}, {@code ALIGNED_WEEK_OF_MONTH} and + * {@code DAY_OF_WEEK} - If all four are present, then they are combined to + * form a {@code LocalDate}. The approach is the same as described above for + * years, months and weeks in {@code ALIGNED_DAY_OF_WEEK_IN_MONTH}. + * The day-of-week is adjusted as the next or same matching day-of-week once + * the years, months and weeks have been handled. + *
    • {@code YEAR}, {@code ALIGNED_WEEK_OF_YEAR} and {@code ALIGNED_DAY_OF_WEEK_IN_YEAR} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in weeks, then in days. + * If the mode is smart or strict, then the all three fields are validated to + * their outer ranges. The date is then combined in a manner equivalent to + * creating a date on the first day of the requested year, then adding + * the amount in weeks and days to reach their values. If the mode is strict, + * the date is additionally validated to check that the day and week adjustment + * did not change the year. + *
    • {@code YEAR}, {@code ALIGNED_WEEK_OF_YEAR} and {@code DAY_OF_WEEK} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * The approach is the same as described above for years and weeks in + * {@code ALIGNED_DAY_OF_WEEK_IN_YEAR}. The day-of-week is adjusted as the + * next or same matching day-of-week once the years and weeks have been handled. + *
    + * + * @param fieldValues the map of fields to values, which can be updated, not null + * @param resolverStyle the requested type of resolve, not null + * @return the resolved date, null if insufficient information to create a date + * @throws DateTimeException if the date cannot be resolved, typically + * because of a conflict in the input data + */ + @Override // override for performance + public LocalDate resolveDate(Map fieldValues, ResolverStyle resolverStyle) { + // check epoch-day before inventing era + if (fieldValues.containsKey(EPOCH_DAY)) { + return LocalDate.ofEpochDay(fieldValues.remove(EPOCH_DAY)); + } + + // fix proleptic month before inventing era + resolveProlepticMonth(fieldValues, resolverStyle); + + // invent era if necessary to resolve year-of-era + resolveYearOfEra(fieldValues, resolverStyle); + + // build date + if (fieldValues.containsKey(YEAR)) { + if (fieldValues.containsKey(MONTH_OF_YEAR)) { + if (fieldValues.containsKey(DAY_OF_MONTH)) { + return resolveYMD(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_MONTH)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { + return resolveYMAA(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + return resolveYMAD(fieldValues, resolverStyle); + } + } + } + if (fieldValues.containsKey(DAY_OF_YEAR)) { + return resolveYD(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_YEAR)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { + return resolveYAA(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + return resolveYAD(fieldValues, resolverStyle); + } + } + } + return null; + } + + private void resolveProlepticMonth(Map fieldValues, ResolverStyle resolverStyle) { + Long pMonth = fieldValues.remove(PROLEPTIC_MONTH); + if (pMonth != null) { + if (resolverStyle != ResolverStyle.LENIENT) { + PROLEPTIC_MONTH.checkValidValue(pMonth); + } + addFieldValue(fieldValues, MONTH_OF_YEAR, Math.floorMod(pMonth, 12) + 1); + addFieldValue(fieldValues, YEAR, Math.floorDiv(pMonth, 12)); + } + } + + private void resolveYearOfEra(Map fieldValues, ResolverStyle resolverStyle) { + Long yoeLong = fieldValues.remove(YEAR_OF_ERA); + if (yoeLong != null) { + if (resolverStyle != ResolverStyle.LENIENT) { + YEAR_OF_ERA.checkValidValue(yoeLong); + } + Long era = fieldValues.remove(ERA); + if (era == null) { + Long year = fieldValues.get(YEAR); + if (resolverStyle == ResolverStyle.STRICT) { + // do not invent era if strict, but do cross-check with year + if (year != null) { + addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong))); + } else { + // reinstate the field removed earlier, no cross-check issues + fieldValues.put(YEAR_OF_ERA, yoeLong); + } + } else { + // invent era + addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong))); + } + } else if (era.longValue() == 1L) { + addFieldValue(fieldValues, YEAR, yoeLong); + } else if (era.longValue() == 0L) { + addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong)); + } else { + throw new DateTimeException("Invalid value for era: " + era); + } + } + } + + private LocalDate resolveYMD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long days = Math.subtractExact(fieldValues.remove(DAY_OF_MONTH), 1); + return LocalDate.of(y, 1, 1).plusMonths(months).plusDays(days); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int dom = DAY_OF_MONTH.checkValidIntValue(fieldValues.remove(DAY_OF_MONTH)); + if (resolverStyle == ResolverStyle.SMART) { // previous valid + dom = Math.min(dom, Month.of(moy).length(Year.isLeap(y))); + } + return LocalDate.of(y, moy, dom); + } + + private LocalDate resolveYD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR), 1); + return LocalDate.of(y, 1, 1).plusDays(days); + } + int doy = DAY_OF_YEAR.checkValidIntValue(fieldValues.remove(DAY_OF_YEAR)); + return LocalDate.ofYearDay(y, doy); // smart is same as strict + } + + private LocalDate resolveYMAA(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); + long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1); + return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); + int ad = ALIGNED_DAY_OF_WEEK_IN_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH)); + LocalDate date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7 + (ad - 1)); + if (resolverStyle == ResolverStyle.STRICT && date.getMonthValue() != moy) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different month"); + } + return date; + } + + private LocalDate resolveYMAD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); + long dow = Math.subtractExact(fieldValues.remove(DAY_OF_WEEK), 1); + return resolveAligned(y, months, weeks, dow); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); + int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); + LocalDate date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); + if (resolverStyle == ResolverStyle.STRICT && date.getMonthValue() != moy) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different month"); + } + return date; + } + + private LocalDate resolveYAA(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1); + long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1); + return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days); + } + int aw = ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR)); + int ad = ALIGNED_DAY_OF_WEEK_IN_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR)); + LocalDate date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7 + (ad - 1)); + if (resolverStyle == ResolverStyle.STRICT && date.getYear() != y) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different year"); + } + return date; + } + + private LocalDate resolveYAD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1); + long dow = Math.subtractExact(fieldValues.remove(DAY_OF_WEEK), 1); + return resolveAligned(y, 0, weeks, dow); + } + int aw = ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR)); + int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); + LocalDate date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); + if (resolverStyle == ResolverStyle.STRICT && date.getYear() != y) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different year"); + } + return date; + } + + private LocalDate resolveAligned(int y, long months, long weeks, long dow) { + LocalDate date = LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks); + if (dow > 7) { + date = date.plusWeeks((dow - 1) / 7); + dow = ((dow - 1) % 7) + 1; + } else if (dow < 1) { + date = date.plusWeeks(Math.subtractExact(dow, 7) / 7); + dow = ((dow + 6) % 7) + 1; + } + return date.with(nextOrSame(DayOfWeek.of((int) dow))); + } + + //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) { return field.range(); --- old/src/share/classes/java/time/chrono/IsoEra.java 2013-04-11 23:15:36.000000000 -0700 +++ new/src/share/classes/java/time/chrono/IsoEra.java 2013-04-11 23:15:36.000000000 -0700 @@ -61,16 +61,38 @@ */ package java.time.chrono; - import java.time.DateTimeException; -import java.time.LocalDate; /** * An era in the ISO calendar system. *

    * The ISO-8601 standard does not define eras. * A definition has therefore been created with two eras - 'Current era' (CE) for - * years from 0001-01-01 (ISO) and 'Before current era' (BCE) for years before that. + * years on or after 0001-01-01 (ISO), and 'Before current era' (BCE) for years before that. + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-year
    2CE2
    1CE1
    1BCE0
    2BCE-1
    *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code IsoEra}. * Use {@code getValue()} instead. @@ -80,20 +102,16 @@ * * @since 1.8 */ -enum IsoEra implements Era { +public enum IsoEra implements Era { /** - * The singleton instance for the era BCE, 'Before Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the BCE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 0}. + * The singleton instance for the era before the current one, 'Before Current Era', + * which has the numeric value 0. */ BCE, /** - * The singleton instance for the era CE, 'Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the CE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 1}. + * The singleton instance for the current era, 'Current Era', + * which has the numeric value 1. */ CE; @@ -104,18 +122,18 @@ * {@code IsoEra} is an enum representing the ISO eras of BCE/CE. * This factory allows the enum to be obtained from the {@code int} value. * - * @param era the BCE/CE value to represent, from 0 (BCE) to 1 (CE) + * @param isoEra the BCE/CE value to represent, from 0 (BCE) to 1 (CE) * @return the era singleton, not null * @throws DateTimeException if the value is invalid */ - public static IsoEra of(int era) { - switch (era) { + public static IsoEra of(int isoEra) { + switch (isoEra) { case 0: return BCE; case 1: return CE; default: - throw new DateTimeException("Invalid era: " + era); + throw new DateTimeException("Invalid era: " + isoEra); } } @@ -132,21 +150,4 @@ return ordinal(); } - @Override - public IsoChronology getChronology() { - return IsoChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public LocalDate date(int year, int month, int day) { - return getChronology().date(this, year, month, day); - } - - @Override - public LocalDate dateYearDay(int year, int dayOfYear) { - return getChronology().dateYearDay(this, year, dayOfYear); - } - } --- old/src/share/classes/java/time/chrono/JapaneseChronology.java 2013-04-11 23:15:37.000000000 -0700 +++ new/src/share/classes/java/time/chrono/JapaneseChronology.java 2013-04-11 23:15:36.000000000 -0700 @@ -61,11 +61,11 @@ import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; +import java.time.Year; +import java.time.ZoneId; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.ValueRange; -import java.time.Year; -import java.time.ZoneId; import java.util.Arrays; import java.util.Calendar; import java.util.List; @@ -105,31 +105,6 @@ public static final JapaneseChronology INSTANCE = new JapaneseChronology(); /** - * The singleton instance for the before Meiji era ( - 1868-09-07) - * which has the value -999. - */ - public static final Era ERA_SEIREKI = JapaneseEra.SEIREKI; - /** - * The singleton instance for the Meiji era (1868-09-08 - 1912-07-29) - * which has the value -1. - */ - public static final Era ERA_MEIJI = JapaneseEra.MEIJI; - /** - * The singleton instance for the Taisho era (1912-07-30 - 1926-12-24) - * which has the value 0. - */ - public static final Era ERA_TAISHO = JapaneseEra.TAISHO; - /** - * The singleton instance for the Showa era (1926-12-25 - 1989-01-07) - * which has the value 1. - */ - public static final Era ERA_SHOWA = JapaneseEra.SHOWA; - /** - * The singleton instance for the Heisei era (1989-01-08 - current) - * which has the value 2. - */ - public static final Era ERA_HEISEI = JapaneseEra.HEISEI; - /** * Serialization version. */ private static final long serialVersionUID = 459996390165777884L; @@ -141,15 +116,6 @@ private JapaneseChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'Japanese'. @@ -183,36 +149,82 @@ } //----------------------------------------------------------------------- + /** + * Obtains a local date in Japanese calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Japanese era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code JapaneseEra} + */ @Override public JapaneseDate date(Era era, int yearOfEra, int month, int dayOfMonth) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } return JapaneseDate.of((JapaneseEra) era, yearOfEra, month, dayOfMonth); } + /** + * Obtains a local date in Japanese calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); } + /** + * Obtains a local date in Japanese calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Japanese era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code JapaneseEra} + */ @Override - public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { - LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); - return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); + public JapaneseDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } + /** + * Obtains a local date in Japanese calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ @Override - public JapaneseDate date(TemporalAccessor temporal) { - if (temporal instanceof JapaneseDate) { - return (JapaneseDate) temporal; - } - return new JapaneseDate(LocalDate.from(temporal)); + public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { + LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); + return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); } - @Override - public JapaneseDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Japanese calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public JapaneseDate dateEpochDay(long epochDay) { + return new JapaneseDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -231,6 +243,14 @@ } @Override + public JapaneseDate date(TemporalAccessor temporal) { + if (temporal instanceof JapaneseDate) { + return (JapaneseDate) temporal; + } + return new JapaneseDate(LocalDate.from(temporal)); + } + + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); } @@ -264,7 +284,7 @@ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } JapaneseEra jera = (JapaneseEra) era; int gregorianYear = jera.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1; @@ -273,20 +293,23 @@ } LocalGregorianCalendar.Date jdate = JCAL.newCalendarDate(null); jdate.setEra(jera.getPrivateEra()).setDate(yearOfEra, 1, 1); + if (!JapaneseChronology.JCAL.validate(jdate)) { + throw new DateTimeException("Invalid yearOfEra value"); + } JCAL.normalize(jdate); if (jdate.getNormalizedYear() == gregorianYear) { return gregorianYear; } - throw new DateTimeException("invalid yearOfEra value"); + throw new DateTimeException("Invalid yearOfEra value"); } /** * Returns the calendar system era object from the given numeric value. * * See the description of each Era for the numeric values of: - * {@link #ERA_HEISEI}, {@link #ERA_SHOWA},{@link #ERA_TAISHO}, - * {@link #ERA_MEIJI}), only Meiji and later eras are supported. - * Prior to Meiji {@link #ERA_SEIREKI} is used. + * {@link JapaneseEra#HEISEI}, {@link JapaneseEra#SHOWA},{@link JapaneseEra#TAISHO}, + * {@link JapaneseEra#MEIJI}), only Meiji and later eras are supported. + * Prior to Meiji {@link JapaneseEra#SEIREKI} is used. * * @param eraValue the era value * @return the Japanese {@code Era} for the given numeric era value @@ -299,7 +322,7 @@ @Override public List eras() { - return Arrays.asList(JapaneseEra.values()); + return Arrays.asList(JapaneseEra.values()); } //----------------------------------------------------------------------- @@ -322,20 +345,24 @@ case NANO_OF_SECOND: case CLOCK_HOUR_OF_DAY: case CLOCK_HOUR_OF_AMPM: - case EPOCH_DAY: - case EPOCH_MONTH: + case EPOCH_DAY: // TODO: if year is restricted, then so is epoch-day return field.range(); } Calendar jcal = Calendar.getInstance(LOCALE); int fieldIndex; switch (field) { case ERA: - return ValueRange.of(jcal.getMinimum(Calendar.ERA) - JapaneseEra.ERA_OFFSET, + return ValueRange.of(JapaneseEra.SEIREKI.getValue(), jcal.getMaximum(Calendar.ERA) - JapaneseEra.ERA_OFFSET); case YEAR: case YEAR_OF_ERA: + // TODO: this is not right return ValueRange.of(Year.MIN_VALUE, jcal.getGreatestMinimum(Calendar.YEAR), jcal.getLeastMaximum(Calendar.YEAR), Year.MAX_VALUE); + case PROLEPTIC_MONTH: + // TODO: should be the range of months bound by the valid range of years + return ValueRange.of((jcal.getGreatestMinimum(Calendar.YEAR) - 1) * 12, + (jcal.getLeastMaximum(Calendar.YEAR)) * 12); case MONTH_OF_YEAR: return ValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1, jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1); --- old/src/share/classes/java/time/chrono/JapaneseDate.java 2013-04-11 23:15:37.000000000 -0700 +++ new/src/share/classes/java/time/chrono/JapaneseDate.java 2013-04-11 23:15:37.000000000 -0700 @@ -69,14 +69,16 @@ import java.time.LocalDate; import java.time.LocalTime; import java.time.Period; +import java.time.Year; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Calendar; import java.util.Objects; @@ -191,7 +193,7 @@ */ public static JapaneseDate of(Era era, int yearOfEra, int month, int dayOfMonth) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } return JapaneseDate.of((JapaneseEra) era, yearOfEra, month, dayOfMonth); } @@ -252,7 +254,7 @@ LocalGregorianCalendar.Date jdate = JapaneseChronology.JCAL.newCalendarDate(null); jdate.setEra(era.getPrivateEra()).setDate(yearOfEra, month, dayOfMonth); if (!JapaneseChronology.JCAL.validate(jdate)) { - throw new IllegalArgumentException(); + throw new DateTimeException("year, month, and day not valid for Era"); } LocalDate date = LocalDate.of(jdate.getNormalizedYear(), month, dayOfMonth); return new JapaneseDate(era, yearOfEra, date); @@ -307,22 +309,54 @@ } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Japanese calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Japanese chronology, not null + */ @Override public JapaneseChronology getChronology() { return JapaneseChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Japanese calendar system has multiple eras defined by {@link JapaneseEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public JapaneseEra getEra() { + return era; + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { ChronoField f = (ChronoField) field; switch (f) { + case DAY_OF_MONTH: + case ALIGNED_WEEK_OF_MONTH: + return isoDate.range(field); case DAY_OF_YEAR: return actualRange(Calendar.DAY_OF_YEAR); case YEAR_OF_ERA: @@ -330,14 +364,14 @@ } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); - jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); + jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); // TODO: cannot calculate this way for SEIREKI jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); @@ -346,6 +380,12 @@ @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { + // same as ISO: + // DAY_OF_WEEK, ALIGNED_DAY_OF_WEEK_IN_MONTH, DAY_OF_MONTH, EPOCH_DAY, + // ALIGNED_WEEK_OF_MONTH, MONTH_OF_YEAR, PROLEPTIC_MONTH, YEAR + // + // calendar specific fields + // ALIGNED_DAY_OF_WEEK_IN_YEAR, DAY_OF_YEAR, ALIGNED_WEEK_OF_YEAR, YEAR_OF_ERA, ERA switch ((ChronoField) field) { case YEAR_OF_ERA: return yearOfEra; @@ -355,8 +395,8 @@ LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate); return JapaneseChronology.JCAL.getDayOfYear(jdate); } + // TODO: ALIGNED_DAY_OF_WEEK_IN_YEAR and ALIGNED_WEEK_OF_YEAR ??? } - // TODO: review other fields return isoDate.getLong(field); } return field.getFrom(this); @@ -392,8 +432,7 @@ case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return this.withYear(nvalue); @@ -405,15 +444,11 @@ } } } + // YEAR, PROLEPTIC_MONTH and others are same as ISO // TODO: review other fields, such as WEEK_OF_YEAR return with(isoDate.with(field, newValue)); } - return (JapaneseDate) ChronoLocalDate.super.with(field, newValue); - } - - @Override - public Era getEra() { - return era; + return ChronoLocalDate.super.with(field, newValue); } /** @@ -423,7 +458,7 @@ */ @Override public JapaneseDate with(TemporalAdjuster adjuster) { - return (JapaneseDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -433,7 +468,7 @@ */ @Override public JapaneseDate plus(TemporalAmount amount) { - return (JapaneseDate)super.plus(amount); + return super.plus(amount); } /** @@ -443,7 +478,7 @@ */ @Override public JapaneseDate minus(TemporalAmount amount) { - return (JapaneseDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- /** @@ -479,7 +514,7 @@ * @throws DateTimeException if {@code year} is invalid */ private JapaneseDate withYear(int year) { - return withYear((JapaneseEra) getEra(), year); + return withYear(getEra(), year); } //----------------------------------------------------------------------- @@ -505,32 +540,32 @@ @Override public JapaneseDate plus(long amountToAdd, TemporalUnit unit) { - return (JapaneseDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public JapaneseDate minus(long amountToAdd, TemporalUnit unit) { - return (JapaneseDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override JapaneseDate minusYears(long yearsToSubtract) { - return (JapaneseDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override JapaneseDate minusMonths(long monthsToSubtract) { - return (JapaneseDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override JapaneseDate minusWeeks(long weeksToSubtract) { - return (JapaneseDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override JapaneseDate minusDays(long daysToSubtract) { - return (JapaneseDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private JapaneseDate with(LocalDate newDate) { @@ -539,7 +574,7 @@ @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override --- old/src/share/classes/java/time/chrono/JapaneseEra.java 2013-04-11 23:15:38.000000000 -0700 +++ new/src/share/classes/java/time/chrono/JapaneseEra.java 2013-04-11 23:15:38.000000000 -0700 @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,6 +61,8 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ERA; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -64,7 +71,12 @@ import java.io.Serializable; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; import java.util.Arrays; +import java.util.Objects; import sun.util.calendar.CalendarDate; @@ -84,7 +96,7 @@ * * @since 1.8 */ -final class JapaneseEra +public final class JapaneseEra implements Era, Serializable { // The offset value to 0-based index from the era value. @@ -202,7 +214,7 @@ //----------------------------------------------------------------------- /** - * Obtains an instance of {@code JapaneseEra} from a value. + * Obtains an instance of {@code JapaneseEra} from an {@code int} value. *

    * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1 * Later era is numbered 2 ({@link #HEISEI}). Earlier eras are numbered 0 ({@link #TAISHO}), @@ -210,22 +222,49 @@ * {@link #SEIREKI} is used. * * @param japaneseEra the era to represent - * @return the {@code JapaneseEra} singleton, never null - * @throws DateTimeException if {@code japaneseEra} is invalid + * @return the {@code JapaneseEra} singleton, not null + * @throws DateTimeException if the value is invalid */ public static JapaneseEra of(int japaneseEra) { if (japaneseEra != SEIREKI.eraValue && (japaneseEra < MEIJI.eraValue || japaneseEra > HEISEI.eraValue)) { - throw new DateTimeException("japaneseEra is invalid"); + throw new DateTimeException("Invalid era: " + japaneseEra); } return KNOWN_ERAS[ordinal(japaneseEra)]; } /** + * Returns the {@code JapaneseEra} with the name. + *

    + * The string must match exactly the name of the era. + * (Extraneous whitespace characters are not permitted.) + * + * @param japaneseEra the japaneseEra name; non-null + * @return the {@code JapaneseEra} singleton, never null + * @throws IllegalArgumentException if there is not JapaneseEra with the specified name + */ + public static JapaneseEra valueOf(String japaneseEra) { + Objects.requireNonNull(japaneseEra, "japaneseEra"); + for (JapaneseEra era : KNOWN_ERAS) { + if (era.getName().equals(japaneseEra)) { + return era; + } + } + throw new IllegalArgumentException("japaneseEra is invalid"); + } + + /** * Returns an array of JapaneseEras. + *

    + * This method may be used to iterate over the JapaneseEras as follows: + *

    +     * for (JapaneseEra c : JapaneseEra.values())
    +     *     System.out.println(c);
    +     * 
    + * * @return an array of JapaneseEras */ - static JapaneseEra[] values() { + public static JapaneseEra[] values() { return Arrays.copyOf(KNOWN_ERAS, KNOWN_ERAS.length); } @@ -268,16 +307,17 @@ /** * Returns the index into the arrays from the Era value. * the eraValue is a valid Era number, -999, -1..2. - * @param eravalue the era value to convert to the index + * + * @param eraValue the era value to convert to the index * @return the index of the current Era */ - private static int ordinal(int eravalue) { - return (eravalue == SEIREKI.eraValue) ? 0 : eravalue + ERA_OFFSET; + private static int ordinal(int eraValue) { + return (eraValue == SEIREKI.eraValue) ? 0 : eraValue + ERA_OFFSET; } //----------------------------------------------------------------------- /** - * Returns the numeric value of this {@code JapaneseEra}. + * Gets the numeric era {@code int} value. *

    * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1. * Later eras are numbered from 2 ({@link #HEISEI}). @@ -290,9 +330,38 @@ return eraValue; } - @Override - public JapaneseChronology getChronology() { - return JapaneseChronology.INSTANCE; + //----------------------------------------------------------------------- + /** + * Gets the range of valid values for the specified field. + *

    + * The range object expresses the minimum and maximum valid values for a field. + * This era is used to enhance the accuracy of the returned range. + * If it is not possible to return the range, because the field is not supported + * or for some other reason, an exception is thrown. + *

    + * If the field is a {@link ChronoField} then the query is implemented here. + * The {@code ERA} field returns the range. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. + *

    + * If the field is not a {@code ChronoField}, then the result of this method + * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} + * passing {@code this} as the argument. + * Whether the range can be obtained is determined by the field. + *

    + * The range of valid Japanese eras can change over time due to the nature + * of the Japanese calendar system. + * + * @param field the field to query the range for, not null + * @return the range of valid values for the field, not null + * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported + */ + @Override // override as super would return range from 0 to 1 + public ValueRange range(TemporalField field) { + if (field == ERA) { + return JapaneseChronology.INSTANCE.range(ERA); + } + return Era.super.range(field); } //----------------------------------------------------------------------- --- old/src/share/classes/java/time/chrono/MinguoChronology.java 2013-04-11 23:15:39.000000000 -0700 +++ new/src/share/classes/java/time/chrono/MinguoChronology.java 2013-04-11 23:15:39.000000000 -0700 @@ -56,6 +56,7 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.Serializable; @@ -107,16 +108,6 @@ public static final MinguoChronology INSTANCE = new MinguoChronology(); /** - * The singleton instance for the era ROC. - */ - public static final Era ERA_ROC = MinguoEra.ROC; - - /** - * The singleton instance for the era BEFORE_ROC. - */ - public static final Era ERA_BEFORE_ROC = MinguoEra.BEFORE_ROC; - - /** * Serialization version. */ private static final long serialVersionUID = 1039765215346859963L; @@ -131,15 +122,6 @@ private MinguoChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'Minguo'. @@ -173,32 +155,78 @@ } //----------------------------------------------------------------------- + /** + * Obtains a local date in Minguo calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Minguo era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code MinguoEra} + */ @Override - public MinguoDate date(int prolepticYear, int month, int dayOfMonth) { - return new MinguoDate(LocalDate.of(prolepticYear + YEARS_DIFFERENCE, month, dayOfMonth)); + public MinguoDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } + /** + * Obtains a local date in Minguo calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ @Override - public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { - return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); + public MinguoDate date(int prolepticYear, int month, int dayOfMonth) { + return new MinguoDate(LocalDate.of(prolepticYear + YEARS_DIFFERENCE, month, dayOfMonth)); } + /** + * Obtains a local date in Minguo calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Minguo era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code MinguoEra} + */ @Override - public MinguoDate date(TemporalAccessor temporal) { - if (temporal instanceof MinguoDate) { - return (MinguoDate) temporal; - } - return new MinguoDate(LocalDate.from(temporal)); + public MinguoDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } - @Override - public MinguoDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); + /** + * Obtains a local date in Minguo calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override + public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { + return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); } - @Override - public MinguoDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Minguo calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public MinguoDate dateEpochDay(long epochDay) { + return new MinguoDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -217,6 +245,14 @@ } @Override + public MinguoDate date(TemporalAccessor temporal) { + if (temporal instanceof MinguoDate) { + return (MinguoDate) temporal; + } + return new MinguoDate(LocalDate.from(temporal)); + } + + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); } @@ -250,7 +286,7 @@ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof MinguoEra == false) { - throw new DateTimeException("Era must be MinguoEra"); + throw new ClassCastException("Era must be MinguoEra"); } return (era == MinguoEra.ROC ? yearOfEra : 1 - yearOfEra); } @@ -269,6 +305,10 @@ @Override public ValueRange range(ChronoField field) { switch (field) { + case PROLEPTIC_MONTH: { + ValueRange range = PROLEPTIC_MONTH.range(); + return ValueRange.of(range.getMinimum() - YEARS_DIFFERENCE * 12L, range.getMaximum() - YEARS_DIFFERENCE * 12L); + } case YEAR_OF_ERA: { ValueRange range = YEAR.range(); return ValueRange.of(1, range.getMaximum() - YEARS_DIFFERENCE, -range.getMinimum() + 1 + YEARS_DIFFERENCE); --- old/src/share/classes/java/time/chrono/MinguoDate.java 2013-04-11 23:15:40.000000000 -0700 +++ new/src/share/classes/java/time/chrono/MinguoDate.java 2013-04-11 23:15:39.000000000 -0700 @@ -72,12 +72,13 @@ import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -205,16 +206,46 @@ } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Minguo calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Minguo chronology, not null + */ @Override public MinguoChronology getChronology() { return MinguoChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Minguo calendar system has two eras, 'ROC' and 'BEFORE_ROC', + * defined by {@link MinguoEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public MinguoEra getEra() { + return (getProlepticYear() >= 1 ? MinguoEra.ROC : MinguoEra.BEFORE_ROC); + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -233,7 +264,7 @@ } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -242,6 +273,8 @@ public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { + case PROLEPTIC_MONTH: + return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); @@ -256,6 +289,10 @@ return field.getFrom(this); } + private long getProlepticMonth() { + return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; + } + private int getProlepticYear() { return isoDate.getYear() - YEARS_DIFFERENCE; } @@ -269,11 +306,13 @@ return this; } switch (f) { + case PROLEPTIC_MONTH: + getChronology().range(f).checkValidValue(newValue, f); + return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear(getProlepticYear() >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE)); @@ -286,7 +325,7 @@ } return with(isoDate.with(field, newValue)); } - return (MinguoDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } /** @@ -296,7 +335,7 @@ */ @Override public MinguoDate with(TemporalAdjuster adjuster) { - return (MinguoDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -306,7 +345,7 @@ */ @Override public MinguoDate plus(TemporalAmount amount) { - return (MinguoDate)super.plus(amount); + return super.plus(amount); } /** @@ -316,7 +355,7 @@ */ @Override public MinguoDate minus(TemporalAmount amount) { - return (MinguoDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- @@ -337,37 +376,37 @@ @Override public MinguoDate plus(long amountToAdd, TemporalUnit unit) { - return (MinguoDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public MinguoDate minus(long amountToAdd, TemporalUnit unit) { - return (MinguoDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override MinguoDate plusWeeks(long weeksToAdd) { - return (MinguoDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override MinguoDate minusYears(long yearsToSubtract) { - return (MinguoDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override MinguoDate minusMonths(long monthsToSubtract) { - return (MinguoDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override MinguoDate minusWeeks(long weeksToSubtract) { - return (MinguoDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override MinguoDate minusDays(long daysToSubtract) { - return (MinguoDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private MinguoDate with(LocalDate newDate) { @@ -376,7 +415,7 @@ @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override @@ -419,7 +458,7 @@ out.writeByte(get(DAY_OF_MONTH)); } - static ChronoLocalDate readExternal(DataInput in) throws IOException { + static ChronoLocalDate readExternal(DataInput in) throws IOException { int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); --- old/src/share/classes/java/time/chrono/MinguoEra.java 2013-04-11 23:15:40.000000000 -0700 +++ new/src/share/classes/java/time/chrono/MinguoEra.java 2013-04-11 23:15:40.000000000 -0700 @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -65,7 +70,34 @@ * An era in the Minguo calendar system. *

    * The Minguo calendar system has two eras. - * The date {@code 0001-01-01 (Minguo)} is equal to {@code 1912-01-01 (ISO)}. + * The current era, for years from 1 onwards, is known as the 'Republic of China' era. + * All previous years, zero or earlier in the proleptic count or one and greater + * in the year-of-era count, are part of the 'Before Republic of China' era. + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-yearISO proleptic-year
    2ROC21913
    1ROC11912
    1BEFORE_ROC01911
    2BEFORE_ROC-11910
    *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code MinguoEra}. * Use {@code getValue()} instead. @@ -75,16 +107,16 @@ * * @since 1.8 */ -enum MinguoEra implements Era { +public enum MinguoEra implements Era { /** - * The singleton instance for the era BEFORE_ROC, 'Before Republic of China'. - * This has the numeric value of {@code 0}. + * The singleton instance for the era before the current one, 'Before Republic of China Era', + * which has the numeric value 0. */ BEFORE_ROC, /** - * The singleton instance for the era ROC, 'Republic of China'. - * This has the numeric value of {@code 1}. + * The singleton instance for the current era, 'Republic of China Era', + * which has the numeric value 1. */ ROC; @@ -95,18 +127,18 @@ * {@code MinguoEra} is an enum representing the Minguo eras of BEFORE_ROC/ROC. * This factory allows the enum to be obtained from the {@code int} value. * - * @param era the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC) + * @param minguoEra the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC) * @return the era singleton, not null * @throws DateTimeException if the value is invalid */ - public static MinguoEra of(int era) { - switch (era) { + public static MinguoEra of(int minguoEra) { + switch (minguoEra) { case 0: return BEFORE_ROC; case 1: return ROC; default: - throw new DateTimeException("Invalid era: " + era); + throw new DateTimeException("Invalid era: " + minguoEra); } } @@ -123,24 +155,7 @@ return ordinal(); } - @Override - public MinguoChronology getChronology() { - return MinguoChronology.INSTANCE; - } - - // JDK8 default methods: //----------------------------------------------------------------------- - @Override - public MinguoDate date(int year, int month, int day) { - return (MinguoDate)(getChronology().date(this, year, month, day)); - } - - @Override - public MinguoDate dateYearDay(int year, int dayOfYear) { - return (MinguoDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - - //------------------------------------------------------------------------- private Object writeReplace() { return new Ser(Ser.MINGUO_ERA_TYPE, this); } --- old/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java 2013-04-11 23:15:41.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java 2013-04-11 23:15:41.000000000 -0700 @@ -56,6 +56,7 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.Serializable; @@ -106,15 +107,6 @@ * Singleton instance of the Buddhist chronology. */ public static final ThaiBuddhistChronology INSTANCE = new ThaiBuddhistChronology(); - /** - * The singleton instance for the era before the current one - Before Buddhist - - * which has the value 0. - */ - public static final Era ERA_BEFORE_BE = ThaiBuddhistEra.BEFORE_BE; - /** - * The singleton instance for the current era - Buddhist - which has the value 1. - */ - public static final Era ERA_BE = ThaiBuddhistEra.BE; /** * Serialization version. @@ -166,15 +158,6 @@ private ThaiBuddhistChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ThaiBuddhist'. @@ -208,32 +191,78 @@ } //----------------------------------------------------------------------- + /** + * Obtains a local date in Thai Buddhist calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Thai Buddhist era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code ThaiBuddhistEra} + */ @Override - public ThaiBuddhistDate date(int prolepticYear, int month, int dayOfMonth) { - return new ThaiBuddhistDate(LocalDate.of(prolepticYear - YEARS_DIFFERENCE, month, dayOfMonth)); + public ThaiBuddhistDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } + /** + * Obtains a local date in Thai Buddhist calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ @Override - public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { - return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); + public ThaiBuddhistDate date(int prolepticYear, int month, int dayOfMonth) { + return new ThaiBuddhistDate(LocalDate.of(prolepticYear - YEARS_DIFFERENCE, month, dayOfMonth)); } + /** + * Obtains a local date in Thai Buddhist calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Thai Buddhist era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code ThaiBuddhistEra} + */ @Override - public ThaiBuddhistDate date(TemporalAccessor temporal) { - if (temporal instanceof ThaiBuddhistDate) { - return (ThaiBuddhistDate) temporal; - } - return new ThaiBuddhistDate(LocalDate.from(temporal)); + public ThaiBuddhistDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } - @Override - public ThaiBuddhistDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); + /** + * Obtains a local date in Thai Buddhist calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override + public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { + return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); } - @Override - public ThaiBuddhistDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Thai Buddhist calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public ThaiBuddhistDate dateEpochDay(long epochDay) { + return new ThaiBuddhistDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -252,6 +281,14 @@ } @Override + public ThaiBuddhistDate date(TemporalAccessor temporal) { + if (temporal instanceof ThaiBuddhistDate) { + return (ThaiBuddhistDate) temporal; + } + return new ThaiBuddhistDate(LocalDate.from(temporal)); + } + + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); } @@ -285,7 +322,7 @@ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof ThaiBuddhistEra == false) { - throw new DateTimeException("Era must be BuddhistEra"); + throw new ClassCastException("Era must be BuddhistEra"); } return (era == ThaiBuddhistEra.BE ? yearOfEra : 1 - yearOfEra); } @@ -304,6 +341,10 @@ @Override public ValueRange range(ChronoField field) { switch (field) { + case PROLEPTIC_MONTH: { + ValueRange range = PROLEPTIC_MONTH.range(); + return ValueRange.of(range.getMinimum() + YEARS_DIFFERENCE * 12L, range.getMaximum() + YEARS_DIFFERENCE * 12L); + } case YEAR_OF_ERA: { ValueRange range = YEAR.range(); return ValueRange.of(1, -(range.getMinimum() + YEARS_DIFFERENCE) + 1, range.getMaximum() + YEARS_DIFFERENCE); --- old/src/share/classes/java/time/chrono/ThaiBuddhistDate.java 2013-04-11 23:15:42.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ThaiBuddhistDate.java 2013-04-11 23:15:41.000000000 -0700 @@ -72,12 +72,13 @@ import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -205,16 +206,46 @@ } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Thai Buddhist calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Thai Buddhist chronology, not null + */ @Override public ThaiBuddhistChronology getChronology() { return ThaiBuddhistChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Thai Buddhist calendar system has two eras, 'BE' and 'BEFORE_BE', + * defined by {@link ThaiBuddhistEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public ThaiBuddhistEra getEra() { + return (getProlepticYear() >= 1 ? ThaiBuddhistEra.BE : ThaiBuddhistEra.BEFORE_BE); + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -233,7 +264,7 @@ } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -242,6 +273,8 @@ public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { + case PROLEPTIC_MONTH: + return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); @@ -256,6 +289,10 @@ return field.getFrom(this); } + private long getProlepticMonth() { + return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; + } + private int getProlepticYear() { return isoDate.getYear() + YEARS_DIFFERENCE; } @@ -269,11 +306,13 @@ return this; } switch (f) { + case PROLEPTIC_MONTH: + getChronology().range(f).checkValidValue(newValue, f); + return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear((getProlepticYear() >= 1 ? nvalue : 1 - nvalue) - YEARS_DIFFERENCE)); @@ -286,7 +325,7 @@ } return with(isoDate.with(field, newValue)); } - return (ThaiBuddhistDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } /** @@ -296,7 +335,7 @@ */ @Override public ThaiBuddhistDate with(TemporalAdjuster adjuster) { - return (ThaiBuddhistDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -306,7 +345,7 @@ */ @Override public ThaiBuddhistDate plus(TemporalAmount amount) { - return (ThaiBuddhistDate)super.plus(amount); + return super.plus(amount); } /** @@ -316,7 +355,7 @@ */ @Override public ThaiBuddhistDate minus(TemporalAmount amount) { - return (ThaiBuddhistDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- @@ -332,7 +371,7 @@ @Override ThaiBuddhistDate plusWeeks(long weeksToAdd) { - return (ThaiBuddhistDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override @@ -342,32 +381,32 @@ @Override public ThaiBuddhistDate plus(long amountToAdd, TemporalUnit unit) { - return (ThaiBuddhistDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public ThaiBuddhistDate minus(long amountToAdd, TemporalUnit unit) { - return (ThaiBuddhistDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override ThaiBuddhistDate minusYears(long yearsToSubtract) { - return (ThaiBuddhistDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override ThaiBuddhistDate minusMonths(long monthsToSubtract) { - return (ThaiBuddhistDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override ThaiBuddhistDate minusWeeks(long weeksToSubtract) { - return (ThaiBuddhistDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override ThaiBuddhistDate minusDays(long daysToSubtract) { - return (ThaiBuddhistDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private ThaiBuddhistDate with(LocalDate newDate) { @@ -376,7 +415,7 @@ @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override --- old/src/share/classes/java/time/chrono/ThaiBuddhistEra.java 2013-04-11 23:15:42.000000000 -0700 +++ new/src/share/classes/java/time/chrono/ThaiBuddhistEra.java 2013-04-11 23:15:42.000000000 -0700 @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,7 +61,6 @@ */ package java.time.chrono; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -66,37 +70,66 @@ * An era in the Thai Buddhist calendar system. *

    * The Thai Buddhist calendar system has two eras. + * The current era, for years from 1 onwards, is known as the 'Buddhist' era. + * All previous years, zero or earlier in the proleptic count or one and greater + * in the year-of-era count, are part of the 'Before Buddhist' era. *

    - * Do not use ordinal() to obtain the numeric representation of a ThaiBuddhistEra - * instance. Use getValue() instead. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-yearISO proleptic-year
    2BE2-542
    1BE1-543
    1BEFORE_BE0-544
    2BEFORE_BE-1-545
    + *

    + * Do not use {@code ordinal()} to obtain the numeric representation of {@code ThaiBuddhistEra}. + * Use {@code getValue()} instead. * *

    Specification for implementors

    * This is an immutable and thread-safe enum. * * @since 1.8 */ -enum ThaiBuddhistEra implements Era { +public enum ThaiBuddhistEra implements Era { /** * The singleton instance for the era before the current one, 'Before Buddhist Era', - * which has the value 0. + * which has the numeric value 0. */ BEFORE_BE, /** - * The singleton instance for the current era, 'Buddhist Era', which has the value 1. + * The singleton instance for the current era, 'Buddhist Era', + * which has the numeric value 1. */ BE; //----------------------------------------------------------------------- /** - * Obtains an instance of {@code ThaiBuddhistEra} from a value. + * Obtains an instance of {@code ThaiBuddhistEra} from an {@code int} value. *

    - * The current era (from ISO year -543 onwards) has the value 1 - * The previous era has the value 0. + * {@code ThaiBuddhistEra} is an enum representing the Thai Buddhist eras of BEFORE_BE/BE. + * This factory allows the enum to be obtained from the {@code int} value. * * @param thaiBuddhistEra the era to represent, from 0 to 1 * @return the BuddhistEra singleton, never null - * @throws IllegalCalendarFieldValueException if the era is invalid + * @throws DateTimeException if the era is invalid */ public static ThaiBuddhistEra of(int thaiBuddhistEra) { switch (thaiBuddhistEra) { @@ -105,16 +138,15 @@ case 1: return BE; default: - throw new DateTimeException("Era is not valid for ThaiBuddhistEra"); + throw new DateTimeException("Invalid era: " + thaiBuddhistEra); } } //----------------------------------------------------------------------- /** - * Gets the era numeric value. + * Gets the numeric era {@code int} value. *

    - * The current era (from ISO year -543 onwards) has the value 1 - * The previous era has the value 0. + * The era BEFORE_BE has the value 0, while the era BE has the value 1. * * @return the era value, from 0 (BEFORE_BE) to 1 (BE) */ @@ -123,23 +155,6 @@ return ordinal(); } - @Override - public ThaiBuddhistChronology getChronology() { - return ThaiBuddhistChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public ThaiBuddhistDate date(int year, int month, int day) { - return (ThaiBuddhistDate)(getChronology().date(this, year, month, day)); - } - - @Override - public ThaiBuddhistDate dateYearDay(int year, int dayOfYear) { - return (ThaiBuddhistDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - //----------------------------------------------------------------------- private Object writeReplace() { return new Ser(Ser.THAIBUDDHIST_ERA_TYPE, this); --- old/src/share/classes/java/time/format/DateTimeFormatter.java 2013-04-11 23:15:43.000000000 -0700 +++ new/src/share/classes/java/time/format/DateTimeFormatter.java 2013-04-11 23:15:43.000000000 -0700 @@ -79,45 +79,343 @@ import java.time.DateTimeException; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.format.DateTimeFormatterBuilder.CompositePrinterParser; import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatterBuilder.CompositePrinterParser; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; /** * Formatter for printing and parsing date-time objects. *

    * This class provides the main application entry point for printing and parsing * and provides common implementations of {@code DateTimeFormatter}: - *

      - *
    • Using pattern letters, such as {@code yyyy-MMM-dd} - *
    • Using localized styles, such as {@code long} or {@code medium} - *
    • Using predefined constants, such as {@code ISO_LOCAL_DATE} - *

    + *
      + *
    • Using predefined constants, such as {@link #ISO_LOCAL_DATE}
    • + *
    • Using pattern letters, such as {@code uuuu-MMM-dd}
    • + *
    • Using localized styles, such as {@code long} or {@code medium}
    • + *
    + *

    + * More complex formatters are provided by + * {@link DateTimeFormatterBuilder DateTimeFormatterBuilder}. * *

    - * In most cases, provided formatters will be sufficient. - * For more complex formatters, a {@link DateTimeFormatterBuilder builder} is provided. - * The main date-time classes provide two methods - one for printing, - * {@code toString(DateTimeFormatter formatter)}, and one for parsing, + * The main date-time classes provide two methods - one for formatting, + * {@code format(DateTimeFormatter formatter)}, and one for parsing, * {@code parse(CharSequence text, DateTimeFormatter formatter)}. + *

    For example: + *

    + *  String text = date.toString(formatter);
    + *  LocalDate date = LocalDate.parse(text, formatter);
    + * 
    + *

    + * In addition to the format, formatters can be created with desired Locale, + * Chronology, ZoneId, and formatting symbols. + *

    + * The {@link #withLocale withLocale} method returns a new formatter that + * overrides the locale. The locale affects some aspects of formatting and + * parsing. For example, the {@link #ofLocalizedDate ofLocalizedDate} provides a + * formatter that uses the locale specific date format. + *

    + * The {@link #withChronology withChronology} method returns a new formatter + * that overrides the chronology. If overridden, the date-time value is + * converted to the chronology before formatting. During parsing the date-time + * value is converted to the chronology before it is returned. + *

    + * The {@link #withZone withZone} method returns a new formatter that overrides + * the zone. If overridden, the date-time value is converted to a ZonedDateTime + * with the requested ZoneId before formatting. During parsing the ZoneId is + * applied before the value is returned. + *

    + * The {@link #withSymbols withSymbols} method returns a new formatter that + * overrides the {@link DateTimeFormatSymbols}. The symbols are used for + * formatting and parsing. + *

    + * Some applications may need to use the older {@link Format java.text.Format} + * class for formatting. The {@link #toFormat()} method returns an + * implementation of {@code java.text.Format}. + *

    + *

    Predefined Formatters

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    FormatterDescriptionExample
    {@link #ofLocalizedDate ofLocalizedDate(dateStyle)} Formatter with date style from the locale '2011-12-03'
    {@link #ofLocalizedTime ofLocalizedTime(timeStyle)} Formatter with time style from the locale '10:15:30'
    {@link #ofLocalizedDateTime ofLocalizedDateTime(dateTimeStyle)} Formatter with a style for date and time from the locale '3 Jun 2008 11:05:30'
    {@link #ofLocalizedDateTime ofLocalizedDateTime(dateStyle,timeStyle)} + * Formatter with date and time styles from the locale '3 Jun 2008 11:05'
    {@link #BASIC_ISO_DATE}Basic ISO date '20111203'
    {@link #ISO_LOCAL_DATE} ISO Local Date '2011-12-03'
    {@link #ISO_OFFSET_DATE} ISO Date with offset '2011-12-03+01:00'
    {@link #ISO_DATE} ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03'
    {@link #ISO_LOCAL_TIME} Time without offset '10:15:30'
    {@link #ISO_OFFSET_TIME} Time with offset '10:15:30+01:00'
    {@link #ISO_TIME} Time with or without offset '10:15:30+01:00'; '10:15:30'
    {@link #ISO_LOCAL_DATE_TIME} ISO Local Date and Time '2011-12-03T10:15:30'
    {@link #ISO_OFFSET_DATE_TIME} Date Time with Offset + * 2011-12-03T10:15:30+01:00'
    {@link #ISO_ZONED_DATE_TIME} Zoned Date Time '2011-12-03T10:15:30+01:00[Europe/Paris]'
    {@link #ISO_DATE_TIME} Date and time with ZoneId '2011-12-03T10:15:30+01:00[Europe/Paris]'
    {@link #ISO_ORDINAL_DATE} Year and day of year '2012-337'
    {@link #ISO_WEEK_DATE} Year and Week 2012-W48-6'
    {@link #ISO_INSTANT} Date and Time of an Instant '2011-12-03T10:15:30Z'
    {@link #RFC_1123_DATE_TIME} RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'
    + * + *

    Patterns for Formatting and Parsing

    + * Patterns are based on a simple sequence of letters and symbols. + * A pattern is used to create a Formatter using the + * {@link #ofPattern(String)} and {@link #ofPattern(String, Locale)} methods. + * For example, + * {@code "d MMM uuuu"} will format 2011-12-03 as '3 Dec 2011'. + * A formatter created from a pattern can be used as many times as necessary, + * it is immutable and is thread-safe. + *

    * For example: - *

    + * 
    + *  DateTimeFormatter formatter = DateTimeFormatter.pattern("yyyy MM dd");
      *  String text = date.toString(formatter);
      *  LocalDate date = LocalDate.parse(text, formatter);
    + * 
    + *

    + * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The + * following pattern letters are defined: + *

    + *  Symbol  Meaning                     Presentation      Examples
    + *  ------  -------                     ------------      -------
    + *   G       era                         text              AD; Anno Domini; A
    + *   u       year                        year              2004; 04
    + *   y       year-of-era                 year              2004; 04
    + *   D       day-of-year                 number            189
    + *   M/L     month-of-year               number/text       7; 07; Jul; July; J
    + *   d       day-of-month                number            10
    + *
    + *   Q/q     quarter-of-year             number/text       3; 03; Q3; 3rd quarter
    + *   Y       week-based-year             year              1996; 96
    + *   w       week-of-week-based-year     number            27
    + *   W       week-of-month               number            4
    + *   E       day-of-week                 text              Tue; Tuesday; T
    + *   e/c     localized day-of-week       number/text       2; 02; Tue; Tuesday; T
    + *   F       week-of-month               number            3
    + *
    + *   a       am-pm-of-day                text              PM
    + *   h       clock-hour-of-am-pm (1-12)  number            12
    + *   K       hour-of-am-pm (0-11)        number            0
    + *   k       clock-hour-of-am-pm (1-24)  number            0
    + *
    + *   H       hour-of-day (0-23)          number            0
    + *   m       minute-of-hour              number            30
    + *   s       second-of-minute            number            55
    + *   S       fraction-of-second          fraction          978
    + *   A       milli-of-day                number            1234
    + *   n       nano-of-second              number            987654321
    + *   N       nano-of-day                 number            1234000000
    + *
    + *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
    + *   z       time-zone name              zone-name         Pacific Standard Time; PST
    + *   O       localized zone-offset       offset-O          GMT+8; GMT+08:00; UTC-08:00;
    + *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
    + *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
    + *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    + *
    + *   p       pad next                    pad modifier      1
    + *
    + *   '       escape for text             delimiter
    + *   ''      single quote                literal           '
    + *   [       optional section start
    + *   ]       optional section end
    + *   #       reserved for future use
    + *   {       reserved for future use
    + *   }       reserved for future use
      * 
    - * Some aspects of formatting and parsing are dependent on the locale. - * The locale can be changed using the {@link #withLocale(Locale)} method - * which returns a new formatter in the requested locale. *

    - * Some applications may need to use the older {@link Format} class for formatting. - * The {@link #toFormat()} method returns an implementation of the old API. + * The count of pattern letters determines the format. + *

    + * Text: The text style is determined based on the number of pattern + * letters used. Less than 4 pattern letters will use the + * {@link TextStyle#SHORT short form}. Exactly 4 pattern letters will use the + * {@link TextStyle#FULL full form}. Exactly 5 pattern letters will use the + * {@link TextStyle#NARROW narrow form}. + * Pattern letters 'L', 'c', and 'q' specify the stand-alone form of the text styles. + *

    + * Number: If the count of letters is one, then the value is output using + * the minimum number of digits and without padding. Otherwise, the count of digits + * is used as the width of the output field, with the value zero-padded as necessary. + * The following pattern letters have constraints on the count of letters. + * Only one letter of 'c' and 'F' can be specified. + * Up to two letters of 'd', 'H', 'h', 'K', 'k', 'm', and 's' can be specified. + * Up to three letters of 'D' can be specified. + *

    + * Number/Text: If the count of pattern letters is 3 or greater, use the + * Text rules above. Otherwise use the Number rules above. + *

    + * Fraction: Outputs the nano-of-second field as a fraction-of-second. + * The nano-of-second value has nine digits, thus the count of pattern letters + * is from 1 to 9. If it is less than 9, then the nano-of-second value is + * truncated, with only the most significant digits being output. When parsing + * in strict mode, the number of parsed digits must match the count of pattern + * letters. When parsing in lenient mode, the number of parsed digits must be at + * least the count of pattern letters, up to 9 digits. + *

    + * Year: The count of letters determines the minimum field width below + * which padding is used. If the count of letters is two, then a + * {@link DateTimeFormatterBuilder#appendValueReduced reduced} two digit form is + * used. For printing, this outputs the rightmost two digits. For parsing, this + * will parse using the base value of 2000, resulting in a year within the range + * 2000 to 2099 inclusive. If the count of letters is less than four (but not + * two), then the sign is only output for negative years as per + * {@link SignStyle#NORMAL}. Otherwise, the sign is output if the pad width is + * exceeded, as per {@link SignStyle#EXCEEDS_PAD}. + *

    + * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. If the + * count of letters is two, then the time-zone ID is output. Any other count of + * letters throws {@code IllegalArgumentException}. + *

    + * Zone names: This outputs the display name of the time-zone ID. If the + * count of letters is one, two or three, then the short name is output. If the + * count of letters is four, then the full name is output. Five or more letters + * throws {@code IllegalArgumentException}. + *

    + * Offset X and x: This formats the offset based on the number of pattern + * letters. One letter outputs just the hour, such as '+01', unless the minute + * is non-zero in which case the minute is also output, such as '+0130'. Two + * letters outputs the hour and minute, without a colon, such as '+0130'. Three + * letters outputs the hour and minute, with a colon, such as '+01:30'. Four + * letters outputs the hour and minute and optional second, without a colon, + * such as '+013015'. Five letters outputs the hour and minute and optional + * second, with a colon, such as '+01:30:15'. Six or more letters throws + * {@code IllegalArgumentException}. Pattern letter 'X' (upper case) will output + * 'Z' when the offset to be output would be zero, whereas pattern letter 'x' + * (lower case) will output '+00', '+0000', or '+00:00'. + *

    + * Offset O: This formats the localized offset based on the number of + * pattern letters. One letter outputs the {@linkplain TextStyle#SHORT short} + * form of the localized offset, which is localized offset text, such as 'GMT', + * with hour without leading zero, optional 2-digit minute and second if + * non-zero, and colon, for example 'GMT+8'. Four letters outputs the + * {@linkplain TextStyle#FULL full} form, which is localized offset text, + * such as 'GMT, with 2-digit hour and minute field, optional second field + * if non-zero, and colon, for example 'GMT+08:00'. Any other count of letters + * throws {@code IllegalArgumentException}. + *

    + * Offset Z: This formats the offset based on the number of pattern + * letters. One, two or three letters outputs the hour and minute, without a + * colon, such as '+0130'. The output will be '+0000' when the offset is zero. + * Four letters outputs the {@linkplain TextStyle#FULL full} form of localized + * offset, equivalent to four letters of Offset-O. The output will be the + * corresponding localized offset text if the offset is zero. Five + * letters outputs the hour, minute, with optional second if non-zero, with + * colon. It outputs 'Z' if the offset is zero. + * Six or more letters throws {@code IllegalArgumentException}. + *

    + * Optional section: The optional section markers work exactly like + * calling {@link DateTimeFormatterBuilder#optionalStart()} and + * {@link DateTimeFormatterBuilder#optionalEnd()}. + *

    + * Pad modifier: Modifies the pattern that immediately follows to be + * padded with spaces. The pad width is determined by the number of pattern + * letters. This is the same as calling + * {@link DateTimeFormatterBuilder#padNext(int)}. + *

    + * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to + * a width of 2. + *

    + * Any unrecognized letter is an error. Any non-letter character, other than + * '[', ']', '{', '}', '#' and the single quote will be output directly. + * Despite this, it is recommended to use single quotes around all characters + * that you want to output directly to ensure that future changes do not break + * your application. * *

    Specification for implementors

    * This class is immutable and thread-safe. @@ -139,6 +437,14 @@ */ private final DateTimeFormatSymbols symbols; /** + * The resolver style to use, not null. + */ + private final ResolverStyle resolverStyle; + /** + * The fields to use in resolving, null for all fields. + */ + private final Set resolverFields; + /** * The chronology to use for formatting, null for no override. */ private final Chronology chrono; @@ -151,129 +457,17 @@ /** * Creates a formatter using the specified pattern. *

    - * This method will create a formatter based on a simple pattern of letters and symbols. - * For example, {@code d MMM yyyy} will format 2011-12-03 as '3 Dec 2011'. - *

    - * The returned formatter will use the default locale, but this can be changed - * using {@link DateTimeFormatter#withLocale(Locale)}. - *

    - * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. - * The following pattern letters are defined: - *

    -     *  Symbol  Meaning                     Presentation      Examples
    -     *  ------  -------                     ------------      -------
    -     *   G       era                         text              A; AD; Anno Domini
    -     *   y       year                        year              2004; 04
    -     *   D       day-of-year                 number            189
    -     *   M       month-of-year               number/text       7; 07; Jul; July; J
    -     *   d       day-of-month                number            10
    -     *
    -     *   Q       quarter-of-year             number/text       3; 03; Q3
    -     *   Y       week-based-year             year              1996; 96
    -     *   w       week-of-year                number            27
    -     *   W       week-of-month               number            27
    -     *   e       localized day-of-week       number            2; Tue; Tuesday; T
    -     *   E       day-of-week                 number/text       2; Tue; Tuesday; T
    -     *   F       week-of-month               number            3
    -     *
    -     *   a       am-pm-of-day                text              PM
    -     *   h       clock-hour-of-am-pm (1-12)  number            12
    -     *   K       hour-of-am-pm (0-11)        number            0
    -     *   k       clock-hour-of-am-pm (1-24)  number            0
    -     *
    -     *   H       hour-of-day (0-23)          number            0
    -     *   m       minute-of-hour              number            30
    -     *   s       second-of-minute            number            55
    -     *   S       fraction-of-second          fraction          978
    -     *   A       milli-of-day                number            1234
    -     *   n       nano-of-second              number            987654321
    -     *   N       nano-of-day                 number            1234000000
    -     *
    -     *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
    -     *   z       time-zone name              zone-name         Pacific Standard Time; PST
    -     *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
    -     *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
    -     *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    -     *
    -     *   p       pad next                    pad modifier      1
    -     *
    -     *   '       escape for text             delimiter
    -     *   ''      single quote                literal           '
    -     *   [       optional section start
    -     *   ]       optional section end
    -     *   {}      reserved for future use
    -     * 
    - *

    - * The count of pattern letters determine the format. + * This method will create a formatter based on a simple + * pattern of letters and symbols + * as described in the class documentation. + * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. + *

    + * The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * Alternatively use the {@link #ofPattern(String, Locale)} variant of this method. *

    - * Text: The text style is determined based on the number of pattern letters used. - * Less than 4 pattern letters will use the {@link TextStyle#SHORT short form}. - * Exactly 4 pattern letters will use the {@link TextStyle#FULL full form}. - * Exactly 5 pattern letters will use the {@link TextStyle#NARROW narrow form}. - *

    - * Number: If the count of letters is one, then the value is output using the minimum number - * of digits and without padding as per {@link DateTimeFormatterBuilder#appendValue(java.time.temporal.TemporalField)}. - * Otherwise, the count of digits is used as the width of the output field as per - * {@link DateTimeFormatterBuilder#appendValue(java.time.temporal.TemporalField, int)}. - *

    - * Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. - * Otherwise use the Number rules above. - *

    - * Fraction: Outputs the nano-of-second field as a fraction-of-second. - * The nano-of-second value has nine digits, thus the count of pattern letters is from 1 to 9. - * If it is less than 9, then the nano-of-second value is truncated, with only the most - * significant digits being output. - * When parsing in strict mode, the number of parsed digits must match the count of pattern letters. - * When parsing in lenient mode, the number of parsed digits must be at least the count of pattern - * letters, up to 9 digits. - *

    - * Year: The count of letters determines the minimum field width below which padding is used. - * If the count of letters is two, then a {@link DateTimeFormatterBuilder#appendValueReduced reduced} - * two digit form is used. - * For printing, this outputs the rightmost two digits. For parsing, this will parse using the - * base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. - * If the count of letters is less than four (but not two), then the sign is only output for negative - * years as per {@link SignStyle#NORMAL}. - * Otherwise, the sign is output if the pad width is exceeded, as per {@link SignStyle#EXCEEDS_PAD} - *

    - * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. - * If the count of letters is two, then the time-zone ID is output. - * Any other count of letters throws {@code IllegalArgumentException}. - *

    - * Zone names: This outputs the display name of the time-zone ID. - * If the count of letters is one, two or three, then the short name is output. - * If the count of letters is four, then the full name is output. - * Five or more letters throws {@code IllegalArgumentException}. - *

    - * Offset X and x: This formats the offset based on the number of pattern letters. - * One letter outputs just the hour', such as '+01', unless the minute is non-zero - * in which case the minute is also output, such as '+0130'. - * Two letters outputs the hour and minute, without a colon, such as '+0130'. - * Three letters outputs the hour and minute, with a colon, such as '+01:30'. - * Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. - * Five letters outputs the hour and minute and optional second, with a colon, such as '+01:30:15'. - * Six or more letters throws {@code IllegalArgumentException}. - * Pattern letter 'X' (upper case) will output 'Z' when the offset to be output would be zero, - * whereas pattern letter 'x' (lower case) will output '+00', '+0000', or '+00:00'. - *

    - * Offset Z: This formats the offset based on the number of pattern letters. - * One, two or three letters outputs the hour and minute, without a colon, such as '+0130'. - * Four or more letters throws {@code IllegalArgumentException}. - * The output will be '+0000' when the offset is zero. - *

    - * Optional section: The optional section markers work exactly like calling - * {@link DateTimeFormatterBuilder#optionalStart()} and {@link DateTimeFormatterBuilder#optionalEnd()}. - *

    - * Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. - * The pad width is determined by the number of pattern letters. - * This is the same as calling {@link DateTimeFormatterBuilder#padNext(int)}. - *

    - * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2. - *

    - * Any unrecognized letter is an error. - * Any non-letter character, other than '[', ']', '{', '}' and the single quote will be output directly. - * Despite this, it is recommended to use single quotes around all characters that you want to - * output directly to ensure that future changes do not break your application. + * The returned formatter has no override chronology or zone. + * It uses {@link ResolverStyle#SMART SMART} resolver style. * * @param pattern the pattern to use, not null * @return the formatter based on the pattern, not null @@ -285,15 +479,18 @@ } /** - * Creates a formatter using the specified pattern. + * Creates a formatter using the specified pattern and locale. *

    - * This method will create a formatter based on a simple pattern of letters and symbols. - * For example, {@code d MMM yyyy} will format 2011-12-03 as '3 Dec 2011'. + * This method will create a formatter based on a simple + * pattern of letters and symbols + * as described in the class documentation. + * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. *

    - * See {@link #ofPattern(String)} for details of the pattern. + * The formatter will use the specified locale. + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter *

    - * The returned formatter will use the specified locale, but this can be changed - * using {@link DateTimeFormatter#withLocale(Locale)}. + * The returned formatter has no override chronology or zone. + * It uses {@link ResolverStyle#SMART SMART} resolver style. * * @param pattern the pattern to use, not null * @param locale the locale to use, not null @@ -307,7 +504,7 @@ //----------------------------------------------------------------------- /** - * Returns a locale specific date format. + * Returns a locale specific date format for the ISO chronology. *

    * This returns a formatter that will format or parse a date. * The exact format pattern used varies by locale. @@ -320,17 +517,22 @@ * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateStyle the formatter style to obtain, not null * @return the date formatter, not null */ public static DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle) { Objects.requireNonNull(dateStyle, "dateStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateStyle, null).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateStyle, null) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific time format. + * Returns a locale specific time format for the ISO chronology. *

    * This returns a formatter that will format or parse a time. * The exact format pattern used varies by locale. @@ -343,17 +545,22 @@ * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param timeStyle the formatter style to obtain, not null * @return the time formatter, not null */ public static DateTimeFormatter ofLocalizedTime(FormatStyle timeStyle) { Objects.requireNonNull(timeStyle, "timeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(null, timeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(null, timeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific date-time formatter, which is typically of short length. + * Returns a locale specific date-time formatter for the ISO chronology. *

    * This returns a formatter that will format or parse a date-time. * The exact format pattern used varies by locale. @@ -366,17 +573,22 @@ * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateTimeStyle the formatter style to obtain, not null * @return the date-time formatter, not null */ public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateTimeStyle) { Objects.requireNonNull(dateTimeStyle, "dateTimeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateTimeStyle, dateTimeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateTimeStyle, dateTimeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific date and time format. + * Returns a locale specific date and time format for the ISO chronology. *

    * This returns a formatter that will format or parse a date-time. * The exact format pattern used varies by locale. @@ -389,6 +601,10 @@ * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateStyle the date formatter style to obtain, not null * @param timeStyle the time formatter style to obtain, not null @@ -397,13 +613,14 @@ public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateStyle, FormatStyle timeStyle) { Objects.requireNonNull(dateStyle, "dateStyle"); Objects.requireNonNull(timeStyle, "timeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateStyle, timeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateStyle, timeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date without an offset, - * such as '2011-12-03'. + * The ISO date formatter that formats or parses a date without an + * offset, such as '2011-12-03'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended local date format. @@ -418,23 +635,27 @@ *

  • A dash *
  • Two digits for the {@link ChronoField#DAY_OF_MONTH day-of-month}. * This is pre-padded by zero to ensure two digits. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_DATE; static { ISO_LOCAL_DATE = new DateTimeFormatterBuilder() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral('-') - .appendValue(MONTH_OF_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_MONTH, 2) - .toFormatter(); + .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral('-') + .appendValue(MONTH_OF_YEAR, 2) + .appendLiteral('-') + .appendValue(DAY_OF_MONTH, 2) + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date with an offset, - * such as '2011-12-03+01:00'. + * The ISO date formatter that formats or parses a date with an + * offset, such as '2011-12-03+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date format. @@ -444,20 +665,24 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_DATE; static { ISO_OFFSET_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date with the + * The ISO date formatter that formats or parses a date with the * offset if available, such as '2011-12-03' or '2011-12-03+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -469,25 +694,29 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_DATE; static { ISO_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time without an offset, - * such as '10:15' or '10:15:30'. + * The ISO time formatter that formats or parses a time without an + * offset, such as '10:15' or '10:15:30'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended local time format. @@ -506,26 +735,29 @@ *

  • A decimal point *
  • One to nine digits for the {@link ChronoField#NANO_OF_SECOND nano-of-second}. * As many digits will be output as required. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_TIME; static { ISO_LOCAL_TIME = new DateTimeFormatterBuilder() - .appendValue(HOUR_OF_DAY, 2) - .appendLiteral(':') - .appendValue(MINUTE_OF_HOUR, 2) - .optionalStart() - .appendLiteral(':') - .appendValue(SECOND_OF_MINUTE, 2) - .optionalStart() - .appendFraction(NANO_OF_SECOND, 0, 9, true) - .toFormatter(); + .appendValue(HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(SECOND_OF_MINUTE, 2) + .optionalStart() + .appendFraction(NANO_OF_SECOND, 0, 9, true) + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time with an offset, - * such as '10:15+01:00' or '10:15:30+01:00'. + * The ISO time formatter that formats or parses a time with an + * offset, such as '10:15+01:00' or '10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset time format. @@ -535,20 +767,23 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_TIME; static { ISO_OFFSET_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_TIME) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_TIME) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time, with the + * The ISO time formatter that formats or parses a time, with the * offset if available, such as '10:15', '10:15:30' or '10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -560,25 +795,28 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_TIME; static { ISO_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_TIME) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_TIME) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * without an offset, such as '2011-12-03T10:15:30'. + * The ISO date-time formatter that formats or parses a date-time without + * an offset, such as '2011-12-03T10:15:30'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date-time format. @@ -587,22 +825,26 @@ *

  • The {@link #ISO_LOCAL_DATE} *
  • The letter 'T'. Parsing is case insensitive. *
  • The {@link #ISO_LOCAL_TIME} - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_DATE_TIME; static { ISO_LOCAL_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .appendLiteral('T') - .append(ISO_LOCAL_TIME) - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .appendLiteral('T') + .append(ISO_LOCAL_TIME) + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * with an offset, such as '2011-12-03T10:15:30+01:00'. + * The ISO date-time formatter that formats or parses a date-time with an + * offset, such as '2011-12-03T10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date-time format. @@ -612,25 +854,30 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_DATE_TIME; static { ISO_OFFSET_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE_TIME) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE_TIME) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time with + * The ISO-like date-time formatter that formats or parses a date-time with * offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'. *

    * This returns an immutable formatter capable of formatting and parsing * a format that extends the ISO-8601 extended offset date-time format * to add the time-zone. + * The section in square brackets is not part of the ISO-8601 standard. * The format consists of: *

      *
    • The {@link #ISO_OFFSET_DATE_TIME} @@ -639,28 +886,33 @@ *
    • The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. * Parsing is case sensitive. *
    • A close square bracket ']'. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_ZONED_DATE_TIME; static { ISO_ZONED_DATE_TIME = new DateTimeFormatterBuilder() - .append(ISO_OFFSET_DATE_TIME) - .optionalStart() - .appendLiteral('[') - .parseCaseSensitive() - .appendZoneRegionId() - .appendLiteral(']') - .toFormatter(); + .append(ISO_OFFSET_DATE_TIME) + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']') + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * with the offset and zone if available, such as '2011-12-03T10:15:30', + * The ISO-like date-time formatter that formats or parses a date-time with + * the offset and zone if available, such as '2011-12-03T10:15:30', * '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'. *

    * This returns an immutable formatter capable of formatting and parsing - * the ISO-8601 extended offset date-time format. + * the ISO-8601 extended local or offset date-time format, as well as the + * extended non-ISO form specifying the time-zone. * The format consists of: *

      *
    • The {@link #ISO_LOCAL_DATE_TIME} @@ -672,28 +924,32 @@ *
    • The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. * Parsing is case sensitive. *
    • A close square bracket ']'. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_DATE_TIME; static { ISO_DATE_TIME = new DateTimeFormatterBuilder() - .append(ISO_LOCAL_DATE_TIME) - .optionalStart() - .appendOffsetId() - .optionalStart() - .appendLiteral('[') - .parseCaseSensitive() - .appendZoneRegionId() - .appendLiteral(']') - .toFormatter(); + .append(ISO_LOCAL_DATE_TIME) + .optionalStart() + .appendOffsetId() + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']') + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses the ordinal date + * The ISO date formatter that formats or parses the ordinal date * without an offset, such as '2012-337'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -710,26 +966,30 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_ORDINAL_DATE; static { ISO_ORDINAL_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral('-') - .appendValue(DAY_OF_YEAR, 3) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral('-') + .appendValue(DAY_OF_YEAR, 3) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses the week-based date + * The ISO date formatter that formats or parses the week-based date * without an offset, such as '2012-W48-6'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -750,50 +1010,67 @@ *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_WEEK_DATE; static { ISO_WEEK_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral("-W") - .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_WEEK, 1) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral("-W") + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2) + .appendLiteral('-') + .appendValue(DAY_OF_WEEK, 1) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO instant formatter that formats or parses an instant in UTC. + * The ISO instant formatter that formats or parses an instant in UTC, + * such as '2011-12-03T10:15:30Z'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 instant format. + *

    + * This is a special case formatter intended to allow a human readable form + * of an {@link java.time.Instant}. The {@code Instant} class is designed to + * only represent a point in time and internally stores a value in nanoseconds + * from a fixed epoch of 1970-01-01Z. As such, an {@code Instant} cannot be + * formatted as a date or time without providing some form of time-zone. + * This formatter allows the {@code Instant} to be formatted, by providing + * a suitable conversion using {@code ZoneOffset.UTC}. + *

    * The format consists of: *

      *
    • The {@link #ISO_OFFSET_DATE_TIME} where the instant is converted from * {@link ChronoField#INSTANT_SECONDS} and {@link ChronoField#NANO_OF_SECOND} * using the {@code UTC} offset. Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_INSTANT; static { ISO_INSTANT = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendInstant() - .toFormatter(); + .parseCaseInsensitive() + .appendInstant() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date without an offset, - * such as '20111203'. + * The ISO date formatter that formats or parses a date without an + * offset, such as '20111203'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 basic local date format. @@ -809,21 +1086,25 @@ *

  • The {@link ZoneOffset#getId() offset ID} without colons. If the offset has * seconds then they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter BASIC_ISO_DATE; static { BASIC_ISO_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(YEAR, 4) - .appendValue(MONTH_OF_YEAR, 2) - .appendValue(DAY_OF_MONTH, 2) - .optionalStart() - .appendOffset("+HHMMss", "Z") - .toFormatter(); + .parseCaseInsensitive() + .appendValue(YEAR, 4) + .appendValue(MONTH_OF_YEAR, 2) + .appendValue(DAY_OF_MONTH, 2) + .optionalStart() + .appendOffset("+HHMMss", "Z") + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- @@ -862,9 +1143,13 @@ *

  • A space *
  • The {@link ZoneOffset#getId() offset ID} without colons or seconds. * An offset of zero uses "GMT". North American zone names and military zone names are not handled. - *

    + * *

    * Parsing is case insensitive. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. */ public static final DateTimeFormatter RFC_1123_DATE_TIME; static { @@ -892,28 +1177,28 @@ moy.put(11L, "Nov"); moy.put(12L, "Dec"); RFC_1123_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .parseLenient() - .optionalStart() - .appendText(DAY_OF_WEEK, dow) - .appendLiteral(", ") - .optionalEnd() - .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) - .appendLiteral(' ') - .appendText(MONTH_OF_YEAR, moy) - .appendLiteral(' ') - .appendValue(YEAR, 4) // 2 digit year not handled - .appendLiteral(' ') - .appendValue(HOUR_OF_DAY, 2) - .appendLiteral(':') - .appendValue(MINUTE_OF_HOUR, 2) - .optionalStart() - .appendLiteral(':') - .appendValue(SECOND_OF_MINUTE, 2) - .optionalEnd() - .appendLiteral(' ') - .appendOffset("+HHMM", "GMT") // should handle UT/Z/EST/EDT/CST/CDT/MST/MDT/PST/MDT - .toFormatter(); + .parseCaseInsensitive() + .parseLenient() + .optionalStart() + .appendText(DAY_OF_WEEK, dow) + .appendLiteral(", ") + .optionalEnd() + .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) + .appendLiteral(' ') + .appendText(MONTH_OF_YEAR, moy) + .appendLiteral(' ') + .appendValue(YEAR, 4) // 2 digit year not handled + .appendLiteral(' ') + .appendValue(HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(SECOND_OF_MINUTE, 2) + .optionalEnd() + .appendLiteral(' ') + .appendOffset("+HHMM", "GMT") // should handle UT/Z/EST/EDT/CST/CDT/MST/MDT/PST/MDT + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** @@ -922,14 +1207,20 @@ * @param printerParser the printer/parser to use, not null * @param locale the locale to use, not null * @param symbols the symbols to use, not null + * @param resolverStyle the resolver style to use, not null + * @param resolverFields the fields to use during resolving, null for all fields * @param chrono the chronology to use, null for no override * @param zone the zone to use, null for no override */ - DateTimeFormatter(CompositePrinterParser printerParser, Locale locale, - DateTimeFormatSymbols symbols, Chronology chrono, ZoneId zone) { + DateTimeFormatter(CompositePrinterParser printerParser, + Locale locale, DateTimeFormatSymbols symbols, + ResolverStyle resolverStyle, Set resolverFields, + Chronology chrono, ZoneId zone) { this.printerParser = Objects.requireNonNull(printerParser, "printerParser"); + this.resolverFields = resolverFields; this.locale = Objects.requireNonNull(locale, "locale"); this.symbols = Objects.requireNonNull(symbols, "symbols"); + this.resolverStyle = Objects.requireNonNull(resolverStyle, "resolverStyle"); this.chrono = chrono; this.zone = zone; } @@ -962,7 +1253,7 @@ if (this.locale.equals(locale)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -987,7 +1278,7 @@ if (this.symbols.equals(symbols)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -998,7 +1289,7 @@ * By default, a formatter has no override chronology, returning null. * See {@link #withChronology(Chronology)} for more details on overriding. * - * @return the chronology of this formatter, null if no override + * @return the override chronology of this formatter, null if no override */ public Chronology getChronology() { return chrono; @@ -1013,26 +1304,35 @@ *

    * If an override is added, then any date that is formatted or parsed will be affected. *

    - * When formatting, if the {@code Temporal} object contains a date then it will + * When formatting, if the temporal object contains a date, then it will * be converted to a date in the override chronology. - * Any time or zone will be retained unless overridden. - * The converted result will behave in a manner equivalent to an implementation - * of {@code ChronoLocalDate},{@code ChronoLocalDateTime} or {@code ChronoZonedDateTime}. - *

    - * When parsing, the override chronology will be used to interpret the - * {@link java.time.temporal.ChronoField fields} into a date unless the - * formatter directly parses a valid chronology. + * Whether the temporal contains a date is determined by querying the + * {@link ChronoField#EPOCH_DAY EPOCH_DAY} field. + * Any time or zone will be retained unaltered unless overridden. + *

    + * If the temporal object does not contain a date, but does contain one + * or more {@code ChronoField} date fields, then a {@code DateTimeException} + * is thrown. In all other cases, the override chronology is added to the temporal, + * replacing any previous chronology, but without changing the date/time. + *

    + * When parsing, there are two distinct cases to consider. + * If a chronology has been parsed directly from the text, perhaps because + * {@link DateTimeFormatterBuilder#appendChronologyId()} was used, then + * this override chronology has no effect. + * If no zone has been parsed, then this override chronology will be used + * to interpret the {@code ChronoField} values into a date according to the + * date resolving rules of the chronology. *

    * This instance is immutable and unaffected by this method call. * - * @param chrono the new chronology, not null + * @param chrono the new chronology, null if no override * @return a formatter based on this formatter with the requested override chronology, not null */ public DateTimeFormatter withChronology(Chronology chrono) { if (Objects.equals(this.chrono, chrono)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -1043,7 +1343,7 @@ * By default, a formatter has no override zone, returning null. * See {@link #withZone(ZoneId)} for more details on overriding. * - * @return the chronology of this formatter, null if no override + * @return the override zone of this formatter, null if no override */ public ZoneId getZone() { return zone; @@ -1058,28 +1358,192 @@ *

    * If an override is added, then any instant that is formatted or parsed will be affected. *

    - * When formatting, if the {@code Temporal} object contains an instant then it will + * When formatting, if the temporal object contains an instant, then it will * be converted to a zoned date-time using the override zone. + * Whether the temporal is an instant is determined by querying the + * {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS} field. * If the input has a chronology then it will be retained unless overridden. * If the input does not have a chronology, such as {@code Instant}, then * the ISO chronology will be used. - * The converted result will behave in a manner equivalent to an implementation - * of {@code ChronoZonedDateTime}. *

    - * When parsing, the override zone will be used to interpret the - * {@link java.time.temporal.ChronoField fields} into an instant unless the - * formatter directly parses a valid zone. + * If the temporal object does not contain an instant, but does contain + * an offset then an additional check is made. If the normalized override + * zone is an offset that differs from the offset of the temporal, then + * a {@code DateTimeException} is thrown. In all other cases, the override + * zone is added to the temporal, replacing any previous zone, but without + * changing the date/time. + *

    + * When parsing, there are two distinct cases to consider. + * If a zone has been parsed directly from the text, perhaps because + * {@link DateTimeFormatterBuilder#appendZoneId()} was used, then + * this override zone has no effect. + * If no zone has been parsed, then this override zone will be included in + * the result of the parse where it can be used to build instants and date-times. *

    * This instance is immutable and unaffected by this method call. * - * @param zone the new override zone, not null + * @param zone the new override zone, null if no override * @return a formatter based on this formatter with the requested override zone, not null */ public DateTimeFormatter withZone(ZoneId zone) { if (Objects.equals(this.zone, zone)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); + } + + //----------------------------------------------------------------------- + /** + * Gets the resolver style to use during parsing. + *

    + * This returns the resolver style, used during the second phase of parsing + * when fields are resolved into dates and times. + * By default, a formatter has the {@link ResolverStyle#SMART SMART} resolver style. + * See {@link #withResolverStyle(ResolverStyle)} for more details. + * + * @return the resolver style of this formatter, not null + */ + public ResolverStyle getResolverStyle() { + return resolverStyle; + } + + /** + * Returns a copy of this formatter with a new resolver style. + *

    + * This returns a formatter with similar state to this formatter but + * with the resolver style set. By default, a formatter has the + * {@link ResolverStyle#SMART SMART} resolver style. + *

    + * Changing the resolver style only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver style is used to control how phase 2, resolving, happens. + * See {@code ResolverStyle} for more information on the options available. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverStyle the new resolver style, not null + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverStyle(ResolverStyle resolverStyle) { + Objects.requireNonNull(resolverStyle, "resolverStyle"); + if (Objects.equals(this.resolverStyle, resolverStyle)) { + return this; + } + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); + } + + //----------------------------------------------------------------------- + /** + * Gets the resolver fields to use during parsing. + *

    + * This returns the resolver fields, used during the second phase of parsing + * when fields are resolved into dates and times. + * By default, a formatter has no resolver fields, and thus returns null. + * See {@link #withResolverFields(Set)} for more details. + * + * @return the immutable set of resolver fields of this formatter, null if no fields + */ + public Set getResolverFields() { + return resolverFields; + } + + /** + * Returns a copy of this formatter with a new set of resolver fields. + *

    + * This returns a formatter with similar state to this formatter but with + * the resolver fields set. By default, a formatter has no resolver fields. + *

    + * Changing the resolver fields only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver fields are used to filter the field-value pairs between phase 1 and 2. + *

    + * This can be used to select between two or more ways that a date or time might + * be resolved. For example, if the formatter consists of year, month, day-of-month + * and day-of-year, then there are two ways to resolve a date. + * Calling this method with the arguments {@link ChronoField#YEAR YEAR} and + * {@link ChronoField#DAY_OF_YEAR DAY_OF_YEAR} will ensure that the date is + * resolved using the year and day-of-year, effectively meaning that the month + * and day-of-month are ignored during the resolving phase. + *

    + * In a similar manner, this method can be used to ignore secondary fields that + * would otherwise be cross-checked. For example, if the formatter consists of year, + * month, day-of-month and day-of-week, then there is only one way to resolve a + * date, but the parsed value for day-of-week will be cross-checked against the + * resolved date. Calling this method with the arguments {@link ChronoField#YEAR YEAR}, + * {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} and + * {@link ChronoField#DAY_OF_MONTH DAY_OF_MONTH} will ensure that the date is + * resolved correctly, but without any cross-check for the day-of-week. + *

    + * In implementation terms, this method behaves as follows. The result of the + * parsing phase can be considered to be a map of field to value. The behavior + * of this method is to cause that map to be filtered between phase 1 and 2, + * removing all fields other than those specified as arguments to this method. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverFields the new set of resolver fields, null if no fields + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverFields(TemporalField... resolverFields) { + Objects.requireNonNull(resolverFields, "resolverFields"); + Set fields = new HashSet<>(Arrays.asList(resolverFields)); + if (Objects.equals(this.resolverFields, fields)) { + return this; + } + fields = Collections.unmodifiableSet(fields); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, fields, chrono, zone); + } + + /** + * Returns a copy of this formatter with a new set of resolver fields. + *

    + * This returns a formatter with similar state to this formatter but with + * the resolver fields set. By default, a formatter has no resolver fields. + *

    + * Changing the resolver fields only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver fields are used to filter the field-value pairs between phase 1 and 2. + *

    + * This can be used to select between two or more ways that a date or time might + * be resolved. For example, if the formatter consists of year, month, day-of-month + * and day-of-year, then there are two ways to resolve a date. + * Calling this method with the arguments {@link ChronoField#YEAR YEAR} and + * {@link ChronoField#DAY_OF_YEAR DAY_OF_YEAR} will ensure that the date is + * resolved using the year and day-of-year, effectively meaning that the month + * and day-of-month are ignored during the resolving phase. + *

    + * In a similar manner, this method can be used to ignore secondary fields that + * would otherwise be cross-checked. For example, if the formatter consists of year, + * month, day-of-month and day-of-week, then there is only one way to resolve a + * date, but the parsed value for day-of-week will be cross-checked against the + * resolved date. Calling this method with the arguments {@link ChronoField#YEAR YEAR}, + * {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} and + * {@link ChronoField#DAY_OF_MONTH DAY_OF_MONTH} will ensure that the date is + * resolved correctly, but without any cross-check for the day-of-week. + *

    + * In implementation terms, this method behaves as follows. The result of the + * parsing phase can be considered to be a map of field to value. The behavior + * of this method is to cause that map to be filtered between phase 1 and 2, + * removing all fields other than those specified as arguments to this method. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverFields the new set of resolver fields, null if no fields + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverFields(Set resolverFields) { + Objects.requireNonNull(resolverFields, "resolverFields"); + if (Objects.equals(this.resolverFields, resolverFields)) { + return this; + } + resolverFields = Collections.unmodifiableSet(new HashSet<>(resolverFields)); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -1151,7 +1615,7 @@ public TemporalAccessor parse(CharSequence text) { Objects.requireNonNull(text, "text"); try { - return parseToBuilder(text, null).resolve(); + return parseResolved0(text, null); } catch (DateTimeParseException ex) { throw ex; } catch (RuntimeException ex) { @@ -1193,7 +1657,7 @@ Objects.requireNonNull(text, "text"); Objects.requireNonNull(position, "position"); try { - return parseToBuilder(text, position).resolve(); + return parseResolved0(text, position); } catch (DateTimeParseException | IndexOutOfBoundsException ex) { throw ex; } catch (RuntimeException ex) { @@ -1225,8 +1689,7 @@ Objects.requireNonNull(text, "text"); Objects.requireNonNull(query, "query"); try { - DateTimeBuilder builder = parseToBuilder(text, null).resolve(); - return builder.query(query); + return parseResolved0(text, null).query(query); } catch (DateTimeParseException ex) { throw ex; } catch (RuntimeException ex) { @@ -1238,7 +1701,7 @@ * Fully parses the text producing an object of one of the specified types. *

    * This parse method is convenient for use when the parser can handle optional elements. - * For example, a pattern of 'yyyy-MM-dd HH.mm[Z]]' can be fully parsed to a {@code ZonedDateTime}, + * For example, a pattern of 'uuuu-MM-dd HH.mm[ VV]' can be fully parsed to a {@code ZonedDateTime}, * or partially parsed to a {@code LocalDateTime}. * The queries must be specified in order, starting from the best matching full-parse option * and ending with the worst matching minimal parse option. @@ -1272,10 +1735,10 @@ throw new IllegalArgumentException("At least two queries must be specified"); } try { - DateTimeBuilder builder = parseToBuilder(text, null).resolve(); + TemporalAccessor resolved = parseResolved0(text, null); for (TemporalQuery query : queries) { try { - return (TemporalAccessor) builder.query(query); + return (TemporalAccessor) resolved.query(query); } catch (RuntimeException ex) { // continue } @@ -1289,7 +1752,7 @@ } private DateTimeParseException createError(CharSequence text, RuntimeException ex) { - String abbr = ""; + String abbr; if (text.length() > 64) { abbr = text.subSequence(0, 64).toString() + "..."; } else { @@ -1300,23 +1763,23 @@ //----------------------------------------------------------------------- /** - * Parses the text to a builder. + * Parses and resolves the specified text. *

    - * This parses to a {@code DateTimeBuilder} ensuring that the text is fully parsed. - * This method throws {@link DateTimeParseException} if unable to parse, or - * some other {@code DateTimeException} if another date/time problem occurs. + * This parses to a {@code TemporalAccessor} ensuring that the text is fully parsed. * * @param text the text to parse, not null * @param position the position to parse from, updated with length parsed * and the index of any error, null if parsing whole string - * @return the engine representing the result of the parse, not null + * @return the resolved result of the parse, not null * @throws DateTimeParseException if the parse fails + * @throws DateTimeException if an error occurs while resolving the date or time + * @throws IndexOutOfBoundsException if the position is invalid */ - private DateTimeBuilder parseToBuilder(final CharSequence text, final ParsePosition position) { + private TemporalAccessor parseResolved0(final CharSequence text, final ParsePosition position) { ParsePosition pos = (position != null ? position : new ParsePosition(0)); - DateTimeParseContext result = parseUnresolved0(text, pos); - if (result == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) { - String abbr = ""; + Parsed unresolved = parseUnresolved0(text, pos); + if (unresolved == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) { + String abbr; if (text.length() > 64) { abbr = text.subSequence(0, 64).toString() + "..."; } else { @@ -1330,7 +1793,7 @@ pos.getIndex(), text, pos.getIndex()); } } - return result.resolveFields().toBuilder(); + return unresolved.resolve(resolverStyle, resolverFields); } /** @@ -1376,7 +1839,7 @@ return parseUnresolved0(text, position); } - private DateTimeParseContext parseUnresolved0(CharSequence text, ParsePosition position) { + private Parsed parseUnresolved0(CharSequence text, ParsePosition position) { Objects.requireNonNull(text, "text"); Objects.requireNonNull(position, "position"); DateTimeParseContext context = new DateTimeParseContext(this); @@ -1387,7 +1850,7 @@ return null; } position.setIndex(pos); // errorIndex not updated from input - return context; + return context.toParsed(); } //----------------------------------------------------------------------- @@ -1496,7 +1959,7 @@ Objects.requireNonNull(text, "text"); try { if (parseType == null) { - return formatter.parseToBuilder(text, null).resolve(); + return formatter.parseResolved0(text, null); } return formatter.parse(text, parseType); } catch (DateTimeParseException ex) { @@ -1508,7 +1971,7 @@ @Override public Object parseObject(String text, ParsePosition pos) { Objects.requireNonNull(text, "text"); - DateTimeParseContext unresolved; + Parsed unresolved; try { unresolved = formatter.parseUnresolved0(text, pos); } catch (IndexOutOfBoundsException ex) { @@ -1524,11 +1987,11 @@ return null; } try { - DateTimeBuilder builder = unresolved.resolveFields().toBuilder().resolve(); + TemporalAccessor resolved = unresolved.resolve(formatter.resolverStyle, formatter.resolverFields); if (parseType == null) { - return builder; + return resolved; } - return builder.query(parseType); + return resolved.query(parseType); } catch (RuntimeException ex) { pos.setErrorIndex(0); return null; --- old/src/share/classes/java/time/format/DateTimeFormatterBuilder.java 2013-04-11 23:15:44.000000000 -0700 +++ new/src/share/classes/java/time/format/DateTimeFormatterBuilder.java 2013-04-11 23:15:44.000000000 -0700 @@ -83,11 +83,9 @@ import java.time.ZoneOffset; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; -import java.time.chrono.JapaneseChronology; import java.time.format.DateTimeTextProvider.LocaleStore; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -111,7 +109,10 @@ import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.TimeZoneNameUtility; /** @@ -129,6 +130,8 @@ *

  • OffsetId/Offset - the {@linkplain ZoneOffset zone offset}
  • *
  • ZoneId - the {@linkplain ZoneId time-zone} id
  • *
  • ZoneText - the name of the time-zone
  • + *
  • ChronologyId - the {@linkplain Chronology chronology} id
  • + *
  • ChronologyText - the name of the chronology
  • *
  • Literal - a text literal
  • *
  • Nested and Optional - formats can be nested or made optional
  • *
  • Other - the printer and parser interfaces can be used to add user supplied formatting
  • @@ -150,7 +153,7 @@ * Query for a time-zone that is region-only. */ private static final TemporalQuery QUERY_REGION_ONLY = (temporal) -> { - ZoneId zone = temporal.query(Queries.zoneId()); + ZoneId zone = temporal.query(TemporalQuery.zoneId()); return (zone != null && zone instanceof ZoneOffset == false ? zone : null); }; @@ -288,6 +291,40 @@ //----------------------------------------------------------------------- /** + * Appends a default value for a field to the formatter for use in parsing. + *

    + * This appends an instruction to the builder to inject a default value + * into the parsed result. This is especially useful in conjunction with + * optional parts of the formatter. + *

    + * For example, consider a formatter that parses the year, followed by + * an optional month, with a further optional day-of-month. Using such a + * formatter would require the calling code to check whether a full date, + * year-month or just a year had been parsed. This method can be used to + * default the month and day-of-month to a sensible value, such as the + * first of the month, allowing the calling code to always get a date. + *

    + * During formatting, this method has no effect. + *

    + * During parsing, the current state of the parse is inspected. + * If the specified field has no associated value, because it has not been + * parsed successfully at that point, then the specified value is injected + * into the parse result. Injection is immediate, thus the field-value pair + * will be visible to any subsequent elements in the formatter. + * As such, this method is normally called at the end of the builder. + * + * @param field the field to default the value of, not null + * @param value the value to default the field to + * @return this, for chaining, not null + */ + public DateTimeFormatterBuilder parseDefaulting(TemporalField field, long value) { + Objects.requireNonNull(field, "field"); + appendInternal(new DefaultValueParser(field, value)); + return this; + } + + //----------------------------------------------------------------------- + /** * Appends the value of a date-time field to the formatter using a normal * output style. *

    @@ -655,7 +692,7 @@ * This appends an instruction to format/parse the offset ID to the builder. *

    * During formatting, the offset is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#offset()}. + * to querying the temporal with {@link TemporalQuery#offset()}. * It will be printed using the format defined below. * If the offset cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -692,6 +729,44 @@ return this; } + /** + * Appends the localized zone offset, such as 'GMT+01:00', to the formatter. + *

    + * This appends a localized zone offset to the builder, the format of the + * localized offset is controlled by the specified {@link FormatStyle style} + * to this method: + *

      + *
    • {@link TextStyle#FULL full} - formats with localized offset text, such + * as 'GMT, 2-digit hour and minute field, optional second field if non-zero, + * and colon. + *
    • {@link TextStyle#SHORT short} - formats with localized offset text, + * such as 'GMT, hour without leading zero, optional 2-digit minute and + * second if non-zero, and colon. + *

    + *

    + * During formatting, the offset is obtained using a mechanism equivalent + * to querying the temporal with {@link TemporalQuery#offset()}. + * If the offset cannot be obtained then an exception is thrown unless the + * section of the formatter is optional. + *

    + * During parsing, the offset is parsed using the format defined above. + * If the offset cannot be parsed then an exception is thrown unless the + * section of the formatter is optional. + *

    + * @param style the format style to use, not null + * @return this, for chaining, not null + * @throws IllegalArgumentException if style is neither {@link TextStyle#FULL + * full} nor {@link TextStyle#SHORT short} + */ + public DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style) { + Objects.requireNonNull(style, "style"); + if (style != TextStyle.FULL && style != TextStyle.SHORT) { + throw new IllegalArgumentException("Style must be either full or short"); + } + appendInternal(new LocalizedOffsetIdPrinterParser(style)); + return this; + } + //----------------------------------------------------------------------- /** * Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter. @@ -702,7 +777,7 @@ * for use with this method, see {@link #appendZoneOrOffsetId()}. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * It will be printed using the result of {@link ZoneId#getId()}. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -725,25 +800,25 @@ *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    * * @return this, for chaining, not null * @see #appendZoneRegionId() */ public DateTimeFormatterBuilder appendZoneId() { - appendInternal(new ZoneIdPrinterParser(Queries.zoneId(), "ZoneId()")); + appendInternal(new ZoneIdPrinterParser(TemporalQuery.zoneId(), "ZoneId()")); return this; } @@ -755,7 +830,7 @@ * only if it is a region-based ID. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} or it cannot be obtained then * an exception is thrown unless the section of the formatter is optional. * If the zone is not an offset, then the zone will be printed using @@ -779,18 +854,18 @@ *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    *

    * Note that this method is is identical to {@code appendZoneId()} except @@ -817,7 +892,7 @@ * then attempts to find an offset, such as that on {@code OffsetDateTime}. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zone()}. + * to querying the temporal with {@link TemporalQuery#zone()}. * It will be printed using the result of {@link ZoneId#getId()}. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -840,18 +915,18 @@ *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    *

    * Note that this method is is identical to {@code appendZoneId()} except @@ -861,7 +936,7 @@ * @see #appendZoneId() */ public DateTimeFormatterBuilder appendZoneOrOffsetId() { - appendInternal(new ZoneIdPrinterParser(Queries.zone(), "ZoneOrOffsetId()")); + appendInternal(new ZoneIdPrinterParser(TemporalQuery.zone(), "ZoneOrOffsetId()")); return this; } @@ -872,7 +947,7 @@ * the builder. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} it will be printed using the * result of {@link ZoneOffset#getId()}. * If the zone is not an offset, the textual name will be looked up @@ -908,7 +983,7 @@ * the builder. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} it will be printed using the * result of {@link ZoneOffset#getId()}. * If the zone is not an offset, the textual name will be looked up @@ -951,7 +1026,7 @@ * This appends an instruction to format/parse the chronology ID to the builder. *

    * During formatting, the chronology is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#chronology()}. + * to querying the temporal with {@link TemporalQuery#chronology()}. * It will be printed using the result of {@link Chronology#getId()}. * If the chronology cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -1098,24 +1173,25 @@ * Appends the elements defined by the specified pattern to the builder. *

    * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. - * The characters '{' and '}' are reserved for future use. + * The characters '#', '{' and '}' are reserved for future use. * The characters '[' and ']' indicate optional patterns. * The following pattern letters are defined: *

          *  Symbol  Meaning                     Presentation      Examples
          *  ------  -------                     ------------      -------
    -     *   G       era                         text              A; AD; Anno Domini
    -     *   y       year                        year              2004; 04
    +     *   G       era                         text              AD; Anno Domini; A
    +     *   u       year                        year              2004; 04
    +     *   y       year-of-era                 year              2004; 04
          *   D       day-of-year                 number            189
    -     *   M       month-of-year               number/text       7; 07; Jul; July; J
    +     *   M/L     month-of-year               number/text       7; 07; Jul; July; J
          *   d       day-of-month                number            10
          *
    -     *   Q       quarter-of-year             number/text       3; 03; Q3
    +     *   Q/q     quarter-of-year             number/text       3; 03; Q3; 3rd quarter
          *   Y       week-based-year             year              1996; 96
    -     *   w       week-of-year                number            27
    -     *   W       week-of-month               number            27
    -     *   e       localized day-of-week       number            2; Tue; Tuesday; T
    -     *   E       day-of-week                 number/text       2; Tue; Tuesday; T
    +     *   w       week-of-week-based-year     number            27
    +     *   W       week-of-month               number            4
    +     *   E       day-of-week                 text              Tue; Tuesday; T
    +     *   e/c     localized day-of-week       number/text       2; 02; Tue; Tuesday; T
          *   F       week-of-month               number            3
          *
          *   a       am-pm-of-day                text              PM
    @@ -1133,6 +1209,7 @@
          *
          *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
          *   z       time-zone name              zone-name         Pacific Standard Time; PST
    +     *   O       localized zone-offset       offset-O          GMT+8; GMT+08:00; UTC-08:00;
          *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
          *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
          *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    @@ -1143,116 +1220,169 @@
          *   ''      single quote                literal           '
          *   [       optional section start
          *   ]       optional section end
    -     *   {}      reserved for future use
    +     *   #       reserved for future use
    +     *   {       reserved for future use
    +     *   }       reserved for future use
          * 
    *

    * The count of pattern letters determine the format. + * See DateTimeFormatter for a user-focused description of the patterns. + * The following tables define how the pattern letters map to the builder. *

    - * Text: The text style is determined based on the number of pattern letters used. - * Less than 4 pattern letters will use the {@link TextStyle#SHORT short form}. - * Exactly 4 pattern letters will use the {@link TextStyle#FULL full form}. - * Exactly 5 pattern letters will use the {@link TextStyle#NARROW narrow form}. - *

    - * Number: If the count of letters is one, then the value is printed using the minimum number - * of digits and without padding as per {@link #appendValue(java.time.temporal.TemporalField)}. Otherwise, the - * count of digits is used as the width of the output field as per {@link #appendValue(java.time.temporal.TemporalField, int)}. - *

    - * Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. - * Otherwise use the Number rules above. - *

    - * Fraction: Outputs the nano-of-second field as a fraction-of-second. - * The nano-of-second value has nine digits, thus the count of pattern letters is from 1 to 9. - * If it is less than 9, then the nano-of-second value is truncated, with only the most - * significant digits being output. - * When parsing in strict mode, the number of parsed digits must match the count of pattern letters. - * When parsing in lenient mode, the number of parsed digits must be at least the count of pattern - * letters, up to 9 digits. - *

    - * Year: The count of letters determines the minimum field width below which padding is used. - * If the count of letters is two, then a {@link #appendValueReduced reduced} two digit form is used. - * For formatting, this outputs the rightmost two digits. For parsing, this will parse using the - * base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. - * If the count of letters is less than four (but not two), then the sign is only output for negative - * years as per {@link SignStyle#NORMAL}. - * Otherwise, the sign is output if the pad width is exceeded, as per {@link SignStyle#EXCEEDS_PAD} - *

    - * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. - * If the count of letters is two, then the time-zone ID is output. - * Any other count of letters throws {@code IllegalArgumentException}. + * Date fields: Pattern letters to output a date. *

    -     *  Pattern     Equivalent builder methods
    -     *   VV          appendZoneId()
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    G       1      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GG      2      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GGG     3      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GGGG    4      appendText(ChronoField.ERA, TextStyle.FULL)
    +     *    GGGGG   5      appendText(ChronoField.ERA, TextStyle.NARROW)
    +     *
    +     *    u       1      appendValue(ChronoField.YEAR, 1, 19, SignStyle.NORMAL);
    +     *    uu      2      appendValueReduced(ChronoField.YEAR, 2, 2000);
    +     *    uuu     3      appendValue(ChronoField.YEAR, 3, 19, SignStyle.NORMAL);
    +     *    u..u    4..n   appendValue(ChronoField.YEAR, n, 19, SignStyle.EXCEEDS_PAD);
    +     *    y       1      appendValue(ChronoField.YEAR_OF_ERA, 1, 19, SignStyle.NORMAL);
    +     *    yy      2      appendValueReduced(ChronoField.YEAR_OF_ERA, 2, 2000);
    +     *    yyy     3      appendValue(ChronoField.YEAR_OF_ERA, 3, 19, SignStyle.NORMAL);
    +     *    y..y    4..n   appendValue(ChronoField.YEAR_OF_ERA, n, 19, SignStyle.EXCEEDS_PAD);
    +     *    Y       1      append special localized WeekFields element for numeric week-based-year
    +     *    YY      2      append special localized WeekFields element for reduced numeric week-based-year 2 digits;
    +     *    YYY     3      append special localized WeekFields element for numeric week-based-year (3, 19, SignStyle.NORMAL);
    +     *    Y..Y    4..n   append special localized WeekFields element for numeric week-based-year (n, 19, SignStyle.EXCEEDS_PAD);
    +     *
    +     *    Q       1      appendValue(IsoFields.QUARTER_OF_YEAR);
    +     *    QQ      2      appendValue(IsoFields.QUARTER_OF_YEAR, 2);
    +     *    QQQ     3      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT)
    +     *    QQQQ    4      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL)
    +     *    QQQQQ   5      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW)
    +     *    q       1      appendValue(IsoFields.QUARTER_OF_YEAR);
    +     *    qq      2      appendValue(IsoFields.QUARTER_OF_YEAR, 2);
    +     *    qqq     3      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT_STANDALONE)
    +     *    qqqq    4      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL_STANDALONE)
    +     *    qqqqq   5      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW_STANDALONE)
    +     *
    +     *    M       1      appendValue(ChronoField.MONTH_OF_YEAR);
    +     *    MM      2      appendValue(ChronoField.MONTH_OF_YEAR, 2);
    +     *    MMM     3      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT)
    +     *    MMMM    4      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL)
    +     *    MMMMM   5      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW)
    +     *    L       1      appendValue(ChronoField.MONTH_OF_YEAR);
    +     *    LL      2      appendValue(ChronoField.MONTH_OF_YEAR, 2);
    +     *    LLL     3      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE)
    +     *    LLLL    4      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL_STANDALONE)
    +     *    LLLLL   5      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE)
    +     *
    +     *    w       1      append special localized WeekFields element for numeric week-of-year
    +     *    ww      1      append special localized WeekFields element for numeric week-of-year, zero-padded
    +     *    W       1      append special localized WeekFields element for numeric week-of-month
    +     *    d       1      appendValue(ChronoField.DAY_OF_MONTH)
    +     *    dd      2      appendValue(ChronoField.DAY_OF_MONTH, 2)
    +     *    D       1      appendValue(ChronoField.DAY_OF_YEAR)
    +     *    DD      2      appendValue(ChronoField.DAY_OF_YEAR, 2)
    +     *    DDD     3      appendValue(ChronoField.DAY_OF_YEAR, 3)
    +     *    F       1      appendValue(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)
    +     *    E       1      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EE      2      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EEE     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EEEE    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL)
    +     *    EEEEE   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW)
    +     *    e       1      append special localized WeekFields element for numeric day-of-week
    +     *    ee      2      append special localized WeekFields element for numeric day-of-week, zero-padded
    +     *    eee     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    eeee    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL)
    +     *    eeeee   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW)
    +     *    c       1      append special localized WeekFields element for numeric day-of-week
    +     *    ccc     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT_STANDALONE)
    +     *    cccc    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL_STANDALONE)
    +     *    ccccc   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW_STANDALONE)
          * 
    *

    - * Zone names: This outputs the display name of the time-zone ID. - * If the count of letters is one, two or three, then the short name is output. - * If the count of letters is four, then the full name is output. - * Five or more letters throws {@code IllegalArgumentException}. + * Time fields: Pattern letters to output a time. *

    -     *  Pattern     Equivalent builder methods
    -     *   z           appendZoneText(TextStyle.SHORT)
    -     *   zz          appendZoneText(TextStyle.SHORT)
    -     *   zzz         appendZoneText(TextStyle.SHORT)
    -     *   zzzz        appendZoneText(TextStyle.FULL)
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    a       1      appendText(ChronoField.AMPM_OF_DAY, TextStyle.SHORT)
    +     *    h       1      appendValue(ChronoField.CLOCK_HOUR_OF_AMPM)
    +     *    hh      2      appendValue(ChronoField.CLOCK_HOUR_OF_AMPM, 2)
    +     *    H       1      appendValue(ChronoField.HOUR_OF_DAY)
    +     *    HH      2      appendValue(ChronoField.HOUR_OF_DAY, 2)
    +     *    k       1      appendValue(ChronoField.CLOCK_HOUR_OF_DAY)
    +     *    kk      2      appendValue(ChronoField.CLOCK_HOUR_OF_DAY, 2)
    +     *    K       1      appendValue(ChronoField.HOUR_OF_AMPM)
    +     *    KK      2      appendValue(ChronoField.HOUR_OF_AMPM, 2)
    +     *    m       1      appendValue(ChronoField.MINUTE_OF_HOUR)
    +     *    mm      2      appendValue(ChronoField.MINUTE_OF_HOUR, 2)
    +     *    s       1      appendValue(ChronoField.SECOND_OF_MINUTE)
    +     *    ss      2      appendValue(ChronoField.SECOND_OF_MINUTE, 2)
    +     *
    +     *    S..S    1..n   appendFraction(ChronoField.NANO_OF_SECOND, n, n, false)
    +     *    A       1      appendValue(ChronoField.MILLI_OF_DAY)
    +     *    A..A    2..n   appendValue(ChronoField.MILLI_OF_DAY, n)
    +     *    n       1      appendValue(ChronoField.NANO_OF_SECOND)
    +     *    n..n    2..n   appendValue(ChronoField.NANO_OF_SECOND, n)
    +     *    N       1      appendValue(ChronoField.NANO_OF_DAY)
    +     *    N..N    2..n   appendValue(ChronoField.NANO_OF_DAY, n)
          * 
    *

    - * Offset X and x: This formats the offset based on the number of pattern letters. - * One letter outputs just the hour', such as '+01', unless the minute is non-zero - * in which case the minute is also output, such as '+0130'. - * Two letters outputs the hour and minute, without a colon, such as '+0130'. - * Three letters outputs the hour and minute, with a colon, such as '+01:30'. - * Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. - * Five letters outputs the hour and minute and optional second, with a colon, such as '+01:30:15'. - * Six or more letters throws {@code IllegalArgumentException}. - * Pattern letter 'X' (upper case) will output 'Z' when the offset to be output would be zero, - * whereas pattern letter 'x' (lower case) will output '+00', '+0000', or '+00:00'. + * Zone ID: Pattern letters to output {@code ZoneId}. *

    -     *  Pattern     Equivalent builder methods
    -     *   X           appendOffset("+HHmm","Z")
    -     *   XX          appendOffset("+HHMM","Z")
    -     *   XXX         appendOffset("+HH:MM","Z")
    -     *   XXXX        appendOffset("+HHMMss","Z")
    -     *   XXXXX       appendOffset("+HH:MM:ss","Z")
    -     *   x           appendOffset("+HHmm","+00")
    -     *   xx          appendOffset("+HHMM","+0000")
    -     *   xxx         appendOffset("+HH:MM","+00:00")
    -     *   xxxx        appendOffset("+HHMMss","+0000")
    -     *   xxxxx       appendOffset("+HH:MM:ss","+00:00")
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    VV      2      appendZoneId()
    +     *    z       1      appendZoneText(TextStyle.SHORT)
    +     *    zz      2      appendZoneText(TextStyle.SHORT)
    +     *    zzz     3      appendZoneText(TextStyle.SHORT)
    +     *    zzzz    4      appendZoneText(TextStyle.FULL)
          * 
    *

    - * Offset Z: This formats the offset based on the number of pattern letters. - * One, two or three letters outputs the hour and minute, without a colon, such as '+0130'. - * Four or more letters throws {@code IllegalArgumentException}. - * The output will be '+0000' when the offset is zero. + * Zone offset: Pattern letters to output {@code ZoneOffset}. *

    -     *  Pattern     Equivalent builder methods
    -     *   Z           appendOffset("+HHMM","+0000")
    -     *   ZZ          appendOffset("+HHMM","+0000")
    -     *   ZZZ         appendOffset("+HHMM","+0000")
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    O       1      appendLocalizedOffsetPrefixed(TextStyle.SHORT);
    +     *    OOOO    4      appendLocalizedOffsetPrefixed(TextStyle.FULL);
    +     *    X       1      appendOffset("+HHmm","Z")
    +     *    XX      2      appendOffset("+HHMM","Z")
    +     *    XXX     3      appendOffset("+HH:MM","Z")
    +     *    XXXX    4      appendOffset("+HHMMss","Z")
    +     *    XXXXX   5      appendOffset("+HH:MM:ss","Z")
    +     *    x       1      appendOffset("+HHmm","+00")
    +     *    xx      2      appendOffset("+HHMM","+0000")
    +     *    xxx     3      appendOffset("+HH:MM","+00:00")
    +     *    xxxx    4      appendOffset("+HHMMss","+0000")
    +     *    xxxxx   5      appendOffset("+HH:MM:ss","+00:00")
    +     *    Z       1      appendOffset("+HHMM","+0000")
    +     *    ZZ      2      appendOffset("+HHMM","+0000")
    +     *    ZZZ     3      appendOffset("+HHMM","+0000")
    +     *    ZZZZ    4      appendLocalizedOffset(TextStyle.FULL);
    +     *    ZZZZZ   5      appendOffset("+HH:MM:ss","Z")
          * 
    *

    - * Optional section: The optional section markers work exactly like calling {@link #optionalStart()} - * and {@link #optionalEnd()}. + * Modifiers: Pattern letters that modify the rest of the pattern: + *

    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    [       1      optionalStart()
    +     *    ]       1      optionalEnd()
    +     *    p..p    1..n   padNext(n)
    +     * 
    *

    - * Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. - * The pad width is determined by the number of pattern letters. - * This is the same as calling {@link #padNext(int)}. - *

    - * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2. - *

    - * Any unrecognized letter is an error. - * Any non-letter character, other than '[', ']', '{', '}' and the single quote will be output directly. - * Despite this, it is recommended to use single quotes around all characters that you want to - * output directly to ensure that future changes do not break your application. + * Any sequence of letters not specified above, unrecognized letter or + * reserved character will throw an exception. + * Future versions may add to the set of patterns. + * It is recommended to use single quotes around all characters that you want + * to output directly to ensure that future changes do not break your application. *

    * Note that the pattern string is similar, but not identical, to * {@link java.text.SimpleDateFormat SimpleDateFormat}. * The pattern string is also similar, but not identical, to that defined by the * Unicode Common Locale Data Repository (CLDR/LDML). - * Pattern letters 'E' and 'u' are merged, which changes the meaning of "E" and "EE" to be numeric. - * Pattern letters 'X' is aligned with Unicode CLDR/LDML, which affects pattern 'X'. - * Pattern letter 'y' and 'Y' parse years of two digits and more than 4 digits differently. - * Pattern letters 'n', 'A', 'N', 'I' and 'p' are added. + * Pattern letters 'X' and 'u' are aligned with Unicode CLDR/LDML. + * By contrast, {@code SimpleDateFormat} uses 'u' for the numeric day of week. + * Pattern letters 'y' and 'Y' parse years of two digits and more than 4 digits differently. + * Pattern letters 'n', 'A', 'N', and 'p' are added. * Number types will reject large numbers. * * @param pattern the pattern to add, not null @@ -1308,10 +1438,23 @@ } appendZoneId(); } else if (cur == 'Z') { - if (count > 3) { + if (count < 4) { + appendOffset("+HHMM", "+0000"); + } else if (count == 4) { + appendLocalizedOffset(TextStyle.FULL); + } else if (count == 5) { + appendOffset("+HH:MM:ss","Z"); + } else { throw new IllegalArgumentException("Too many pattern letters: " + cur); } - appendOffset("+HHMM", "+0000"); + } else if (cur == 'O') { + if (count == 1) { + appendLocalizedOffset(TextStyle.SHORT); + } else if (count == 4) { + appendLocalizedOffset(TextStyle.FULL); + } else { + throw new IllegalArgumentException("Pattern letter count must be 1 or 4: " + cur); + } } else if (cur == 'X') { if (count > 5) { throw new IllegalArgumentException("Too many pattern letters: " + cur); @@ -1323,18 +1466,21 @@ } String zero = (count == 1 ? "+00" : (count % 2 == 0 ? "+0000" : "+00:00")); appendOffset(OffsetIdPrinterParser.PATTERNS[count + (count == 1 ? 0 : 1)], zero); - } else if (cur == 'w' || cur == 'e') { + } else if (cur == 'W') { // Fields defined by Locale if (count > 1) { throw new IllegalArgumentException("Too many pattern letters: " + cur); } appendInternal(new WeekBasedFieldPrinterParser(cur, count)); - } else if (cur == 'W') { + } else if (cur == 'w') { // Fields defined by Locale if (count > 2) { throw new IllegalArgumentException("Too many pattern letters: " + cur); } appendInternal(new WeekBasedFieldPrinterParser(cur, count)); + } else if (cur == 'Y') { + // Fields defined by Locale + appendInternal(new WeekBasedFieldPrinterParser(cur, count)); } else { throw new IllegalArgumentException("Unknown pattern letter: " + cur); } @@ -1371,7 +1517,7 @@ } optionalEnd(); - } else if (cur == '{' || cur == '}') { + } else if (cur == '{' || cur == '}' || cur == '#') { throw new IllegalArgumentException("Pattern includes reserved character: '" + cur + "'"); } else { appendLiteral(cur); @@ -1379,10 +1525,12 @@ } } + @SuppressWarnings("fallthrough") private void parseField(char cur, int count, TemporalField field) { + boolean standalone = false; switch (cur) { + case 'u': case 'y': - case 'Y': if (count == 2) { appendValueReduced(field, 2, 2000); } else if (count < 4) { @@ -1391,31 +1539,55 @@ appendValue(field, count, 19, SignStyle.EXCEEDS_PAD); } break; + case 'c': + if (count == 2) { + throw new IllegalArgumentException("Invalid pattern \"cc\""); + } + /*fallthrough*/ + case 'L': + case 'q': + standalone = true; + /*fallthrough*/ case 'M': case 'Q': case 'E': + case 'e': switch (count) { case 1: - appendValue(field); - break; case 2: - appendValue(field, 2); + if (cur == 'c' || cur == 'e') { + appendInternal(new WeekBasedFieldPrinterParser(cur, count)); + } else if (cur == 'E') { + appendText(field, TextStyle.SHORT); + } else { + if (count == 1) { + appendValue(field); + } else { + appendValue(field, 2); + } + } break; case 3: - appendText(field, TextStyle.SHORT); + appendText(field, standalone ? TextStyle.SHORT_STANDALONE : TextStyle.SHORT); break; case 4: - appendText(field, TextStyle.FULL); + appendText(field, standalone ? TextStyle.FULL_STANDALONE : TextStyle.FULL); break; case 5: - appendText(field, TextStyle.NARROW); + appendText(field, standalone ? TextStyle.NARROW_STANDALONE : TextStyle.NARROW); break; default: throw new IllegalArgumentException("Too many pattern letters: " + cur); } break; - case 'G': case 'a': + if (count == 1) { + appendText(field, TextStyle.SHORT); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'G': switch (count) { case 1: case 2: @@ -1435,6 +1607,37 @@ case 'S': appendFraction(NANO_OF_SECOND, count, count, false); break; + case 'F': + if (count == 1) { + appendValue(field); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'd': + case 'h': + case 'H': + case 'k': + case 'K': + case 'm': + case 's': + if (count == 1) { + appendValue(field); + } else if (count == 2) { + appendValue(field, count); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'D': + if (count == 1) { + appendValue(field); + } else if (count <= 3) { + appendValue(field, count); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; default: if (count == 1) { appendValue(field); @@ -1448,44 +1651,43 @@ /** Map of letters to fields. */ private static final Map FIELD_MAP = new HashMap<>(); static { - FIELD_MAP.put('G', ChronoField.ERA); // Java, LDML (different to both for 1/2 chars) - FIELD_MAP.put('y', ChronoField.YEAR); // LDML - // FIELD_MAP.put('y', ChronoField.YEAR_OF_ERA); // Java, LDML // TODO redefine from above - // FIELD_MAP.put('u', ChronoField.YEAR); // LDML // TODO - // FIELD_MAP.put('Y', IsoFields.WEEK_BASED_YEAR); // Java7, LDML (needs localized week number) // TODO + // SDF = SimpleDateFormat + FIELD_MAP.put('G', ChronoField.ERA); // SDF, LDML (different to both for 1/2 chars) + FIELD_MAP.put('y', ChronoField.YEAR_OF_ERA); // SDF, LDML + FIELD_MAP.put('u', ChronoField.YEAR); // LDML (different in SDF) FIELD_MAP.put('Q', IsoFields.QUARTER_OF_YEAR); // LDML (removed quarter from 310) - FIELD_MAP.put('M', ChronoField.MONTH_OF_YEAR); // Java, LDML - // FIELD_MAP.put('w', WeekFields.weekOfYear()); // Java, LDML (needs localized week number) - // FIELD_MAP.put('W', WeekFields.weekOfMonth()); // Java, LDML (needs localized week number) - FIELD_MAP.put('D', ChronoField.DAY_OF_YEAR); // Java, LDML - FIELD_MAP.put('d', ChronoField.DAY_OF_MONTH); // Java, LDML - FIELD_MAP.put('F', ChronoField.ALIGNED_WEEK_OF_MONTH); // Java, LDML - FIELD_MAP.put('E', ChronoField.DAY_OF_WEEK); // Java, LDML (different to both for 1/2 chars) - // FIELD_MAP.put('e', WeekFields.dayOfWeek()); // LDML (needs localized week number) - FIELD_MAP.put('a', ChronoField.AMPM_OF_DAY); // Java, LDML - FIELD_MAP.put('H', ChronoField.HOUR_OF_DAY); // Java, LDML - FIELD_MAP.put('k', ChronoField.CLOCK_HOUR_OF_DAY); // Java, LDML - FIELD_MAP.put('K', ChronoField.HOUR_OF_AMPM); // Java, LDML - FIELD_MAP.put('h', ChronoField.CLOCK_HOUR_OF_AMPM); // Java, LDML - FIELD_MAP.put('m', ChronoField.MINUTE_OF_HOUR); // Java, LDML - FIELD_MAP.put('s', ChronoField.SECOND_OF_MINUTE); // Java, LDML - FIELD_MAP.put('S', ChronoField.NANO_OF_SECOND); // LDML (Java uses milli-of-second number) + FIELD_MAP.put('q', IsoFields.QUARTER_OF_YEAR); // LDML (stand-alone) + FIELD_MAP.put('M', ChronoField.MONTH_OF_YEAR); // SDF, LDML + FIELD_MAP.put('L', ChronoField.MONTH_OF_YEAR); // SDF, LDML (stand-alone) + FIELD_MAP.put('D', ChronoField.DAY_OF_YEAR); // SDF, LDML + FIELD_MAP.put('d', ChronoField.DAY_OF_MONTH); // SDF, LDML + FIELD_MAP.put('F', ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH); // SDF, LDML + FIELD_MAP.put('E', ChronoField.DAY_OF_WEEK); // SDF, LDML (different to both for 1/2 chars) + FIELD_MAP.put('c', ChronoField.DAY_OF_WEEK); // LDML (stand-alone) + FIELD_MAP.put('e', ChronoField.DAY_OF_WEEK); // LDML (needs localized week number) + FIELD_MAP.put('a', ChronoField.AMPM_OF_DAY); // SDF, LDML + FIELD_MAP.put('H', ChronoField.HOUR_OF_DAY); // SDF, LDML + FIELD_MAP.put('k', ChronoField.CLOCK_HOUR_OF_DAY); // SDF, LDML + FIELD_MAP.put('K', ChronoField.HOUR_OF_AMPM); // SDF, LDML + FIELD_MAP.put('h', ChronoField.CLOCK_HOUR_OF_AMPM); // SDF, LDML + FIELD_MAP.put('m', ChronoField.MINUTE_OF_HOUR); // SDF, LDML + FIELD_MAP.put('s', ChronoField.SECOND_OF_MINUTE); // SDF, LDML + FIELD_MAP.put('S', ChronoField.NANO_OF_SECOND); // LDML (SDF uses milli-of-second number) FIELD_MAP.put('A', ChronoField.MILLI_OF_DAY); // LDML FIELD_MAP.put('n', ChronoField.NANO_OF_SECOND); // 310 (proposed for LDML) FIELD_MAP.put('N', ChronoField.NANO_OF_DAY); // 310 (proposed for LDML) // 310 - z - time-zone names, matches LDML and SimpleDateFormat 1 to 4 // 310 - Z - matches SimpleDateFormat and LDML - // 310 - V - time-zone id, matches proposed LDML + // 310 - V - time-zone id, matches LDML // 310 - p - prefix for padding - // 310 - X - matches proposed LDML, almost matches JavaSDF for 1, exact match 2&3, extended 4&5 - // 310 - x - matches proposed LDML - // Java - u - clashes with LDML, go with LDML (year-proleptic) here + // 310 - X - matches LDML, almost matches SDF for 1, exact match 2&3, extended 4&5 + // 310 - x - matches LDML + // 310 - w, W, and Y are localized forms matching LDML // LDML - U - cycle year name, not supported by 310 yet // LDML - l - deprecated // LDML - j - not relevant // LDML - g - modified-julian-day // LDML - v,V - extended time-zone names - // LDML - q/c/L - standalone quarter/day-of-week/month } //----------------------------------------------------------------------- @@ -1632,10 +1834,12 @@ //----------------------------------------------------------------------- /** - * Completes this builder by creating the DateTimeFormatter using the default locale. + * Completes this builder by creating the {@code DateTimeFormatter} + * using the default locale. *

    - * This will create a formatter with the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. + * This will create a formatter with the {@linkplain Locale#getDefault(Locale.Category) default FORMAT locale}. * Numbers will be printed and parsed using the standard non-localized set of symbols. + * The resolver style will be {@link ResolverStyle#SMART SMART}. *

    * Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -1650,10 +1854,12 @@ } /** - * Completes this builder by creating the DateTimeFormatter using the specified locale. + * Completes this builder by creating the {@code DateTimeFormatter} + * using the specified locale. *

    * This will create a formatter with the specified locale. * Numbers will be printed and parsed using the standard non-localized set of symbols. + * The resolver style will be {@link ResolverStyle#SMART SMART}. *

    * Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -1665,12 +1871,35 @@ * @return the created formatter, not null */ public DateTimeFormatter toFormatter(Locale locale) { + return toFormatter(locale, ResolverStyle.SMART, null); + } + + /** + * Completes this builder by creating the formatter. + * This uses the default locale. + * + * @param resolverStyle the resolver style to use, not null + * @return the created formatter, not null + */ + DateTimeFormatter toFormatter(ResolverStyle resolverStyle, Chronology chrono) { + return toFormatter(Locale.getDefault(Locale.Category.FORMAT), resolverStyle, chrono); + } + + /** + * Completes this builder by creating the formatter. + * + * @param locale the locale to use for formatting, not null + * @param chrono the chronology to use, may be null + * @return the created formatter, not null + */ + private DateTimeFormatter toFormatter(Locale locale, ResolverStyle resolverStyle, Chronology chrono) { Objects.requireNonNull(locale, "locale"); while (active.parent != null) { optionalEnd(); } CompositePrinterParser pp = new CompositePrinterParser(printerParsers, false); - return new DateTimeFormatter(pp, locale, DateTimeFormatSymbols.STANDARD, null, null); + return new DateTimeFormatter(pp, locale, DateTimeFormatSymbols.STANDARD, + resolverStyle, null, chrono, null); } //----------------------------------------------------------------------- @@ -1942,6 +2171,31 @@ //----------------------------------------------------------------------- /** + * Defaults a value into the parse if not currently present. + */ + static class DefaultValueParser implements DateTimePrinterParser { + private final TemporalField field; + private final long value; + + DefaultValueParser(TemporalField field, long value) { + this.field = field; + this.value = value; + } + + public boolean format(DateTimePrintContext context, StringBuilder buf) { + return true; + } + + public int parse(DateTimeParseContext context, CharSequence text, int position) { + if (context.getParsed(field) == null) { + context.setParsedField(field, value, position, position); + } + return position; + } + } + + //----------------------------------------------------------------------- + /** * Prints or parses a character literal. */ static final class CharLiteralPrinterParser implements DateTimePrinterParser { @@ -2104,13 +2358,7 @@ @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - Chronology chrono = context.getTemporal().query(Queries.chronology()); - Long valueLong; - if (chrono == JapaneseChronology.INSTANCE && field == ChronoField.YEAR) { - valueLong = context.getValue(ChronoField.YEAR_OF_ERA); - } else { - valueLong = context.getValue(field); - } + Long valueLong = context.getValue(field); if (valueLong == null) { return false; } @@ -2281,14 +2529,7 @@ * @return the new position */ int setValue(DateTimeParseContext context, long value, int errorPos, int successPos) { - TemporalField f = field; - if (field == ChronoField.YEAR) { - Chronology chrono = context.getEffectiveChronology(); - if (chrono == JapaneseChronology.INSTANCE) { - f = ChronoField.YEAR_OF_ERA; - } - } - return context.setParsedField(f, value, errorPos, successPos); + return context.setParsedField(field, value, errorPos, successPos); } @Override @@ -2570,7 +2811,7 @@ return false; } String text; - Chronology chrono = context.getTemporal().query(Queries.chronology()); + Chronology chrono = context.getTemporal().query(TemporalQuery.chronology()); if (chrono == null || chrono == IsoChronology.INSTANCE) { text = provider.getText(field, value, textStyle, context.getLocale()); } else { @@ -2887,6 +3128,167 @@ //----------------------------------------------------------------------- /** + * Prints or parses an offset ID. + */ + static final class LocalizedOffsetIdPrinterParser implements DateTimePrinterParser { + private final TextStyle style; + + /** + * Constructor. + * + * @param style the style, not null + */ + LocalizedOffsetIdPrinterParser(TextStyle style) { + this.style = style; + } + + private static StringBuilder appendHMS(StringBuilder buf, int t) { + return buf.append((char)(t / 10 + '0')) + .append((char)(t % 10 + '0')); + } + + @Override + public boolean format(DateTimePrintContext context, StringBuilder buf) { + Long offsetSecs = context.getValue(OFFSET_SECONDS); + if (offsetSecs == null) { + return false; + } + String gmtText = "GMT"; // TODO: get localized version of 'GMT' + if (gmtText != null) { + buf.append(gmtText); + } + int totalSecs = Math.toIntExact(offsetSecs); + if (totalSecs != 0) { + int absHours = Math.abs((totalSecs / 3600) % 100); // anything larger than 99 silently dropped + int absMinutes = Math.abs((totalSecs / 60) % 60); + int absSeconds = Math.abs(totalSecs % 60); + buf.append(totalSecs < 0 ? "-" : "+"); + if (style == TextStyle.FULL) { + appendHMS(buf, absHours); + buf.append(':'); + appendHMS(buf, absMinutes); + if (absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absSeconds); + } + } else { + if (absHours >= 10) { + buf.append((char)(absHours / 10 + '0')); + } + buf.append((char)(absHours % 10 + '0')); + if (absMinutes != 0 || absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absMinutes); + if (absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absSeconds); + } + } + } + } + return true; + } + + int getDigit(CharSequence text, int position) { + char c = text.charAt(position); + if (c < '0' || c > '9') { + return -1; + } + return c - '0'; + } + + @Override + public int parse(DateTimeParseContext context, CharSequence text, int position) { + int pos = position; + int end = pos + text.length(); + String gmtText = "GMT"; // TODO: get localized version of 'GMT' + if (gmtText != null) { + if (!context.subSequenceEquals(text, pos, gmtText, 0, gmtText.length())) { + return ~position; + } + pos += gmtText.length(); + } + // parse normal plus/minus offset + int negative = 0; + if (pos == end) { + return context.setParsedField(OFFSET_SECONDS, 0, position, pos); + } + char sign = text.charAt(pos); // IOOBE if invalid position + if (sign == '+') { + negative = 1; + } else if (sign == '-') { + negative = -1; + } else { + return context.setParsedField(OFFSET_SECONDS, 0, position, pos); + } + pos++; + int h = 0; + int m = 0; + int s = 0; + if (style == TextStyle.FULL) { + int h1 = getDigit(text, pos++); + int h2 = getDigit(text, pos++); + if (h1 < 0 || h2 < 0 || text.charAt(pos++) != ':') { + return ~position; + } + h = h1 * 10 + h2; + int m1 = getDigit(text, pos++); + int m2 = getDigit(text, pos++); + if (m1 < 0 || m2 < 0) { + return ~position; + } + m = m1 * 10 + m2; + if (pos + 2 < end && text.charAt(pos) == ':') { + int s1 = getDigit(text, pos + 1); + int s2 = getDigit(text, pos + 2); + if (s1 >= 0 && s2 >= 0) { + s = s1 * 10 + s2; + pos += 3; + } + } + } else { + h = getDigit(text, pos++); + if (h < 0) { + return ~position; + } + if (pos < end) { + int h2 = getDigit(text, pos); + if (h2 >=0) { + h = h * 10 + h2; + pos++; + } + if (pos + 2 < end && text.charAt(pos) == ':') { + if (pos + 2 < end && text.charAt(pos) == ':') { + int m1 = getDigit(text, pos + 1); + int m2 = getDigit(text, pos + 2); + if (m1 >= 0 && m2 >= 0) { + m = m1 * 10 + m2; + pos += 3; + if (pos + 2 < end && text.charAt(pos) == ':') { + int s1 = getDigit(text, pos + 1); + int s2 = getDigit(text, pos + 2); + if (s1 >= 0 && s2 >= 0) { + s = s1 * 10 + s2; + pos += 3; + } + } + } + } + } + } + } + long offsetSecs = negative * (h * 3600L + m * 60L + s); + return context.setParsedField(OFFSET_SECONDS, offsetSecs, position, pos); + } + + @Override + public String toString() { + return "LocalizedOffset(" + style + ")"; + } + } + + //----------------------------------------------------------------------- + /** * Prints or parses a zone ID. */ static final class ZoneTextPrinterParser extends ZoneIdPrinterParser { @@ -2898,7 +3300,7 @@ private Set preferredZones; ZoneTextPrinterParser(TextStyle textStyle, Set preferredZones) { - super(Queries.zone(), "ZoneText(" + textStyle + ")"); + super(TemporalQuery.zone(), "ZoneText(" + textStyle + ")"); this.textStyle = Objects.requireNonNull(textStyle, "textStyle"); if (preferredZones != null && preferredZones.size() != 0) { this.preferredZones = new HashSet<>(); @@ -2929,12 +3331,12 @@ } names = Arrays.copyOfRange(names, 0, 7); names[5] = - TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG,locale); + TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = - TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT,locale); + TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } @@ -2946,16 +3348,16 @@ } switch (type) { case STD: - return names[textStyle.ordinal() + 1]; + return names[textStyle.zoneNameStyleIndex() + 1]; case DST: - return names[textStyle.ordinal() + 3]; + return names[textStyle.zoneNameStyleIndex() + 3]; } - return names[textStyle.ordinal() + 5]; + return names[textStyle.zoneNameStyleIndex() + 5]; } @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - ZoneId zone = context.getValue(Queries.zoneId()); + ZoneId zone = context.getValue(TemporalQuery.zoneId()); if (zone == null) { return false; } @@ -3507,14 +3909,14 @@ @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - Chronology chrono = context.getValue(Queries.chronology()); + Chronology chrono = context.getValue(TemporalQuery.chronology()); if (chrono == null) { return false; } if (textStyle == null) { buf.append(chrono.getId()); } else { - buf.append(chrono.getId()); // TODO: Use symbols + buf.append(getChronologyName(chrono, context.getLocale())); } return true; } @@ -3529,11 +3931,16 @@ Chronology bestMatch = null; int matchLen = -1; for (Chronology chrono : chronos) { - String id = chrono.getId(); - int idLen = id.length(); - if (idLen > matchLen && context.subSequenceEquals(text, position, id, 0, idLen)) { + String name; + if (textStyle == null) { + name = chrono.getId(); + } else { + name = getChronologyName(chrono, context.getLocale()); + } + int nameLen = name.length(); + if (nameLen > matchLen && context.subSequenceEquals(text, position, name, 0, nameLen)) { bestMatch = chrono; - matchLen = idLen; + matchLen = nameLen; } } if (bestMatch == null) { @@ -3542,6 +3949,22 @@ context.setParsed(bestMatch); return position + matchLen; } + + /** + * Returns the chronology name of the given chrono in the given locale + * if available, or the chronology Id otherwise. The regular ResourceBundle + * search path is used for looking up the chronology name. + * + * @param chrono the chronology, not null + * @param locale the locale, not null + * @return the chronology name of chrono in locale, or the id if no name is available + * @throws NullPointerException if chrono or locale is null + */ + private String getChronologyName(Chronology chrono, Locale locale) { + String key = "calendarname." + chrono.getCalendarType(); + String name = DateTimeTextProvider.getLocalizedResource(key, locale); + return name != null ? name : chrono.getId(); + } } //----------------------------------------------------------------------- @@ -3549,6 +3972,9 @@ * Prints or parses a localized pattern. */ static final class LocalizedPrinterParser implements DateTimePrinterParser { + /** Cache of formatters. */ + private static final ConcurrentMap FORMATTER_CACHE = new ConcurrentHashMap<>(16, 0.75f, 2); + private final FormatStyle dateStyle; private final FormatStyle timeStyle; @@ -3578,6 +4004,9 @@ /** * Gets the formatter to use. + *

    + * The formatter will be the most appropriate to use for the date and time style in the locale. + * For example, some locales will use the month name while others will use the number. * * @param locale the locale to use, not null * @param chrono the chronology to use, not null @@ -3585,8 +4014,32 @@ * @throws IllegalArgumentException if the formatter cannot be found */ private DateTimeFormatter formatter(Locale locale, Chronology chrono) { - return DateTimeFormatStyleProvider.getInstance() - .getFormatter(dateStyle, timeStyle, chrono, locale); + String key = chrono.getId() + '|' + locale.toString() + '|' + dateStyle + timeStyle; + DateTimeFormatter formatter = FORMATTER_CACHE.get(key); + if (formatter == null) { + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); + String pattern = lr.getJavaTimeDateTimePattern( + convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); + formatter = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(locale); + DateTimeFormatter old = FORMATTER_CACHE.putIfAbsent(key, formatter); + if (old != null) { + formatter = old; + } + } + return formatter; + } + + /** + * Converts the given FormatStyle to the java.text.DateFormat style. + * + * @param style the FormatStyle style + * @return the int style, or -1 if style is null, indicating unrequired + */ + private int convertStyle(FormatStyle style) { + if (style == null) { + return -1; + } + return style.ordinal(); // indices happen to align } @Override @@ -3596,7 +4049,6 @@ } } - //----------------------------------------------------------------------- /** * Prints or parses a localized pattern from a localized field. @@ -3641,14 +4093,23 @@ WeekFields weekDef = WeekFields.of(locale); TemporalField field = null; switch (chr) { + case 'Y': + field = weekDef.weekBasedYear(); + if (count == 2) { + return new ReducedPrinterParser(field, 2, 2000); + } else { + return new NumberPrinterParser(field, count, 19, + (count < 4) ? SignStyle.NORMAL : SignStyle.EXCEEDS_PAD, -1); + } case 'e': + case 'c': field = weekDef.dayOfWeek(); break; case 'w': - field = weekDef.weekOfMonth(); + field = weekDef.weekOfWeekBasedYear(); break; case 'W': - field = weekDef.weekOfYear(); + field = weekDef.weekOfMonth(); break; default: throw new IllegalStateException("unreachable"); @@ -3658,11 +4119,41 @@ @Override public String toString() { - return String.format("WeekBased(%c%d)", chr, count); + StringBuilder sb = new StringBuilder(30); + sb.append("Localized("); + if (chr == 'Y') { + if (count == 1) { + sb.append("WeekBasedYear"); + } else if (count == 2) { + sb.append("ReducedValue(WeekBasedYear,2,2000)"); + } else { + sb.append("WeekBasedYear,").append(count).append(",") + .append(19).append(",") + .append((count < 4) ? SignStyle.NORMAL : SignStyle.EXCEEDS_PAD); + } + } else { + switch (chr) { + case 'c': + case 'e': + sb.append("DayOfWeek"); + break; + case 'w': + sb.append("WeekOfWeekBasedYear"); + break; + case 'W': + sb.append("WeekOfMonth"); + break; + default: + break; + } + sb.append(","); + sb.append(count); + } + sb.append(")"); + return sb.toString(); } } - //------------------------------------------------------------------------- /** * Length comparator. @@ -3673,5 +4164,4 @@ return str1.length() == str2.length() ? str1.compareTo(str2) : str1.length() - str2.length(); } }; - } --- old/src/share/classes/java/time/format/DateTimeParseContext.java 2013-04-11 23:15:45.000000000 -0700 +++ new/src/share/classes/java/time/format/DateTimeParseContext.java 2013-04-11 23:15:45.000000000 -0700 @@ -61,19 +61,12 @@ */ package java.time.format; -import java.time.DateTimeException; import java.time.ZoneId; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; import java.util.ArrayList; -import java.util.HashMap; import java.util.Locale; -import java.util.Map; import java.util.Objects; /** @@ -83,8 +76,8 @@ * It has the ability to store and retrieve the parsed values and manage optional segments. * It also provides key information to the parsing methods. *

    - * Once parsing is complete, the {@link #toBuilder()} is typically used - * to obtain a builder that can combine the separate parsed fields into meaningful values. + * Once parsing is complete, the {@link #toParsed()} is used to obtain the data. + * It contains a method to resolve the separate parsed fields into meaningful values. * *

    Specification for implementors

    * This class is a mutable context intended for use from a single thread. @@ -93,7 +86,7 @@ * * @since 1.8 */ -final class DateTimeParseContext implements TemporalAccessor { +final class DateTimeParseContext { /** * The formatter, not null. @@ -306,6 +299,17 @@ return parsed.get(parsed.size() - 1); } + /** + * Gets the result of the parse. + * + * @return the result of the parse, not null + */ + Parsed toParsed() { + Parsed parsed = currentParsed(); + parsed.effectiveChrono = getEffectiveChronology(); + return parsed; + } + //----------------------------------------------------------------------- /** * Gets the first value that was parsed for the specified field. @@ -368,111 +372,6 @@ //----------------------------------------------------------------------- /** - * Returns a {@code DateTimeBuilder} that can be used to interpret - * the results of the parse. - *

    - * This method is typically used once parsing is complete to obtain the parsed data. - * Parsing will typically result in separate fields, such as year, month and day. - * The returned builder can be used to combine the parsed data into meaningful - * objects such as {@code LocalDate}, potentially applying complex processing - * to handle invalid parsed data. - * - * @return a new builder with the results of the parse, not null - */ - DateTimeBuilder toBuilder() { - Parsed parsed = currentParsed(); - DateTimeBuilder builder = new DateTimeBuilder(); - for (Map.Entry fv : parsed.fieldValues.entrySet()) { - builder.addFieldValue(fv.getKey(), fv.getValue()); - } - builder.addObject(getEffectiveChronology()); - if (parsed.zone != null) { - builder.addObject(parsed.zone); - } - return builder; - } - - /** - * Resolves the fields in this context. - * - * @return this, for method chaining - * @throws DateTimeException if resolving one field results in a value for - * another field that is in conflict - */ - DateTimeParseContext resolveFields() { - Parsed data = currentParsed(); - outer: - while (true) { - for (Map.Entry entry : data.fieldValues.entrySet()) { - TemporalField targetField = entry.getKey(); - Map changes = targetField.resolve(this, entry.getValue()); - if (changes != null) { - resolveMakeChanges(data, targetField, changes); - data.fieldValues.remove(targetField); // helps avoid infinite loops - continue outer; // have to restart to avoid concurrent modification - } - } - break; - } - return this; - } - - private void resolveMakeChanges(Parsed data, TemporalField targetField, Map changes) { - for (Map.Entry change : changes.entrySet()) { - TemporalField changeField = change.getKey(); - Long changeValue = change.getValue(); - Objects.requireNonNull(changeField, "changeField"); - if (changeValue != null) { - Long old = currentParsed().fieldValues.put(changeField, changeValue); - if (old != null && old.longValue() != changeValue.longValue()) { - throw new DateTimeException("Conflict found: " + changeField + " " + old + - " differs from " + changeField + " " + changeValue + - " while resolving " + targetField); - } - } else { - data.fieldValues.remove(changeField); - } - } - } - - //----------------------------------------------------------------------- - // TemporalAccessor methods - // should only to be used once parsing is complete - @Override - public boolean isSupported(TemporalField field) { - if (currentParsed().fieldValues.containsKey(field)) { - return true; - } - return (field instanceof ChronoField == false) && field.isSupportedBy(this); - } - - @Override - public long getLong(TemporalField field) { - Long value = currentParsed().fieldValues.get(field); - if (value != null) { - return value; - } - if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); - } - return field.getFrom(this); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) currentParsed().chrono; - } else if (query == Queries.zoneId()) { - return (R) currentParsed().zone; - } else if (query == Queries.precision()) { - return null; - } - return query.queryFrom(this); - } - - //----------------------------------------------------------------------- - /** * Returns a string version of the context for debugging. * * @return a string representation of the context data, not null @@ -482,27 +381,4 @@ return currentParsed().toString(); } - //----------------------------------------------------------------------- - /** - * Temporary store of parsed data. - */ - private static final class Parsed { - Chronology chrono = null; - ZoneId zone = null; - final Map fieldValues = new HashMap<>(); - private Parsed() { - } - protected Parsed copy() { - Parsed cloned = new Parsed(); - cloned.chrono = this.chrono; - cloned.zone = this.zone; - cloned.fieldValues.putAll(this.fieldValues); - return cloned; - } - @Override - public String toString() { - return fieldValues.toString() + "," + chrono + "," + zone; - } - } - } --- old/src/share/classes/java/time/format/DateTimePrintContext.java 2013-04-11 23:15:46.000000000 -0700 +++ new/src/share/classes/java/time/format/DateTimePrintContext.java 2013-04-11 23:15:45.000000000 -0700 @@ -63,14 +63,16 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import static java.time.temporal.ChronoField.INSTANT_SECONDS; +import static java.time.temporal.ChronoField.OFFSET_SECONDS; import java.time.DateTimeException; import java.time.Instant; import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; import java.time.temporal.ChronoField; -import java.time.chrono.ChronoLocalDate; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -118,20 +120,20 @@ } private static TemporalAccessor adjust(final TemporalAccessor temporal, DateTimeFormatter formatter) { - // normal case first + // normal case first (early return is an optimization) Chronology overrideChrono = formatter.getChronology(); ZoneId overrideZone = formatter.getZone(); if (overrideChrono == null && overrideZone == null) { return temporal; } - // ensure minimal change - Chronology temporalChrono = Chronology.from(temporal); // default to ISO, handles Instant - ZoneId temporalZone = temporal.query(Queries.zone()); // zone then offset, handles OffsetDateTime - if (temporal.isSupported(EPOCH_DAY) == false || Objects.equals(overrideChrono, temporalChrono)) { + // ensure minimal change (early return is an optimization) + Chronology temporalChrono = temporal.query(TemporalQuery.chronology()); + ZoneId temporalZone = temporal.query(TemporalQuery.zoneId()); + if (Objects.equals(overrideChrono, temporalChrono)) { overrideChrono = null; } - if (temporal.isSupported(INSTANT_SECONDS) == false || Objects.equals(overrideZone, temporalZone)) { + if (Objects.equals(overrideZone, temporalZone)) { overrideZone = null; } if (overrideChrono == null && overrideZone == null) { @@ -139,53 +141,83 @@ } // make adjustment - if (overrideChrono != null && overrideZone != null) { - return overrideChrono.zonedDateTime(Instant.from(temporal), overrideZone); - } else if (overrideZone != null) { - return temporalChrono.zonedDateTime(Instant.from(temporal), overrideZone); - } else { // overrideChrono != null - // need class here to handle non-standard cases - final ChronoLocalDate date = overrideChrono.date(temporal); - return new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - return temporal.isSupported(field); - } - @Override - public ValueRange range(TemporalField field) { - if (field instanceof ChronoField) { - if (((ChronoField) field).isDateField()) { - return date.range(field); - } else { - return temporal.range(field); + final Chronology effectiveChrono = (overrideChrono != null ? overrideChrono : temporalChrono); + if (overrideZone != null) { + // if have zone and instant, calculation is simple, defaulting chrono if necessary + if (temporal.isSupported(INSTANT_SECONDS)) { + Chronology chrono = (effectiveChrono != null ? effectiveChrono : IsoChronology.INSTANCE); + return chrono.zonedDateTime(Instant.from(temporal), overrideZone); + } + // block changing zone on OffsetTime, and similar problem cases + if (overrideZone.normalized() instanceof ZoneOffset && temporal.isSupported(OFFSET_SECONDS) && + temporal.get(OFFSET_SECONDS) != overrideZone.getRules().getOffset(Instant.EPOCH).getTotalSeconds()) { + throw new DateTimeException("Unable to apply override zone '" + overrideZone + + "' because the temporal object being formatted has a different offset but" + + " does not represent an instant: " + temporal); + } + } + final ZoneId effectiveZone = (overrideZone != null ? overrideZone : temporalZone); + final ChronoLocalDate effectiveDate; + if (overrideChrono != null) { + if (temporal.isSupported(EPOCH_DAY)) { + effectiveDate = effectiveChrono.date(temporal); + } else { + // check for date fields other than epoch-day, ignoring case of converting null to ISO + if (!(overrideChrono == IsoChronology.INSTANCE && temporalChrono == null)) { + for (ChronoField f : ChronoField.values()) { + if (f.isDateBased() && temporal.isSupported(f)) { + throw new DateTimeException("Unable to apply override chronology '" + overrideChrono + + "' because the temporal object being formatted contains date fields but" + + " does not represent a whole date: " + temporal); } } - return field.rangeRefinedBy(this); } - @Override - public long getLong(TemporalField field) { - if (field instanceof ChronoField) { - if (((ChronoField) field).isDateField()) { - return date.getLong(field); - } else { - return temporal.getLong(field); - } - } - return field.getFrom(this); + effectiveDate = null; + } + } else { + effectiveDate = null; + } + + // combine available data + // this is a non-standard temporal that is almost a pure delegate + // this better handles map-like underlying temporal instances + return new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.isSupported(field); } - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) date.getChronology(); - } - if (query == Queries.zoneId() || query == Queries.precision()) { - return temporal.query(query); - } - return query.queryFrom(this); + return temporal.isSupported(field); + } + @Override + public ValueRange range(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.range(field); } - }; - } + return temporal.range(field); + } + @Override + public long getLong(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.getLong(field); + } + return temporal.getLong(field); + } + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return (R) effectiveChrono; + } + if (query == TemporalQuery.zoneId()) { + return (R) effectiveZone; + } + if (query == TemporalQuery.precision()) { + return temporal.query(query); + } + return query.queryFrom(this); + } + }; } //----------------------------------------------------------------------- --- old/src/share/classes/java/time/format/DateTimeTextProvider.java 2013-04-11 23:15:46.000000000 -0700 +++ new/src/share/classes/java/time/format/DateTimeTextProvider.java 2013-04-11 23:15:46.000000000 -0700 @@ -70,6 +70,7 @@ import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; import java.time.temporal.TemporalField; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; @@ -82,10 +83,13 @@ import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.util.locale.provider.CalendarDataUtility; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * A provider to obtain the textual form of a date-time field. @@ -141,15 +145,6 @@ return null; } - private static int toStyle(TextStyle style) { - if (style == TextStyle.FULL) { - return Calendar.LONG_FORMAT; - } else if (style == TextStyle.SHORT) { - return Calendar.SHORT_FORMAT; - } - return Calendar.NARROW_STANDALONE; - } - /** * Gets the text for the specified chrono, field, locale and style * for the purpose of formatting. @@ -158,7 +153,7 @@ * The null return value should be used if there is no applicable text, or * if the text would be a numeric representation of the value. * - * @param chrono the Chronology to get text for, not null + * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param value the field value to get text for, not null * @param style the style to get text for, not null @@ -200,8 +195,8 @@ } else { return null; } - return CalendarDataUtility.retrieveCldrFieldValueName( - chrono.getCalendarType(), fieldIndex, fieldValue, toStyle(style), locale); + return CalendarDataUtility.retrieveJavaTimeFieldValueName( + chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); } /** @@ -238,7 +233,7 @@ * if the text would be a numeric representation of the value. * Text can only be parsed if all the values for that field-style-locale combination are unique. * - * @param chrono the Chronology to get text for, not null + * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param style the style to get text for, null for all parsable text * @param locale the locale to get text for, not null @@ -270,17 +265,17 @@ return null; } - Map map = CalendarDataUtility.retrieveCldrFieldValueNames( - chrono.getCalendarType(), fieldIndex, toStyle(style), locale); + int calendarStyle = (style == null) ? Calendar.ALL_STYLES : style.toCalendarStyle(); + Map map = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + chrono.getCalendarType(), fieldIndex, calendarStyle, locale); if (map == null) { return null; } - List> list = new ArrayList<>(map.size()); switch (fieldIndex) { case Calendar.ERA: - for (String key : map.keySet()) { - int era = map.get(key); + for (Map.Entry entry : map.entrySet()) { + int era = entry.getValue(); if (chrono == JapaneseChronology.INSTANCE) { if (era == 0) { era = -999; @@ -288,22 +283,22 @@ era -= 2; } } - list.add(createEntry(key, (long) era)); + list.add(createEntry(entry.getKey(), (long)era)); } break; case Calendar.MONTH: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)(map.get(key) + 1))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)(entry.getValue() + 1))); } break; case Calendar.DAY_OF_WEEK: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)toWeekDay(map.get(key)))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)toWeekDay(entry.getValue()))); } break; default: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)map.get(key))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)entry.getValue())); } break; } @@ -333,85 +328,126 @@ Map> styleMap = new HashMap<>(); if (field == ERA) { for (TextStyle textStyle : TextStyle.values()) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.ERA, toStyle(textStyle), locale).entrySet()) { - map.put((long) entry.getValue(), entry.getKey()); + if (textStyle.isStandalone()) { + // Stand-alone isn't applicable to era names. + continue; } - if (!map.isEmpty()) { - styleMap.put(textStyle, map); + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.ERA, textStyle.toCalendarStyle(), locale); + if (displayNames != null) { + Map map = new HashMap<>(); + for (Entry entry : displayNames.entrySet()) { + map.put((long) entry.getValue(), entry.getKey()); + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); + } } } return new LocaleStore(styleMap); } if (field == MONTH_OF_YEAR) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.MONTH, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long) (entry.getValue() + 1), entry.getKey()); - } - styleMap.put(TextStyle.FULL, map); - - map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.MONTH, Calendar.SHORT_FORMAT, locale).entrySet()) { - map.put((long) (entry.getValue() + 1), entry.getKey()); - } - styleMap.put(TextStyle.SHORT, map); - - map = new HashMap<>(); - for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { - String name; - name = CalendarDataUtility.retrieveCldrFieldValueName( - "gregory", Calendar.MONTH, month, Calendar.NARROW_STANDALONE, locale); - if (name != null) { - map.put((long)(month + 1), name); + for (TextStyle textStyle : TextStyle.values()) { + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale); + Map map = new HashMap<>(); + if (displayNames != null) { + for (Entry entry : displayNames.entrySet()) { + map.put((long) (entry.getValue() + 1), entry.getKey()); + } + + } else { + // Narrow names may have duplicated names, such as "J" for January, Jun, July. + // Get names one by one in that case. + for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { + String name; + name = CalendarDataUtility.retrieveJavaTimeFieldValueName( + "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale); + if (name == null) { + break; + } + map.put((long) (month + 1), name); + } + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); } - } - if (!map.isEmpty()) { - styleMap.put(TextStyle.NARROW, map); } return new LocaleStore(styleMap); } if (field == DAY_OF_WEEK) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.DAY_OF_WEEK, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long)toWeekDay(entry.getValue()), entry.getKey()); - } - styleMap.put(TextStyle.FULL, map); - map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.DAY_OF_WEEK, Calendar.SHORT_FORMAT, locale).entrySet()) { - map.put((long) toWeekDay(entry.getValue()), entry.getKey()); - } - styleMap.put(TextStyle.SHORT, map); - map = new HashMap<>(); - for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { - map.put((long) toWeekDay(wday), - CalendarDataUtility.retrieveCldrFieldValueName( - "gregory", Calendar.DAY_OF_WEEK, wday, Calendar.NARROW_FORMAT, locale)); + for (TextStyle textStyle : TextStyle.values()) { + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale); + Map map = new HashMap<>(); + if (displayNames != null) { + for (Entry entry : displayNames.entrySet()) { + map.put((long)toWeekDay(entry.getValue()), entry.getKey()); + } + + } else { + // Narrow names may have duplicated names, such as "S" for Sunday and Saturday. + // Get names one by one in that case. + for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { + String name; + name = CalendarDataUtility.retrieveJavaTimeFieldValueName( + "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale); + if (name == null) { + break; + } + map.put((long)toWeekDay(wday), name); + } + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); + } } - styleMap.put(TextStyle.NARROW, map); return new LocaleStore(styleMap); } if (field == AMPM_OF_DAY) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.AM_PM, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long) entry.getValue(), entry.getKey()); + for (TextStyle textStyle : TextStyle.values()) { + if (textStyle.isStandalone()) { + // Stand-alone isn't applicable to AM/PM. + continue; + } + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.AM_PM, textStyle.toCalendarStyle(), locale); + if (displayNames != null) { + Map map = new HashMap<>(); + for (Entry entry : displayNames.entrySet()) { + map.put((long) entry.getValue(), entry.getKey()); + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); + } + } + } + return new LocaleStore(styleMap); + } + + if (field == IsoFields.QUARTER_OF_YEAR) { + // The order of keys must correspond to the TextStyle.values() order. + final String[] keys = { + "QuarterNames", + "standalone.QuarterNames", + "QuarterAbbreviations", + "standalone.QuarterAbbreviations", + "QuarterNarrows", + "standalone.QuarterNarrows", + }; + for (int i = 0; i < keys.length; i++) { + String[] names = getLocalizedResource(keys[i], locale); + if (names != null) { + Map map = new HashMap<>(); + for (int q = 0; q < names.length; q++) { + map.put((long) (q + 1), names[q]); + } + styleMap.put(TextStyle.values()[i], map); + } } - styleMap.put(TextStyle.FULL, map); - styleMap.put(TextStyle.SHORT, map); // re-use, as we don't have different data return new LocaleStore(styleMap); } @@ -430,6 +466,23 @@ } /** + * Returns the localized resource of the given key and locale, or null + * if no localized resource is available. + * + * @param key the key of the localized resource, not null + * @param locale the locale, not null + * @return the localized resource, or null if not available + * @throws NullPointerException if key or locale is null + */ + @SuppressWarnings("unchecked") + static T getLocalizedResource(String key, Locale locale) { + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey(key) ? (T) rb.getObject(key) : null; + } + + /** * Stores the text for a single locale. *

    * Some fields have a textual representation, such as day-of-week or month-of-year. @@ -457,9 +510,9 @@ this.valueTextMap = valueTextMap; Map>> map = new HashMap<>(); List> allList = new ArrayList<>(); - for (TextStyle style : valueTextMap.keySet()) { + for (Map.Entry> vtmEntry : valueTextMap.entrySet()) { Map> reverse = new HashMap<>(); - for (Map.Entry entry : valueTextMap.get(style).entrySet()) { + for (Map.Entry entry : vtmEntry.getValue().entrySet()) { if (reverse.put(entry.getValue(), createEntry(entry.getValue(), entry.getKey())) != null) { // TODO: BUG: this has no effect continue; // not parsable, try next style @@ -467,7 +520,7 @@ } List> list = new ArrayList<>(reverse.values()); Collections.sort(list, COMPARATOR); - map.put(style, list); + map.put(vtmEntry.getKey(), list); allList.addAll(list); map.put(null, allList); } --- old/src/share/classes/java/time/format/TextStyle.java 2013-04-11 23:15:47.000000000 -0700 +++ new/src/share/classes/java/time/format/TextStyle.java 2013-04-11 23:15:47.000000000 -0700 @@ -61,33 +61,115 @@ */ package java.time.format; +import java.util.Calendar; + /** - * Enumeration of the style of text output to use. + * Enumeration of the style of text formatting and parsing. + *

    + * Text styles define three sizes for the formatted text - 'full', 'short' and 'narrow'. + * Each of these three sizes is available in both 'standard' and 'stand-alone' variations. *

    - * This defines the "size" of the text to be output. + * The difference between the three sizes is obvious in most languages. + * For example, in English the 'full' month is 'January', the 'short' month is 'Jan' + * and the 'narrow' month is 'J'. Note that the narrow size is often not unique. + * For example, 'January', 'June' and 'July' all have the 'narrow' text 'J'. + *

    + * The difference between the 'standard' and 'stand-alone' forms is trickier to describe + * as there is no difference in English. However, in other languages there is a difference + * in the word used when the text is used alone, as opposed to in a complete date. + * For example, the word used for a month when used alone in a date picker is different + * to the word used for month in association with a day and year in a date. * *

    Specification for implementors

    * This is immutable and thread-safe enum. - * - * @since 1.8 */ public enum TextStyle { // ordered from large to small + // ordered so that bit 0 of the ordinal indicates stand-alone. /** * Full text, typically the full description. * For example, day-of-week Monday might output "Monday". */ - FULL, + FULL(Calendar.LONG_FORMAT, 0), + /** + * Full text for stand-alone use, typically the full description. + * For example, day-of-week Monday might output "Monday". + */ + FULL_STANDALONE(Calendar.LONG_STANDALONE, 0), /** * Short text, typically an abbreviation. * For example, day-of-week Monday might output "Mon". */ - SHORT, + SHORT(Calendar.SHORT_FORMAT, 1), + /** + * Short text for stand-alone use, typically an abbreviation. + * For example, day-of-week Monday might output "Mon". + */ + SHORT_STANDALONE(Calendar.SHORT_STANDALONE, 1), /** * Narrow text, typically a single letter. * For example, day-of-week Monday might output "M". */ - NARROW; + NARROW(Calendar.NARROW_FORMAT, 1), + /** + * Narrow text for stand-alone use, typically a single letter. + * For example, day-of-week Monday might output "M". + */ + NARROW_STANDALONE(Calendar.NARROW_STANDALONE, 1); + + private final int calendarStyle; + private final int zoneNameStyleIndex; + + private TextStyle(int calendarStyle, int zoneNameStyleIndex) { + this.calendarStyle = calendarStyle; + this.zoneNameStyleIndex = zoneNameStyleIndex; + } + /** + * Returns true if the Style is a stand-alone style. + * @return true if the style is a stand-alone style. + */ + public boolean isStandalone() { + return (ordinal() & 1) == 1; + } + + /** + * Returns the stand-alone style with the same size. + * @return the stand-alone style with the same size + */ + public TextStyle asStandalone() { + return TextStyle.values()[ordinal() | 1]; + } + + /** + * Returns the normal style with the same size. + * + * @return the normal style with the same size + */ + public TextStyle asNormal() { + return TextStyle.values()[ordinal() & ~1]; + } + + /** + * Returns the {@code Calendar} style corresponding to this {@code TextStyle}. + * + * @return the corresponding {@code Calendar} style + */ + int toCalendarStyle() { + return calendarStyle; + } + + /** + * Returns the relative index value to an element of the {@link + * java.text.DateFormatSymbols#getZoneStrings() DateFormatSymbols.getZoneStrings()} + * value, 0 for long names and 1 for short names (abbreviations). Note that these values + * do not correspond to the {@link java.util.TimeZone#LONG} and {@link + * java.util.TimeZone#SHORT} values. + * + * @return the relative index value to time zone names array + */ + int zoneNameStyleIndex() { + return zoneNameStyleIndex; + } } --- old/src/share/classes/java/time/temporal/ChronoField.java 2013-04-11 23:15:48.000000000 -0700 +++ new/src/share/classes/java/time/temporal/ChronoField.java 2013-04-11 23:15:47.000000000 -0700 @@ -76,6 +76,11 @@ import java.time.ZoneOffset; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.util.Locale; +import java.util.Objects; +import java.util.ResourceBundle; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * A standard set of fields. @@ -187,7 +192,7 @@ * This counts the second within the minute, from 0 to 59. * This field has the same meaning for all calendar systems. */ - SECOND_OF_MINUTE("SecondOfMinute", SECONDS, MINUTES, ValueRange.of(0, 59)), + SECOND_OF_MINUTE("SecondOfMinute", SECONDS, MINUTES, ValueRange.of(0, 59), "second"), /** * The second-of-day. *

    @@ -201,7 +206,7 @@ * This counts the minute within the hour, from 0 to 59. * This field has the same meaning for all calendar systems. */ - MINUTE_OF_HOUR("MinuteOfHour", MINUTES, HOURS, ValueRange.of(0, 59)), + MINUTE_OF_HOUR("MinuteOfHour", MINUTES, HOURS, ValueRange.of(0, 59), "minute"), /** * The minute-of-day. *

    @@ -232,7 +237,7 @@ * This is the hour that would be observed on a standard 24-hour digital clock. * This field has the same meaning for all calendar systems. */ - HOUR_OF_DAY("HourOfDay", HOURS, DAYS, ValueRange.of(0, 23)), + HOUR_OF_DAY("HourOfDay", HOURS, DAYS, ValueRange.of(0, 23), "hour"), /** * The clock-hour-of-day. *

    @@ -247,7 +252,7 @@ * This counts the AM/PM within the day, from 0 (AM) to 1 (PM). * This field has the same meaning for all calendar systems. */ - AMPM_OF_DAY("AmPmOfDay", HALF_DAYS, DAYS, ValueRange.of(0, 1)), + AMPM_OF_DAY("AmPmOfDay", HALF_DAYS, DAYS, ValueRange.of(0, 1), "dayperiod"), /** * The day-of-week, such as Tuesday. *

    @@ -263,7 +268,7 @@ * if they have a similar concept of named or numbered days within a period similar * to a week. It is recommended that the numbering starts from 1. */ - DAY_OF_WEEK("DayOfWeek", DAYS, WEEKS, ValueRange.of(1, 7)), + DAY_OF_WEEK("DayOfWeek", DAYS, WEEKS, ValueRange.of(1, 7), "weekday"), /** * The aligned day-of-week within a month. *

    @@ -312,7 +317,7 @@ * day-of-month values for users of the calendar system. * Normally, this is a count of days from 1 to the length of the month. */ - DAY_OF_MONTH("DayOfMonth", DAYS, MONTHS, ValueRange.of(1, 28, 31)), + DAY_OF_MONTH("DayOfMonth", DAYS, MONTHS, ValueRange.of(1, 28, 31), "day"), /** * The day-of-year. *

    @@ -377,17 +382,27 @@ * month-of-year values for users of the calendar system. * Normally, this is a count of months starting from 1. */ - MONTH_OF_YEAR("MonthOfYear", MONTHS, YEARS, ValueRange.of(1, 12)), + MONTH_OF_YEAR("MonthOfYear", MONTHS, YEARS, ValueRange.of(1, 12), "month"), /** - * The epoch-month based on the Java epoch of 1970-01-01. + * The proleptic-month based, counting months sequentially from year 0. *

    - * This field is the sequential count of months where January 1970 (ISO) is zero. + * This field is the sequential count of months where the first month + * in proleptic-year zero has the value zero. + * Later months have increasingly larger values. + * Earlier months have increasingly small values. + * There are no gaps or breaks in the sequence of months. * Note that this uses the local time-line, ignoring offset and time-zone. *

    - * Non-ISO calendar systems should also implement this field to represent a sequential - * count of months. It is recommended to define zero as the month of 1970-01-01 (ISO). + * In the default ISO calendar system, June 2012 would have the value + * {@code (2012 * 12 + 6 - 1)}. This field is primarily for internal use. + *

    + * Non-ISO calendar systems must implement this field as per the definition above. + * It is just a simple zero-based count of elapsed months from the start of proleptic-year 0. + * All calendar systems with a full proleptic-year definition will have a year zero. + * If the calendar system has a minimum year that excludes year zero, then one must + * be extrapolated in order for this method to be defined. */ - EPOCH_MONTH("EpochMonth", MONTHS, FOREVER, ValueRange.of((Year.MIN_VALUE - 1970L) * 12, (Year.MAX_VALUE - 1970L) * 12L - 1L)), + PROLEPTIC_MONTH("ProlepticMonth", MONTHS, FOREVER, ValueRange.of(Year.MIN_VALUE * 12L, Year.MAX_VALUE * 12L + 11)), /** * The year within the era. *

    @@ -446,7 +461,7 @@ * defined with any appropriate value, although defining it to be the same as ISO may be * the best option. */ - YEAR("Year", YEARS, FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)), + YEAR("Year", YEARS, FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), "year"), /** * The era. *

    @@ -463,7 +478,7 @@ * Earlier eras must have sequentially smaller values. * Later eras must have sequentially larger values, */ - ERA("Era", ERAS, FOREVER, ValueRange.of(0, 1)), + ERA("Era", ERAS, FOREVER, ValueRange.of(0, 1), "era"), /** * The instant epoch-seconds. *

    @@ -499,12 +514,23 @@ private final TemporalUnit baseUnit; private final TemporalUnit rangeUnit; private final ValueRange range; + private final String displayNameKey; private ChronoField(String name, TemporalUnit baseUnit, TemporalUnit rangeUnit, ValueRange range) { this.name = name; this.baseUnit = baseUnit; this.rangeUnit = rangeUnit; this.range = range; + this.displayNameKey = null; + } + + private ChronoField(String name, TemporalUnit baseUnit, TemporalUnit rangeUnit, + ValueRange range, String displayNameKey) { + this.name = name; + this.baseUnit = baseUnit; + this.rangeUnit = rangeUnit; + this.range = range; + this.displayNameKey = displayNameKey; } //----------------------------------------------------------------------- @@ -514,6 +540,20 @@ } @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + if (displayNameKey == null) { + return getName(); + } + + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + String key = "field." + displayNameKey; + return rb.containsKey(key) ? rb.getString(key) : getName(); + } + + @Override public TemporalUnit getBaseUnit() { return baseUnit; } @@ -548,19 +588,25 @@ //----------------------------------------------------------------------- /** * Checks if this field represents a component of a date. + *

    + * Fields from day-of-week to era are date-based. * * @return true if it is a component of a date */ - public boolean isDateField() { + @Override + public boolean isDateBased() { return ordinal() >= DAY_OF_WEEK.ordinal() && ordinal() <= ERA.ordinal(); } /** * Checks if this field represents a component of a time. + *

    + * Fields from nano-of-second to am-pm-of-day are time-based. * * @return true if it is a component of a time */ - public boolean isTimeField() { + @Override + public boolean isTimeBased() { return ordinal() < DAY_OF_WEEK.ordinal(); } --- old/src/share/classes/java/time/temporal/ChronoUnit.java 2013-04-11 23:15:48.000000000 -0700 +++ new/src/share/classes/java/time/temporal/ChronoUnit.java 2013-04-11 23:15:48.000000000 -0700 @@ -178,7 +178,7 @@ * Unit that represents the concept of an era. * The ISO calendar system doesn't have eras thus it is impossible to add * an era to a date or date-time. - * The estimated duration of the era is artificially defined as {@code 1,000,00,000 Years}. + * The estimated duration of the era is artificially defined as {@code 1,000,000,000 Years}. *

    * When used with other calendar systems there are no restrictions on the unit. */ --- old/src/share/classes/java/time/temporal/IsoFields.java 2013-04-11 23:15:49.000000000 -0700 +++ new/src/share/classes/java/time/temporal/IsoFields.java 2013-04-11 23:15:49.000000000 -0700 @@ -69,13 +69,19 @@ import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; -import java.time.DateTimeException; import java.time.Duration; import java.time.LocalDate; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; +import java.time.format.ResolverStyle; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.Objects; +import java.util.ResourceBundle; + +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * Fields and units specific to the ISO-8601 calendar system, @@ -162,6 +168,27 @@ * value from 1 to 92. If the quarter has less than 92 days, then day 92, and * potentially day 91, is in the following quarter. *

    + * In the resolving phase of parsing, a date can be created from a year, + * quarter-of-year and day-of-quarter. + *

    + * In {@linkplain ResolverStyle#STRICT strict mode}, all three fields are + * validated against their range of valid values. The day-of-quarter field + * is validated from 1 to 90, 91 or 92 depending on the year and quarter. + *

    + * In {@linkplain ResolverStyle#SMART smart mode}, all three fields are + * validated against their range of valid values. The day-of-quarter field is + * validated between 1 and 92, ignoring the actual range based on the year and quarter. + * If the day-of-quarter exceeds the actual range by one day, then the resulting date + * is one day later. If the day-of-quarter exceeds the actual range by two days, + * then the resulting date is two days later. + *

    + * In {@linkplain ResolverStyle#LENIENT lenient mode}, only the year is validated + * against the range of valid values. The resulting date is calculated equivalent to + * the following three stage approach. First, create a date on the first of January + * in the requested year. Then take the quarter-of-year, subtract one, and add the + * amount in quarters to the date. Finally, take the day-of-quarter, subtract one, + * and add the amount in days to the date. + *

    * This unit is an immutable and thread-safe singleton. */ public static final TemporalField DAY_OF_QUARTER = Field.DAY_OF_QUARTER; @@ -171,7 +198,11 @@ * This field allows the quarter-of-year value to be queried and set. * The quarter-of-year has values from 1 to 4. *

    - * The day-of-quarter can only be calculated if the month-of-year is available. + * The quarter-of-year can only be calculated if the month-of-year is available. + *

    + * In the resolving phase of parsing, a date can be created from a year, + * quarter-of-year and day-of-quarter. + * See {@link #DAY_OF_QUARTER} for details. *

    * This unit is an immutable and thread-safe singleton. */ @@ -180,6 +211,28 @@ * The field that represents the week-of-week-based-year. *

    * This field allows the week of the week-based-year value to be queried and set. + * The week-of-week-based-year has values from 1 to 52, or 53 if the + * week-based-year has 53 weeks. + *

    + * In the resolving phase of parsing, a date can be created from a + * week-based-year, week-of-week-based-year and day-of-week. + *

    + * In {@linkplain ResolverStyle#STRICT strict mode}, all three fields are + * validated against their range of valid values. The week-of-week-based-year + * field is validated from 1 to 52 or 53 depending on the week-based-year. + *

    + * In {@linkplain ResolverStyle#SMART smart mode}, all three fields are + * validated against their range of valid values. The week-of-week-based-year + * field is validated between 1 and 53, ignoring the week-based-year. + * If the week-of-week-based-year is 53, but the week-based-year only has + * 52 weeks, then the resulting date is in week 1 of the following week-based-year. + *

    + * In {@linkplain ResolverStyle#LENIENT lenient mode}, only the week-based-year + * is validated against the range of valid values. If the day-of-week is outside + * the range 1 to 7, then the resulting date is adjusted by a suitable number of + * weeks to reduce the day-of-week to the range 1 to 7. If the week-of-week-based-year + * value is outside the range 1 to 52, then any excess weeks are added or subtracted + * from the resulting date. *

    * This unit is an immutable and thread-safe singleton. */ @@ -189,6 +242,12 @@ *

    * This field allows the week-based-year value to be queried and set. *

    + * The field has a range that matches {@link LocalDate#MAX} and {@link LocalDate#MIN}. + *

    + * In the resolving phase of parsing, a date can be created from a + * week-based-year, week-of-week-based-year and day-of-week. + * See {@link #WEEK_OF_WEEK_BASED_YEAR} for details. + *

    * This unit is an immutable and thread-safe singleton. */ public static final TemporalField WEEK_BASED_YEAR = Field.WEEK_BASED_YEAR; @@ -253,7 +312,7 @@ @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: DayOfQuarter"); + throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } long qoy = temporal.getLong(QUARTER_OF_YEAR); if (qoy == 1) { @@ -269,7 +328,7 @@ @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: DayOfQuarter"); + throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } int doy = temporal.get(DAY_OF_YEAR); int moy = temporal.get(MONTH_OF_YEAR); @@ -285,16 +344,29 @@ return (R) temporal.with(DAY_OF_YEAR, temporal.getLong(DAY_OF_YEAR) + (newValue - curValue)); } @Override - public Map resolve(TemporalAccessor temporal, long value) { - if ((temporal.isSupported(YEAR) && temporal.isSupported(DAY_OF_QUARTER)) == false) { + public Map resolve(TemporalAccessor temporal, long doq, ResolverStyle resolverStyle) { + if ((temporal.isSupported(YEAR) && temporal.isSupported(QUARTER_OF_YEAR)) == false) { return null; } - int y = temporal.get(YEAR); - int qoy = temporal.get(QUARTER_OF_YEAR); - range().checkValidValue(value, this); // leniently check from 1 to 92 TODO: check - LocalDate date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1).plusDays(value - 1); + int y = temporal.get(YEAR); // validated + LocalDate date; + if (resolverStyle == ResolverStyle.LENIENT) { + long qoy = temporal.getLong(QUARTER_OF_YEAR); // unvalidated + date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoy, 1), 3)); + } else { + int qoy = temporal.get(QUARTER_OF_YEAR); // validated + date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1); + if (doq < 1 || doq > 90) { + if (resolverStyle == ResolverStyle.STRICT) { + rangeRefinedBy(date).checkValidValue(doq, this); // only allow exact range + } else { // SMART + range().checkValidValue(doq, this); // allow 1-92 rolling into next quarter + } + } + } + long epochDay = Math.addExact(date.toEpochDay(), Math.subtractExact(doq, 1)); Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); + result.put(EPOCH_DAY, epochDay); result.put(YEAR, null); result.put(QUARTER_OF_YEAR, null); return result; @@ -324,7 +396,7 @@ @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: QuarterOfYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: QuarterOfYear"); } long moy = temporal.getLong(MONTH_OF_YEAR); return ((moy + 2) / 3); @@ -343,6 +415,16 @@ public String getName() { return "WeekOfWeekBasedYear"; } + + @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey("field.week") ? rb.getString("field.week") : getName(); + } + @Override public TemporalUnit getBaseUnit() { return WEEKS; @@ -362,14 +444,14 @@ @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekOfWeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } return getWeekRange(LocalDate.from(temporal)); } @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekOfWeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } return getWeek(LocalDate.from(temporal)); } @@ -381,14 +463,33 @@ return (R) temporal.plus(Math.subtractExact(newValue, getFrom(temporal)), WEEKS); } @Override - public Map resolve(TemporalAccessor temporal, long value) { + public Map resolve(TemporalAccessor temporal, long wowby, ResolverStyle resolverStyle) { if ((temporal.isSupported(WEEK_BASED_YEAR) && temporal.isSupported(DAY_OF_WEEK)) == false) { return null; } - int wby = temporal.get(WEEK_BASED_YEAR); - int dow = temporal.get(DAY_OF_WEEK); - range().checkValidValue(value, this); // lenient range - LocalDate date = LocalDate.of(wby, 1, 4).plusWeeks(value - 1).with(DAY_OF_WEEK, dow); + int wby = temporal.get(WEEK_BASED_YEAR); // validated + LocalDate date = LocalDate.of(wby, 1, 4); + if (resolverStyle == ResolverStyle.LENIENT) { + long dow = temporal.getLong(DAY_OF_WEEK); // unvalidated + if (dow > 7) { + date = date.plusWeeks((dow - 1) / 7); + dow = ((dow - 1) % 7) + 1; + } else if (dow < 1) { + date = date.plusWeeks(Math.subtractExact(dow, 7) / 7); + dow = ((dow + 6) % 7) + 1; + } + date = date.plusWeeks(Math.subtractExact(wowby, 1)).with(DAY_OF_WEEK, dow); + } else { + int dow = temporal.get(DAY_OF_WEEK); // validated + if (wowby < 1 || wowby > 52) { + if (resolverStyle == ResolverStyle.STRICT) { + getWeekRange(date).checkValidValue(wowby, this); // only allow exact range + } else { // SMART + range().checkValidValue(wowby, this); // allow 1-53 rolling into next year + } + } + date = date.plusWeeks(wowby - 1).with(DAY_OF_WEEK, dow); + } Map result = new HashMap<>(2, 1.0f); result.put(EPOCH_DAY, date.toEpochDay()); result.put(WEEK_BASED_YEAR, null); @@ -420,7 +521,7 @@ @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } return getWeekBasedYear(LocalDate.from(temporal)); } @@ -428,7 +529,7 @@ @Override public R adjustInto(R temporal, long newValue) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } int newVal = range().checkValidIntValue(newValue, WEEK_BASED_YEAR); // strict check LocalDate date = LocalDate.from(temporal); @@ -439,6 +540,11 @@ }; @Override + public boolean isDateBased() { + return true; + } + + @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { return range(); } --- old/src/share/classes/java/time/temporal/JulianFields.java 2013-04-11 23:15:50.000000000 -0700 +++ new/src/share/classes/java/time/temporal/JulianFields.java 2013-04-11 23:15:49.000000000 -0700 @@ -66,6 +66,7 @@ import static java.time.temporal.ChronoUnit.FOREVER; import java.time.DateTimeException; +import java.time.format.ResolverStyle; import java.util.Collections; import java.util.Map; @@ -106,7 +107,12 @@ * When 'JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered. * 'JULIAN_DAY.adjustInto()' and 'JULIAN_DAY.getFrom()' only apply to {@code Temporal} objects that * can be converted into {@link ChronoField#EPOCH_DAY}. - * A {@link DateTimeException} is thrown for any other type of object. + * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object. + *

    + * In the resolving phase of parsing, a date can be created from a Julian Day field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Julian Day value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. *

    *

    Astronomical and Scientific Notes

    * The standard astronomical definition uses a fraction to indicate the time-of-day, @@ -147,10 +153,15 @@ * When 'MODIFIED_JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered. * 'MODIFIED_JULIAN_DAY.adjustInto()' and 'MODIFIED_JULIAN_DAY.getFrom()' only apply to {@code Temporal} objects * that can be converted into {@link ChronoField#EPOCH_DAY}. - * A {@link DateTimeException} is thrown for any other type of object. + * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object. *

    * This implementation is an integer version of MJD with the decimal part rounded to floor. *

    + * In the resolving phase of parsing, a date can be created from a Modified Julian Day field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Modified Julian Day value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. + *

    *

    Astronomical and Scientific Notes

    *
          *  | ISO date          | Modified Julian Day |      Decimal MJD |
    @@ -180,7 +191,12 @@
          * When 'RATA_DIE.adjustInto()' is applied to a date-time, the time of day portion remains unaltered.
          * 'RATA_DIE.adjustInto()' and 'RATA_DIE.getFrom()' only apply to {@code Temporal} objects
          * that can be converted into {@link ChronoField#EPOCH_DAY}.
    -     * A {@link DateTimeException} is thrown for any other type of object.
    +     * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object.
    +     * 

    + * In the resolving phase of parsing, a date can be created from a Rata Die field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Rata Die value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. */ public static final TemporalField RATA_DIE = Field.RATA_DIE; @@ -232,6 +248,11 @@ } @Override + public boolean isDateBased() { + return true; + } + + @Override public ValueRange range() { return range; } @@ -266,8 +287,15 @@ //----------------------------------------------------------------------- @Override - public Map resolve(TemporalAccessor temporal, long value) { - return Collections.singletonMap(EPOCH_DAY, Math.subtractExact(value, offset)); + public Map resolve(TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { + long epochDay; + if (resolverStyle == ResolverStyle.LENIENT) { + epochDay = Math.subtractExact(value, offset); + } else { + range().checkValidValue(value, this); + epochDay = value - offset; + } + return Collections.singletonMap(EPOCH_DAY, epochDay); } //----------------------------------------------------------------------- --- old/src/share/classes/java/time/temporal/Temporal.java 2013-04-11 23:15:50.000000000 -0700 +++ new/src/share/classes/java/time/temporal/Temporal.java 2013-04-11 23:15:50.000000000 -0700 @@ -83,7 +83,7 @@ * Two pieces of date/time information cannot be represented by numbers, * the {@linkplain java.time.chrono.Chronology chronology} and the {@linkplain ZoneId time-zone}. * These can be accessed via {@link #query(TemporalQuery) queries} using - * the static methods defined on {@link Queries}. + * the static methods defined on {@link TemporalQuery}. *

    * This interface is a framework-level interface that should not be widely * used in application code. Instead, applications should create and pass @@ -134,7 +134,7 @@ * This adjusts this date-time according to the rules of the specified adjuster. * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * The adjuster is responsible for handling special cases, such as the varying * lengths of month and leap years. @@ -161,7 +161,7 @@ * @throws DateTimeException if unable to make the adjustment * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal with(TemporalAdjuster adjuster) { + default Temporal with(TemporalAdjuster adjuster) { return adjuster.adjustInto(this); } @@ -180,7 +180,7 @@ *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the adjustment must be performed. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -194,6 +194,7 @@ * @param newValue the new value of the field in the result * @return an object of the same type with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ Temporal with(TemporalField field, long newValue); @@ -210,7 +211,6 @@ *

          *  date = date.plus(period);                      // add a Period instance
          *  date = date.plus(duration);                    // add a Duration instance
    -     *  date = date.plus(MONTHS.between(start, end));  // static import of MONTHS field
          *  date = date.plus(workingDays(6));              // example user-written workingDays method
          * 
    *

    @@ -232,7 +232,7 @@ * @throws DateTimeException if the addition cannot be made * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal plus(TemporalAmount amount) { + default Temporal plus(TemporalAmount amount) { return amount.addTo(this); } @@ -255,7 +255,7 @@ *

    Specification for implementors

    * Implementations must check and handle all units defined in {@link ChronoUnit}. * If the unit is supported, then the addition must be performed. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -269,6 +269,7 @@ * @param unit the unit of the period to add, not null * @return an object of the same type with the specified period added, not null * @throws DateTimeException if the unit cannot be added + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ Temporal plus(long amountToAdd, TemporalUnit unit); @@ -285,7 +286,6 @@ *

          *  date = date.minus(period);                      // subtract a Period instance
          *  date = date.minus(duration);                    // subtract a Duration instance
    -     *  date = date.minus(MONTHS.between(start, end));  // static import of MONTHS field
          *  date = date.minus(workingDays(6));              // example user-written workingDays method
          * 
    *

    @@ -307,7 +307,7 @@ * @throws DateTimeException if the subtraction cannot be made * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal minus(TemporalAmount amount) { + default Temporal minus(TemporalAmount amount) { return amount.subtractFrom(this); } @@ -344,9 +344,10 @@ * @param unit the unit of the period to subtract, not null * @return an object of the same type with the specified period subtracted, not null * @throws DateTimeException if the unit cannot be subtracted + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal minus(long amountToSubtract, TemporalUnit unit) { + default Temporal minus(long amountToSubtract, TemporalUnit unit) { return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit)); } @@ -388,7 +389,7 @@ * Implementations must begin by checking to ensure that the input temporal * object is of the same observable type as the implementation. * They must then perform the calculation for all instances of {@link ChronoUnit}. - * A {@code DateTimeException} must be thrown for {@code ChronoUnit} + * An {@code UnsupportedTemporalTypeException} must be thrown for {@code ChronoUnit} * instances that are unsupported. *

    * If the unit is not a {@code ChronoUnit}, then the result of this method @@ -401,7 +402,7 @@ * // check input temporal is the same type as this class * if (unit instanceof ChronoUnit) { * // if unit is supported, then calculate and return result - * // else throw DateTimeException for unsupported units + * // else throw UnsupportedTemporalTypeException for unsupported units * } * return unit.between(this, endTemporal); *

    @@ -414,6 +415,7 @@ * the unit; positive if the specified object is later than this one, negative if * it is earlier than this one * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ long periodUntil(Temporal endTemporal, TemporalUnit unit); --- old/src/share/classes/java/time/temporal/TemporalAccessor.java 2013-04-11 23:15:51.000000000 -0700 +++ new/src/share/classes/java/time/temporal/TemporalAccessor.java 2013-04-11 23:15:51.000000000 -0700 @@ -63,6 +63,7 @@ import java.time.DateTimeException; import java.time.ZoneId; +import java.util.Objects; /** * Framework-level interface defining read-only access to a temporal object, @@ -80,8 +81,8 @@ *

    * Two pieces of date/time information cannot be represented by numbers, * the {@linkplain java.time.chrono.Chronology chronology} and the {@linkplain ZoneId time-zone}. - * These can be accessed via {@link #query(TemporalQuery) queries} using - * the static methods defined on {@link Queries}. + * These can be accessed via {@linkplain #query(TemporalQuery) queries} using + * the static methods defined on {@link TemporalQuery}. *

    * A sub-interface, {@link Temporal}, extends this definition to one that also * supports adjustment and manipulation on more complete temporal objects. @@ -139,7 +140,7 @@ *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the range of the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessorl)} @@ -153,7 +154,7 @@ * if (isSupported(field)) { * return field.range(); * } - * throw new DateTimeException("Unsupported field: " + field.getName()); + * throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); * } * return field.rangeRefinedBy(this); *

    @@ -161,14 +162,16 @@ * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } + Objects.requireNonNull(field, "field"); return field.rangeRefinedBy(this); } @@ -184,28 +187,40 @@ * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported and has an {@code int} range, then the value of * the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. *

    - * Implementations must not alter either this object. + * Implementations must not alter this object. *

    * The default implementation must behave equivalent to this code: *

    -     *  return range(field).checkValidIntValue(getLong(field), field);
    +     *  if (range(field).isIntValue()) {
    +     *    return range(field).checkValidIntValue(getLong(field), field);
    +     *  }
    +     *  throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead");
          * 
    * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained - * @throws DateTimeException if the range of valid values for the field exceeds an {@code int} - * @throws DateTimeException if the value is outside the range of valid values for the field + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ - public default int get(TemporalField field) { - return range(field).checkValidIntValue(getLong(field), field); + default int get(TemporalField field) { + ValueRange range = range(field); + if (range.isIntValue() == false) { + throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead"); + } + long value = getLong(field); + if (range.isValidValue(value) == false) { + throw new DateTimeException("Invalid value for " + field + " (valid values " + range + "): " + value); + } + return (int) value; } /** @@ -219,7 +234,7 @@ *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the value of the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -230,6 +245,7 @@ * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ long getLong(TemporalField field); @@ -247,13 +263,13 @@ *

    * The most common query implementations are method references, such as * {@code LocalDate::from} and {@code ZoneId::from}. - * Further implementations are on {@link Queries}. - * Queries may also be defined by applications. + * Additional implementations are provided as static methods on {@link TemporalQuery}. * *

    Specification for implementors

    * The default implementation must behave equivalent to this code: *
    -     *  if (query == Queries.zoneId() || query == Queries.chronology() || query == Queries.precision()) {
    +     *  if (query == TemporalQuery.zoneId() ||
    +     *        query == TemporalQuery.chronology() || query == TemporalQuery.precision()) {
          *    return null;
          *  }
          *  return query.queryFrom(this);
    @@ -270,7 +286,7 @@
          * For example, an application-defined {@code HourMin} class storing the hour
          * and minute must override this method as follows:
          * 
    -     *  if (query == Queries.precision()) {
    +     *  if (query == TemporalQuery.precision()) {
          *    return MINUTES;
          *  }
          *  return TemporalAccessor.super.query(query);
    @@ -282,8 +298,8 @@
          * @throws DateTimeException if unable to query
          * @throws ArithmeticException if numeric overflow occurs
          */
    -    public default  R query(TemporalQuery query) {
    -        if (query == Queries.zoneId() || query == Queries.chronology() || query == Queries.precision()) {
    +    default  R query(TemporalQuery query) {
    +        if (query == TemporalQuery.zoneId() || query == TemporalQuery.chronology() || query == TemporalQuery.precision()) {
                 return null;
             }
             return query.queryFrom(this);
    --- old/src/share/classes/java/time/temporal/TemporalAdjuster.java	2013-04-11 23:15:52.000000000 -0700
    +++ new/src/share/classes/java/time/temporal/TemporalAdjuster.java	2013-04-11 23:15:52.000000000 -0700
    @@ -62,6 +62,9 @@
     package java.time.temporal;
     
     import java.time.DateTimeException;
    +import java.time.DayOfWeek;
    +import java.time.LocalDate;
    +import java.util.function.UnaryOperator;
     
     /**
      * Strategy for adjusting a temporal object.
    @@ -83,13 +86,22 @@
      * It is recommended to use the second approach, {@code with(TemporalAdjuster)},
      * as it is a lot clearer to read in code.
      * 

    - * See {@link Adjusters} for a standard set of adjusters, including finding the - * last day of the month. - * Adjusters may also be defined by applications. + * This class also contains a standard set of adjusters, available as static methods. + * These include: + *

      + *
    • finding the first or last day of the month + *
    • finding the first day of next month + *
    • finding the first or last day of the year + *
    • finding the first day of next year + *
    • finding the first or last day-of-week within a month, such as "first Wednesday in June" + *
    • finding the next or previous day-of-week, such as "next Thursday" + *
    * *

    Specification for implementors

    * This interface places no restrictions on the mutability of implementations, * however immutability is strongly recommended. + *

    + * All the implementations supplied by the static methods on this interface are immutable. * * @since 1.8 */ @@ -128,7 +140,7 @@ *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -140,4 +152,311 @@ */ Temporal adjustInto(Temporal temporal); + //----------------------------------------------------------------------- + /** + * Obtains a {@code TemporalAdjuster} that wraps a date adjuster. + *

    + * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. + * This method allows an adjustment from {@code LocalDate} to {@code LocalDate} + * to be wrapped to match the temporal-based interface. + * This is provided for convenience to make user-written adjusters simpler. + *

    + * In general, user-written adjusters should be static constants: + *

    +     *  static TemporalAdjuster TWO_DAYS_LATER = TemporalAdjuster.ofDateAdjuster(
    +     *    date -> date.plusDays(2));
    +     * 
    + * + * @param dateBasedAdjuster the date-based adjuster, not null + * @return the temporal adjuster wrapping on the date adjuster, not null + */ + static TemporalAdjuster ofDateAdjuster(UnaryOperator dateBasedAdjuster) { + return TemporalAdjusters.ofDateAdjuster(dateBasedAdjuster); + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of month" adjuster, which returns a new date set to + * the first day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-02-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1);
    +     * 
    + * + * @return the first day-of-month adjuster, not null + */ + static TemporalAdjuster firstDayOfMonth() { + return TemporalAdjusters.firstDayOfMonth(); + } + + /** + * Returns the "last day of month" adjuster, which returns a new date set to + * the last day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-31.
    + * The input 2011-02-15 will return 2011-02-28.
    + * The input 2012-02-15 will return 2012-02-29 (leap year).
    + * The input 2011-04-15 will return 2011-04-30. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_MONTH).getMaximum();
    +     *  temporal.with(DAY_OF_MONTH, lastDay);
    +     * 
    + * + * @return the last day-of-month adjuster, not null + */ + static TemporalAdjuster lastDayOfMonth() { + return TemporalAdjusters.lastDayOfMonth(); + } + + /** + * Returns the "first day of next month" adjuster, which returns a new date set to + * the first day of the next month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-02-01.
    + * The input 2011-02-15 will return 2011-03-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextMonth() { + return TemporalAdjusters.firstDayOfNextMonth(); + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of year" adjuster, which returns a new date set to + * the first day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-01-01.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1);
    +     * 
    + * + * @return the first day-of-year adjuster, not null + */ + static TemporalAdjuster firstDayOfYear() { + return TemporalAdjusters.firstDayOfYear(); + } + + /** + * Returns the "last day of year" adjuster, which returns a new date set to + * the last day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-12-31.
    + * The input 2011-02-15 will return 2011-12-31.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_YEAR).getMaximum();
    +     *  temporal.with(DAY_OF_YEAR, lastDay);
    +     * 
    + * + * @return the last day-of-year adjuster, not null + */ + static TemporalAdjuster lastDayOfYear() { + return TemporalAdjusters.lastDayOfYear(); + } + + /** + * Returns the "first day of next year" adjuster, which returns a new date set to + * the first day of the next year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2012-01-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextYear() { + return TemporalAdjusters.firstDayOfNextYear(); + } + + //----------------------------------------------------------------------- + /** + * Returns the first in month adjuster, which returns a new date + * in the same month with the first matching day-of-week. + * This is used for expressions like 'first Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-05.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-02.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjuster.dayOfWeekInMonth(1, dayOfWeek); + } + + /** + * Returns the last in month adjuster, which returns a new date + * in the same month with the last matching day-of-week. + * This is used for expressions like 'last Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-26.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-30.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjuster.dayOfWeekInMonth(-1, dayOfWeek); + } + + /** + * Returns the day-of-week in month adjuster, which returns a new date + * in the same month with the ordinal day-of-week. + * This is used for expressions like the 'second Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (1,TUESDAY) will return 2011-12-06.
    + * The input 2011-12-15 for (2,TUESDAY) will return 2011-12-13.
    + * The input 2011-12-15 for (3,TUESDAY) will return 2011-12-20.
    + * The input 2011-12-15 for (4,TUESDAY) will return 2011-12-27.
    + * The input 2011-12-15 for (5,TUESDAY) will return 2012-01-03.
    + * The input 2011-12-15 for (-1,TUESDAY) will return 2011-12-27 (last in month).
    + * The input 2011-12-15 for (-4,TUESDAY) will return 2011-12-06 (3 weeks before last in month).
    + * The input 2011-12-15 for (-5,TUESDAY) will return 2011-11-29 (4 weeks before last in month).
    + * The input 2011-12-15 for (0,TUESDAY) will return 2011-11-29 (last in previous month).
    + *

    + * For a positive or zero ordinal, the algorithm is equivalent to finding the first + * day-of-week that matches within the month and then adding a number of weeks to it. + * For a negative ordinal, the algorithm is equivalent to finding the last + * day-of-week that matches within the month and then subtracting a number of weeks to it. + * The ordinal number of weeks is not validated and is interpreted leniently + * according to this algorithm. This definition means that an ordinal of zero finds + * the last matching day-of-week in the previous month. + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param ordinal the week within the month, unbounded but typically from -5 to 5 + * @param dayOfWeek the day-of-week, not null + * @return the day-of-week in month adjuster, not null + */ + static TemporalAdjuster dayOfWeekInMonth(final int ordinal, DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(ordinal, dayOfWeek); + } + + //----------------------------------------------------------------------- + /** + * Returns the next day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-22 (seven days later). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the next day-of-week adjuster, not null + */ + static TemporalAdjuster next(DayOfWeek dayOfWeek) { + return TemporalAdjusters.next(dayOfWeek); + } + + /** + * Returns the next-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the next-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { + return TemporalAdjusters.nextOrSame(dayOfWeek); + } + + /** + * Returns the previous day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-08 (seven days earlier). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the previous day-of-week adjuster, not null + */ + static TemporalAdjuster previous(DayOfWeek dayOfWeek) { + return TemporalAdjusters.previous(dayOfWeek); + } + + /** + * Returns the previous-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the previous-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { + return TemporalAdjusters.previousOrSame(dayOfWeek); + } + } --- old/src/share/classes/java/time/temporal/TemporalAmount.java 2013-04-11 23:15:53.000000000 -0700 +++ new/src/share/classes/java/time/temporal/TemporalAmount.java 2013-04-11 23:15:53.000000000 -0700 @@ -75,7 +75,7 @@ * to any specific point on the time-line. *

    * The amount can be thought of as a {@code Map} of {@link TemporalUnit} to - * {@code long}, exposed via {@link #getUnits()}and {@link #get(TemporalUnit)}. + * {@code long}, exposed via {@link #getUnits()} and {@link #get(TemporalUnit)}. * A simple case might have a single unit-value pair, such as "6 hours". * A more complex case may have multiple unit-value pairs, such as * "7 years, 3 months and 5 days". @@ -111,9 +111,10 @@ * * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit - * @throws DateTimeException if the {@code unit} is not supported + * @throws DateTimeException if a value for the unit cannot be obtained + * @throws UnsupportedTemporalTypeException if the {@code unit} is not supported */ - public long get(TemporalUnit unit); + long get(TemporalUnit unit); /** * Returns the list of units uniquely defining the value of this TemporalAmount. @@ -130,7 +131,7 @@ * * @return the List of {@code TemporalUnits}; not null */ - public List getUnits(); + List getUnits(); /** * Adds to the specified temporal object. @@ -162,7 +163,7 @@ *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -172,7 +173,7 @@ * @throws DateTimeException if unable to add * @throws ArithmeticException if numeric overflow occurs */ - public Temporal addTo(Temporal temporal); + Temporal addTo(Temporal temporal); /** * Subtracts this object from the specified temporal object. @@ -204,7 +205,7 @@ *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -214,5 +215,5 @@ * @throws DateTimeException if unable to subtract * @throws ArithmeticException if numeric overflow occurs */ - public Temporal subtractFrom(Temporal temporal); + Temporal subtractFrom(Temporal temporal); } --- old/src/share/classes/java/time/temporal/TemporalField.java 2013-04-11 23:15:53.000000000 -0700 +++ new/src/share/classes/java/time/temporal/TemporalField.java 2013-04-11 23:15:53.000000000 -0700 @@ -62,8 +62,10 @@ package java.time.temporal; import java.time.DateTimeException; -import java.util.Comparator; +import java.time.format.ResolverStyle; +import java.util.Locale; import java.util.Map; +import java.util.Objects; /** * A field of date-time, such as month-of-year or hour-of-minute. @@ -88,7 +90,7 @@ * * @since 1.8 */ -public interface TemporalField extends Comparator { +public interface TemporalField { /** * Gets a descriptive name for the field. @@ -102,6 +104,21 @@ String getName(); /** + * Gets the display name for the field in the requested locale. + *

    + * If there is no display name for the locale the value of {@code getName} + * is returned. + * + * @param locale the locale to use, not null + * @return the display name for the locale or the value of {@code getName}, + * not null + */ + default String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "local"); + return getName(); + } + + /** * Gets the unit that the field is measured in. *

    * The unit of the field is the period that varies within the range. @@ -126,28 +143,6 @@ */ TemporalUnit getRangeUnit(); - //----------------------------------------------------------------------- - /** - * Compares the value of this field in two temporal objects. - *

    - * All fields implement {@link Comparator} on {@link TemporalAccessor}. - * This allows a list of date-times to be compared using the value of a field. - * For example, you could sort a list of arbitrary temporal objects by the value of - * the month-of-year field - {@code Collections.sort(list, MONTH_OF_YEAR)} - *

    - * The default implementation must behave equivalent to this code: - *

    -     *  return Long.compare(temporal1.getLong(this), temporal2.getLong(this));
    -     * 
    - * - * @param temporal1 the first temporal object to compare, not null - * @param temporal2 the second temporal object to compare, not null - * @throws DateTimeException if unable to obtain the value for this field - */ - public default int compare(TemporalAccessor temporal1, TemporalAccessor temporal2) { - return Long.compare(temporal1.getLong(this), temporal2.getLong(this)); - } - /** * Gets the range of valid values for the field. *

    @@ -165,6 +160,35 @@ //----------------------------------------------------------------------- /** + * Checks if this field represents a component of a date. + *

    + * A field is date-based if it can be derived from + * {@link ChronoField#EPOCH_DAY EPOCH_DAY}. + *

    + * The default implementation must return false. + * + * @return true if this field is a component of a date + */ + default boolean isDateBased() { + return false; + } + + /** + * Checks if this field represents a component of a time. + *

    + * A field is time-based if it can be derived from + * {@link ChronoField#NANO_OF_DAY NANO_OF_DAY}. + *

    + * The default implementation must return false. + * + * @return true if this field is a component of a time + */ + default boolean isTimeBased() { + return false; + } + + //----------------------------------------------------------------------- + /** * Checks if this field is supported by the temporal object. *

    * This determines whether the temporal accessor supports this field. @@ -213,11 +237,12 @@ *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * * @param temporal the temporal object used to refine the result, not null * @return the range of valid values for this field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal */ ValueRange rangeRefinedBy(TemporalAccessor temporal); @@ -240,11 +265,12 @@ *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * * @param temporal the temporal object to query, not null * @return the value of this field, not null * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ long getFrom(TemporalAccessor temporal); @@ -276,7 +302,7 @@ *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. *

    * Implementations must not alter the specified temporal object. * Instead, an adjusted copy of the original must be returned. @@ -287,6 +313,7 @@ * @param newValue the new value of the field * @return the adjusted temporal object, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ R adjustInto(R temporal, long newValue); @@ -314,17 +341,22 @@ * If the result is non-null, this field will be removed from the temporal. * This field should not be added to the result map. *

    + * The {@link ResolverStyle} should be used by implementations to determine + * how to perform the resolve. + *

    * The default implementation must return null. * * @param temporal the temporal to resolve, not null * @param value the value of this field + * @param resolverStyle the requested type of resolve, not null * @return a map of fields to update in the temporal, with a mapping to null * indicating a deletion. The whole map must be null if no resolving occurred * @throws DateTimeException if resolving results in an error. This must not be thrown * by querying a field on the temporal without first checking if it is supported * @throws ArithmeticException if numeric overflow occurs */ - public default Map resolve(TemporalAccessor temporal, long value) { + default Map resolve( + TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { return null; } --- old/src/share/classes/java/time/temporal/TemporalQuery.java 2013-04-11 23:15:54.000000000 -0700 +++ new/src/share/classes/java/time/temporal/TemporalQuery.java 2013-04-11 23:15:54.000000000 -0700 @@ -62,6 +62,11 @@ package java.time.temporal; import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.chrono.Chronology; /** * Strategy for querying a temporal object. @@ -89,8 +94,7 @@ *

    * The most common implementations are method references, such as * {@code LocalDate::from} and {@code ZoneId::from}. - * Further implementations are on {@link Queries}. - * Queries may also be defined by applications. + * Additional common implementations are provided on this interface as static methods. * *

    Specification for implementors

    * This interface places no restrictions on the mutability of implementations, @@ -129,7 +133,7 @@ *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -141,4 +145,214 @@ */ R queryFrom(TemporalAccessor temporal); + //----------------------------------------------------------------------- + // special constants should be used to extract information from a TemporalAccessor + // that cannot be derived in other ways + // Javadoc added here, so as to pretend they are more normal than they really are + + /** + * A strict query for the {@code ZoneId}. + *

    + * This queries a {@code TemporalAccessor} for the zone. + * The zone is only returned if the date-time conceptually contains a {@code ZoneId}. + * It will not be returned if the date-time only conceptually has an {@code ZoneOffset}. + * Thus a {@link java.time.ZonedDateTime} will return the result of {@code getZone()}, + * but an {@link java.time.OffsetDateTime} will return null. + *

    + * In most cases, applications should use {@link #zone()} as this query is too strict. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns null
    + * {@code LocalTime} returns null
    + * {@code LocalDateTime} returns null
    + * {@code ZonedDateTime} returns the associated zone
    + * {@code OffsetTime} returns null
    + * {@code OffsetDateTime} returns null
    + * {@code ChronoLocalDate} returns null
    + * {@code ChronoLocalDateTime} returns null
    + * {@code ChronoZonedDateTime} returns the associated zone
    + * {@code Era} returns null
    + * {@code DayOfWeek} returns null
    + * {@code Month} returns null
    + * {@code Year} returns null
    + * {@code YearMonth} returns null
    + * {@code MonthDay} returns null
    + * {@code ZoneOffset} returns null
    + * {@code Instant} returns null
    + * + * @return a query that can obtain the zone ID of a temporal, not null + */ + static TemporalQuery zoneId() { + return TemporalQueries.ZONE_ID; + } + + /** + * A query for the {@code Chronology}. + *

    + * This queries a {@code TemporalAccessor} for the chronology. + * If the target {@code TemporalAccessor} represents a date, or part of a date, + * then it should return the chronology that the date is expressed in. + * As a result of this definition, objects only representing time, such as + * {@code LocalTime}, will return null. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns {@code IsoChronology.INSTANCE}
    + * {@code LocalTime} returns null (does not represent a date)
    + * {@code LocalDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code ZonedDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code OffsetTime} returns null (does not represent a date)
    + * {@code OffsetDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code ChronoLocalDate} returns the associated chronology
    + * {@code ChronoLocalDateTime} returns the associated chronology
    + * {@code ChronoZonedDateTime} returns the associated chronology
    + * {@code Era} returns the associated chronology
    + * {@code DayOfWeek} returns null (shared across chronologies)
    + * {@code Month} returns {@code IsoChronology.INSTANCE}
    + * {@code Year} returns {@code IsoChronology.INSTANCE}
    + * {@code YearMonth} returns {@code IsoChronology.INSTANCE}
    + * {@code MonthDay} returns null {@code IsoChronology.INSTANCE}
    + * {@code ZoneOffset} returns null (does not represent a date)
    + * {@code Instant} returns null (does not represent a date)
    + *

    + * The method {@link java.time.chrono.Chronology#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code Chronology::from}. + * That method is equivalent to this query, except that it throws an + * exception if a chronology cannot be obtained. + * + * @return a query that can obtain the chronology of a temporal, not null + */ + static TemporalQuery chronology() { + return TemporalQueries.CHRONO; + } + + /** + * A query for the smallest supported unit. + *

    + * This queries a {@code TemporalAccessor} for the time precision. + * If the target {@code TemporalAccessor} represents a consistent or complete date-time, + * date or time then this must return the smallest precision actually supported. + * Note that fields such as {@code NANO_OF_DAY} and {@code NANO_OF_SECOND} + * are defined to always return ignoring the precision, thus this is the only + * way to find the actual smallest supported unit. + * For example, were {@code GregorianCalendar} to implement {@code TemporalAccessor} + * it would return a precision of {@code MILLIS}. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns {@code DAYS}
    + * {@code LocalTime} returns {@code NANOS}
    + * {@code LocalDateTime} returns {@code NANOS}
    + * {@code ZonedDateTime} returns {@code NANOS}
    + * {@code OffsetTime} returns {@code NANOS}
    + * {@code OffsetDateTime} returns {@code NANOS}
    + * {@code ChronoLocalDate} returns {@code DAYS}
    + * {@code ChronoLocalDateTime} returns {@code NANOS}
    + * {@code ChronoZonedDateTime} returns {@code NANOS}
    + * {@code Era} returns {@code ERAS}
    + * {@code DayOfWeek} returns {@code DAYS}
    + * {@code Month} returns {@code MONTHS}
    + * {@code Year} returns {@code YEARS}
    + * {@code YearMonth} returns {@code MONTHS}
    + * {@code MonthDay} returns null (does not represent a complete date or time)
    + * {@code ZoneOffset} returns null (does not represent a date or time)
    + * {@code Instant} returns {@code NANOS}
    + * + * @return a query that can obtain the precision of a temporal, not null + */ + static TemporalQuery precision() { + return TemporalQueries.PRECISION; + } + + //----------------------------------------------------------------------- + // non-special constants are standard queries that derive information from other information + /** + * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. + *

    + * This queries a {@code TemporalAccessor} for the zone. + * It first tries to obtain the zone, using {@link #zoneId()}. + * If that is not found it tries to obtain the {@link #offset()}. + * Thus a {@link java.time.ZonedDateTime} will return the result of {@code getZone()}, + * while an {@link java.time.OffsetDateTime} will return the result of {@code getOffset()}. + *

    + * In most cases, applications should use this query rather than {@code #zoneId()}. + *

    + * The method {@link ZoneId#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code ZoneId::from}. + * That method is equivalent to this query, except that it throws an + * exception if a zone cannot be obtained. + * + * @return a query that can obtain the zone ID or offset of a temporal, not null + */ + static TemporalQuery zone() { + return TemporalQueries.ZONE; + } + + /** + * A query for {@code ZoneOffset} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the offset. The query will return null if the temporal + * object cannot supply an offset. + *

    + * The query implementation examines the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} + * field and uses it to create a {@code ZoneOffset}. + *

    + * The method {@link java.time.ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code ZoneOffset::from}. + * This query and {@code ZoneOffset::from} will return the same result if the + * temporal object contains an offset. If the temporal object does not contain + * an offset, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the offset of a temporal, not null + */ + static TemporalQuery offset() { + return TemporalQueries.OFFSET; + } + + /** + * A query for {@code LocalDate} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the local date. The query will return null if the temporal + * object cannot supply a local date. + *

    + * The query implementation examines the {@link ChronoField#EPOCH_DAY EPOCH_DAY} + * field and uses it to create a {@code LocalDate}. + *

    + * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code LocalDate::from}. + * This query and {@code LocalDate::from} will return the same result if the + * temporal object contains a date. If the temporal object does not contain + * a date, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the date of a temporal, not null + */ + static TemporalQuery localDate() { + return TemporalQueries.LOCAL_DATE; + } + + /** + * A query for {@code LocalTime} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the local time. The query will return null if the temporal + * object cannot supply a local time. + *

    + * The query implementation examines the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} + * field and uses it to create a {@code LocalTime}. + *

    + * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code LocalTime::from}. + * This query and {@code LocalTime::from} will return the same result if the + * temporal object contains a time. If the temporal object does not contain + * a time, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the time of a temporal, not null + */ + static TemporalQuery localTime() { + return TemporalQueries.LOCAL_TIME; + } + } --- old/src/share/classes/java/time/temporal/TemporalUnit.java 2013-04-11 23:15:55.000000000 -0700 +++ new/src/share/classes/java/time/temporal/TemporalUnit.java 2013-04-11 23:15:54.000000000 -0700 @@ -143,10 +143,12 @@ * @param temporal the temporal object to check, not null * @return true if the unit is supported */ - public default boolean isSupportedBy(Temporal temporal) { + default boolean isSupportedBy(Temporal temporal) { try { temporal.plus(1, this); return true; + } catch (UnsupportedTemporalTypeException ex) { + return false; } catch (RuntimeException ex) { try { temporal.plus(-1, this); @@ -178,7 +180,7 @@ *

    * Implementations should perform any queries or calculations using the units * available in {@link ChronoUnit} or the fields available in {@link ChronoField}. - * If the unit is not supported a {@code DateTimeException} must be thrown. + * If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown. *

    * Implementations must not alter the specified temporal object. * Instead, an adjusted copy of the original must be returned. @@ -189,6 +191,7 @@ * @param amount the amount of this unit to add, positive or negative * @return the adjusted temporal object, not null * @throws DateTimeException if the period cannot be added + * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal */ R addTo(R temporal, long amount); @@ -214,8 +217,8 @@ * The second is to use {@link Temporal#periodUntil(Temporal, TemporalUnit)}: *

          *   // these two lines are equivalent
    -     *   temporal = thisUnit.between(start, end);
    -     *   temporal = start.periodUntil(end, thisUnit);
    +     *   between = thisUnit.between(start, end);
    +     *   between = start.periodUntil(end, thisUnit);
          * 
    * The choice should be made based on which makes the code more readable. *

    @@ -229,14 +232,15 @@ *

    * Implementations should perform any queries or calculations using the units * available in {@link ChronoUnit} or the fields available in {@link ChronoField}. - * If the unit is not supported a {@code DateTimeException} must be thrown. + * If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * Implementations must not alter the specified temporal objects. * * @param temporal1 the base temporal object, not null * @param temporal2 the other temporal object, not null - * @return the period between datetime1 and datetime2 in terms of this unit; - * positive if datetime2 is later than datetime1, negative if earlier + * @return the period between temporal1 and temporal2 in terms of this unit; + * positive if temporal2 is later than temporal1, negative if earlier * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ long between(Temporal temporal1, Temporal temporal2); --- old/src/share/classes/java/time/temporal/ValueRange.java 2013-04-11 23:15:55.000000000 -0700 +++ new/src/share/classes/java/time/temporal/ValueRange.java 2013-04-11 23:15:55.000000000 -0700 @@ -305,11 +305,7 @@ */ public long checkValidValue(long value, TemporalField field) { if (isValidValue(value) == false) { - if (field != null) { - throw new DateTimeException("Invalid value for " + field.getName() + " (valid values " + this + "): " + value); - } else { - throw new DateTimeException("Invalid value (valid values " + this + "): " + value); - } + throw new DateTimeException(genInvalidFieldMessage(field, value)); } return value; } @@ -328,11 +324,19 @@ */ public int checkValidIntValue(long value, TemporalField field) { if (isValidIntValue(value) == false) { - throw new DateTimeException("Invalid int value for " + field.getName() + ": " + value); + throw new DateTimeException(genInvalidFieldMessage(field, value)); } return (int) value; } + private String genInvalidFieldMessage(TemporalField field, long value) { + if (field != null) { + return "Invalid value for " + field.getName() + " (valid values " + this + "): " + value; + } else { + return "Invalid value (valid values " + this + "): " + value; + } + } + //----------------------------------------------------------------------- /** * Checks if this range is equal to another range. --- old/src/share/classes/java/time/temporal/WeekFields.java 2013-04-11 23:15:56.000000000 -0700 +++ new/src/share/classes/java/time/temporal/WeekFields.java 2013-04-11 23:15:55.000000000 -0700 @@ -68,6 +68,7 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.FOREVER; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; @@ -77,14 +78,18 @@ import java.time.DayOfWeek; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.time.format.ResolverStyle; import java.util.Collections; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.util.locale.provider.CalendarDataUtility; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * Localized definitions of the day-of-week, week-of-month and week-of-year fields. @@ -93,8 +98,9 @@ * other aspects of a week. This class represents the definition of the week, for the * purpose of providing {@link TemporalField} instances. *

    - * WeekFields provides three fields, - * {@link #dayOfWeek()}, {@link #weekOfMonth()}, and {@link #weekOfYear()} + * WeekFields provides five fields, + * {@link #dayOfWeek()}, {@link #weekOfMonth()}, {@link #weekOfYear()}, + * {@link #weekOfWeekBasedYear()}, and {@link #weekBasedYear()} * that provide access to the values from any {@linkplain Temporal temporal object}. *

    * The computations for day-of-week, week-of-month, and week-of-year are based @@ -110,7 +116,7 @@ *

  • The first day-of-week. * For example, the ISO-8601 standard considers Monday to be the first day-of-week. *
  • The minimal number of days in the first week. - * For example, the ISO-08601 standard counts the first week as needing at least 4 days. + * For example, the ISO-8601 standard counts the first week as needing at least 4 days. *

    * Together these two values allow a year or month to be divided into weeks. *

    @@ -134,14 +140,37 @@ * 2009-01-05Monday * Week 2 of January 2009Week 1 of January 2009 * - *

    + * *

    Week of Year

    * One field is used: week-of-year. * The calculation ensures that weeks never overlap a year boundary. * The year is divided into periods where each period starts on the defined first day-of-week. * The earliest period is referred to as week 0 if it has less than the minimal number of days * and week 1 if it has at least the minimal number of days. - *

    + * + *

    Week Based Year

    + * Two fields are used for week-based-year, one for the + * {@link #weekOfWeekBasedYear() week-of-week-based-year} and one for + * {@link #weekBasedYear() week-based-year}. In a week-based-year, each week + * belongs to only a single year. Week 1 of a year is the first week that + * starts on the first day-of-week and has at least the minimum number of days. + * The first and last weeks of a year may contain days from the + * previous calendar year or next calendar year respectively. + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Examples of WeekFields for week-based-year
    DateDay-of-weekFirst day: Monday
    Minimal days: 4
    First day: Monday
    Minimal days: 5
    2008-12-31WednesdayWeek 1 of 2009Week 53 of 2008
    2009-01-01ThursdayWeek 1 of 2009Week 53 of 2008
    2009-01-04SundayWeek 1 of 2009Week 53 of 2008
    2009-01-05MondayWeek 2 of 2009Week 1 of 2009
    + *

    Specification for implementors

    * This class is immutable and thread-safe. * * @since 1.8 @@ -171,19 +200,41 @@ * Note that the first week may start in the previous calendar year. * Note also that the first few days of a calendar year may be in the * week-based-year corresponding to the previous calendar year. + *

    + * This field is an immutable and thread-safe singleton. */ public static final WeekFields ISO = new WeekFields(DayOfWeek.MONDAY, 4); /** - * The common definition of a week that starts on Sunday. + * The common definition of a week that starts on Sunday and the first week + * has a minimum of 1 day. *

    * Defined as starting on Sunday and with a minimum of 1 day in the month. * This week definition is in use in the US and other European countries. - * + *

    + * This field is an immutable and thread-safe singleton. */ public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1); /** + * The unit that represents week-based-years for the purpose of addition and subtraction. + *

    + * This allows a number of week-based-years to be added to, or subtracted from, a date. + * The unit is equal to either 52 or 53 weeks. + * The estimated duration of a week-based-year is the same as that of a standard ISO + * year at {@code 365.2425 Days}. + *

    + * The rules for addition add the number of week-based-years to the existing value + * for the week-based-year field retaining the week-of-week-based-year + * and day-of-week, unless the week number it too large for the target year. + * In that case, the week is set to the last week of the year + * with the same day-of-week. + *

    + * This field is an immutable and thread-safe singleton. + */ + public static final TemporalUnit WEEK_BASED_YEARS = IsoFields.WEEK_BASED_YEARS; + + /** * Serialization version. */ private static final long serialVersionUID = -1177360819670808121L; @@ -213,6 +264,24 @@ private transient final TemporalField weekOfYear = ComputedDayOfField.ofWeekOfYearField(this); /** + * The field that represents the week-of-week-based-year. + *

    + * This field allows the week of the week-based-year value to be queried and set. + *

    + * This unit is an immutable and thread-safe singleton. + */ + private transient final TemporalField weekOfWeekBasedYear = ComputedDayOfField.ofWeekOfWeekBasedYearField(this); + + /** + * The field that represents the week-based-year. + *

    + * This field allows the week-based-year value to be queried and set. + *

    + * This unit is an immutable and thread-safe singleton. + */ + private transient final TemporalField weekBasedYear = ComputedDayOfField.ofWeekBasedYearField(this); + + /** * Obtains an instance of {@code WeekFields} appropriate for a locale. *

    * This will look up appropriate values from the provider of localization data. @@ -341,7 +410,7 @@ * Returns a field to access the week of month, * computed based on this WeekFields. *

    - * This represents concept of the count of weeks within the month where weeks + * This represents the concept of the count of weeks within the month where weeks * start on a fixed day-of-week, such as Monday. * This field is typically used with {@link WeekFields#dayOfWeek()}. *

    @@ -367,12 +436,12 @@ * Returns a field to access the week of year, * computed based on this WeekFields. *

    - * This represents concept of the count of weeks within the year where weeks + * This represents the concept of the count of weeks within the year where weeks * start on a fixed day-of-week, such as Monday. * This field is typically used with {@link WeekFields#dayOfWeek()}. *

    * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} - * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the month. + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. * Thus, week one may start up to {@code minDays} days before the start of the year. * If the first week starts after the start of the year then the period before is week zero (0). *

    @@ -390,7 +459,59 @@ } /** - * Checks if these rules are equal to the specified rules. + * Returns a field to access the week of a week-based-year, + * computed based on this WeekFields. + *

    + * This represents the concept of the count of weeks within the year where weeks + * start on a fixed day-of-week, such as Monday and each week belongs to exactly one year. + * This field is typically used with {@link WeekFields#dayOfWeek()} and + * {@link WeekFields#weekBasedYear()}. + *

    + * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. + * If the first week starts after the start of the year then the period before + * is in the last week of the previous year. + *

    + * For example:
    + * - if the 1st day of the year is a Monday, week one starts on the 1st
    + * - if the 2nd day of the year is a Monday, week one starts on the 2nd and + * the 1st is in the last week of the previous year
    + * - if the 4th day of the year is a Monday, week one starts on the 4th and + * the 1st to 3rd is in the last week of the previous year
    + * - if the 5th day of the year is a Monday, week two starts on the 5th and + * the 1st to 4th is in week one
    + *

    + * This field can be used with any calendar system. + * @return a TemporalField to access the week of week-based-year, not null + */ + public TemporalField weekOfWeekBasedYear() { + return weekOfWeekBasedYear; + } + + /** + * Returns a field to access the year of a week-based-year, + * computed based on this WeekFields. + *

    + * This represents the concept of the year where weeks start on a fixed day-of-week, + * such as Monday and each week belongs to exactly one year. + * This field is typically used with {@link WeekFields#dayOfWeek()} and + * {@link WeekFields#weekOfWeekBasedYear()}. + *

    + * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. + * Thus, week one may start before the start of the year. + * If the first week starts after the start of the year then the period before + * is in the last week of the previous year. + *

    + * This field can be used with any calendar system. + * @return a TemporalField to access the year of week-based-year, not null + */ + public TemporalField weekBasedYear() { + return weekBasedYear; + } + + /** + * Checks if this WeekFields is equal to the specified object. *

    * The comparison is based on the entire state of the rules, which is * the first day-of-week and minimal days. @@ -469,6 +590,49 @@ static ComputedDayOfField ofWeekOfYearField(WeekFields weekDef) { return new ComputedDayOfField("WeekOfYear", weekDef, WEEKS, YEARS, WEEK_OF_YEAR_RANGE); } + + /** + * Returns a field to access the week of week-based-year, + * computed based on a WeekFields. + * @see WeekFields#weekOfWeekBasedYear() + */ + static ComputedDayOfField ofWeekOfWeekBasedYearField(WeekFields weekDef) { + return new ComputedDayOfField("WeekOfWeekBasedYear", weekDef, WEEKS, IsoFields.WEEK_BASED_YEARS, WEEK_OF_YEAR_RANGE); + } + + /** + * Returns a field to access the week of week-based-year, + * computed based on a WeekFields. + * @see WeekFields#weekBasedYear() + */ + static ComputedDayOfField ofWeekBasedYearField(WeekFields weekDef) { + return new ComputedDayOfField("WeekBasedYear", weekDef, IsoFields.WEEK_BASED_YEARS, FOREVER, ChronoField.YEAR.range()); + } + + /** + * Return a new week-based-year date of the Chronology, year, week-of-year, + * and dow of week. + * @param chrono The chronology of the new date + * @param yowby the year of the week-based-year + * @param wowby the week of the week-based-year + * @param dow the day of the week + * @return a ChronoLocalDate for the requested year, week of year, and day of week + */ + private ChronoLocalDate ofWeekBasedYear(Chronology chrono, + int yowby, int wowby, int dow) { + ChronoLocalDate date = chrono.date(yowby, 1, 1); + int ldow = localizedDayOfWeek(date); + int offset = startOfWeekOffset(1, ldow); + + // Clamp the week of year to keep it in the same year + int yearLen = date.lengthOfYear(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + wowby = Math.min(wowby, newYearWeek - 1); + + int days = -offset + (dow - 1) + (wowby - 1) * 7; + return date.plus(days, DAYS); + } + private final String name; private final WeekFields weekDef; private final TemporalUnit baseUnit; @@ -489,44 +653,109 @@ @Override public long getFrom(TemporalAccessor temporal) { - // Offset the ISO DOW by the start of this week - int sow = weekDef.getFirstDayOfWeek().getValue(); - int dow = localizedDayOfWeek(temporal, sow); - if (rangeUnit == WEEKS) { // day-of-week - return dow; + return localizedDayOfWeek(temporal); } else if (rangeUnit == MONTHS) { // week-of-month - return localizedWeekOfMonth(temporal, dow); + return localizedWeekOfMonth(temporal); } else if (rangeUnit == YEARS) { // week-of-year - return localizedWeekOfYear(temporal, dow); + return localizedWeekOfYear(temporal); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return localizedWeekOfWeekBasedYear(temporal); + } else if (rangeUnit == FOREVER) { + return localizedWeekBasedYear(temporal); } else { - throw new IllegalStateException("unreachable"); + throw new IllegalStateException("unreachable, rangeUnit: " + rangeUnit + ", this: " + this); } } - private int localizedDayOfWeek(TemporalAccessor temporal, int sow) { + private int localizedDayOfWeek(TemporalAccessor temporal) { + int sow = weekDef.getFirstDayOfWeek().getValue(); int isoDow = temporal.get(DAY_OF_WEEK); return Math.floorMod(isoDow - sow, 7) + 1; } - private long localizedWeekOfMonth(TemporalAccessor temporal, int dow) { + private long localizedWeekOfMonth(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); int dom = temporal.get(DAY_OF_MONTH); int offset = startOfWeekOffset(dom, dow); return computeWeek(offset, dom); } - private long localizedWeekOfYear(TemporalAccessor temporal, int dow) { + private long localizedWeekOfYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); int doy = temporal.get(DAY_OF_YEAR); int offset = startOfWeekOffset(doy, dow); return computeWeek(offset, doy); } /** + * Returns the year of week-based-year for the temporal. + * The year can be the previous year, the current year, or the next year. + * @param temporal a date of any chronology, not null + * @return the year of week-based-year for the date + */ + private int localizedWeekBasedYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); + int year = temporal.get(YEAR); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year; return the previous year + return year - 1; + } else { + // If getting close to end of year, use higher precision logic + // Check if date of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + if (week >= newYearWeek) { + return year + 1; + } + } + return year; + } + + /** + * Returns the week of week-based-year for the temporal. + * The week can be part of the previous year, the current year, + * or the next year depending on the week start and minimum number + * of days. + * @param temporal a date of any chronology + * @return the week of the year + * @see #localizedWeekBasedYear(java.time.temporal.TemporalAccessor) + */ + private int localizedWeekOfWeekBasedYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year + // Recompute from the last day of the previous year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.minus(doy, DAYS); // Back down into previous year + return localizedWeekOfWeekBasedYear(date); + } else if (week > 50) { + // If getting close to end of year, use higher precision logic + // Check if date of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + if (week >= newYearWeek) { + // Overlaps with week of following year; reduce to week in following year + week = week - newYearWeek + 1; + } + } + return week; + } + + /** * Returns an offset to align week start with a day of month or day of year. * - * @param day the day; 1 through infinity - * @param dow the day of the week of that day; 1 through 7 - * @return an offset in days to align a day with the start of the first 'full' week + * @param day the day; 1 through infinity + * @param dow the day of the week of that day; 1 through 7 + * @return an offset in days to align a day with the start of the first 'full' week */ private int startOfWeekOffset(int day, int dow) { // offset of first day corresponding to the day of week in first 7 days (zero origin) @@ -560,54 +789,81 @@ if (newVal == currentVal) { return temporal; } - // Compute the difference and add that using the base using of the field - return (R) temporal.plus(newVal - currentVal, baseUnit); + + if (rangeUnit == FOREVER) { // replace year of WeekBasedYear + // Create a new date object with the same chronology, + // the desired year and the same week and dow. + int idow = temporal.get(weekDef.dayOfWeek); + int wowby = temporal.get(weekDef.weekOfWeekBasedYear); + return (R) ofWeekBasedYear(Chronology.from(temporal), (int)newValue, wowby, idow); + } else { + // Compute the difference and add that using the base unit of the field + return (R) temporal.plus(newVal - currentVal, baseUnit); + } } @Override - public Map resolve(TemporalAccessor temporal, long value) { + public Map resolve(TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { int newValue = range.checkValidIntValue(value, this); int sow = weekDef.getFirstDayOfWeek().getValue(); if (rangeUnit == WEEKS) { // day-of-week int isoDow = Math.floorMod((sow - 1) + (newValue - 1), 7) + 1; return Collections.singletonMap(DAY_OF_WEEK, (long) isoDow); } - if ((temporal.isSupported(YEAR) && temporal.isSupported(DAY_OF_WEEK)) == false) { + if (temporal.isSupported(DAY_OF_WEEK) == false) { return null; } - int dow = localizedDayOfWeek(temporal, sow); - int year = temporal.get(YEAR); Chronology chrono = Chronology.from(temporal); // defaults to ISO - if (rangeUnit == MONTHS) { // week-of-month - if (temporal.isSupported(MONTH_OF_YEAR) == false) { - return null; + int dow = localizedDayOfWeek(temporal); + if (temporal.isSupported(YEAR)) { + int year = temporal.get(YEAR); + if (rangeUnit == MONTHS) { // week-of-month + if (temporal.isSupported(MONTH_OF_YEAR) == false) { + return null; + } + int month = temporal.get(ChronoField.MONTH_OF_YEAR); + @SuppressWarnings("rawtypes") + ChronoLocalDate date = chrono.date(year, month, 1); + int dateDow = localizedDayOfWeek(date); + long weeks = newValue - localizedWeekOfMonth(date); + int days = dow - dateDow; + date = date.plus(weeks * 7 + days, DAYS); + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(YEAR, null); + result.put(MONTH_OF_YEAR, null); + result.put(DAY_OF_WEEK, null); + return result; + } else if (rangeUnit == YEARS) { // week-of-year + @SuppressWarnings("rawtypes") + ChronoLocalDate date = chrono.date(year, 1, 1); + int dateDow = localizedDayOfWeek(date); + long weeks = newValue - localizedWeekOfYear(date); + int days = dow - dateDow; + date = date.plus(weeks * 7 + days, DAYS); + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(YEAR, null); + result.put(DAY_OF_WEEK, null); + return result; + } + } else if (rangeUnit == WEEK_BASED_YEARS || rangeUnit == FOREVER) { + if (temporal.isSupported(weekDef.weekBasedYear) && + temporal.isSupported(weekDef.weekOfWeekBasedYear)) { + // week-of-week-based-year and year-of-week-based-year + int yowby = temporal.get(weekDef.weekBasedYear); + int wowby = temporal.get(weekDef.weekOfWeekBasedYear); + ChronoLocalDate date = ofWeekBasedYear(Chronology.from(temporal), yowby, wowby, dow); + + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(DAY_OF_WEEK, null); + result.put(weekDef.weekOfWeekBasedYear, null); + result.put(weekDef.weekBasedYear, null); + return result; } - int month = temporal.get(ChronoField.MONTH_OF_YEAR); - ChronoLocalDate date = chrono.date(year, month, 1); - int dateDow = localizedDayOfWeek(date, sow); - long weeks = newValue - localizedWeekOfMonth(date, dateDow); - int days = dow - dateDow; - date = date.plus(weeks * 7 + days, DAYS); - Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); - result.put(YEAR, null); - result.put(MONTH_OF_YEAR, null); - result.put(DAY_OF_WEEK, null); - return result; - } else if (rangeUnit == YEARS) { // week-of-year - ChronoLocalDate date = chrono.date(year, 1, 1); - int dateDow = localizedDayOfWeek(date, sow); - long weeks = newValue - localizedWeekOfYear(date, dateDow); - int days = dow - dateDow; - date = date.plus(weeks * 7 + days, DAYS); - Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); - result.put(YEAR, null); - result.put(DAY_OF_WEEK, null); - return result; - } else { - throw new IllegalStateException("unreachable"); } + return null; } //----------------------------------------------------------------------- @@ -617,6 +873,18 @@ } @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + if (rangeUnit == YEARS) { // only have values for week-of-year + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey("field.week") ? rb.getString("field.week") : getName(); + } + return getName(); + } + + @Override public TemporalUnit getBaseUnit() { return baseUnit; } @@ -627,6 +895,11 @@ } @Override + public boolean isDateBased() { + return true; + } + + @Override public ValueRange range() { return range; } @@ -641,6 +914,10 @@ return temporal.isSupported(DAY_OF_MONTH); } else if (rangeUnit == YEARS) { // week-of-year return temporal.isSupported(DAY_OF_YEAR); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return temporal.isSupported(DAY_OF_YEAR); + } else if (rangeUnit == FOREVER) { + return temporal.isSupported(YEAR); } } return false; @@ -650,27 +927,68 @@ public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (rangeUnit == ChronoUnit.WEEKS) { // day-of-week return range; - } - - TemporalField field = null; - if (rangeUnit == MONTHS) { // week-of-month - field = DAY_OF_MONTH; + } else if (rangeUnit == MONTHS) { // week-of-month + return rangeByWeek(temporal, DAY_OF_MONTH); } else if (rangeUnit == YEARS) { // week-of-year - field = DAY_OF_YEAR; + return rangeByWeek(temporal, DAY_OF_YEAR); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return rangeWeekOfWeekBasedYear(temporal); + } else if (rangeUnit == FOREVER) { + return YEAR.range(); } else { - throw new IllegalStateException("unreachable"); + throw new IllegalStateException("unreachable, rangeUnit: " + rangeUnit + ", this: " + this); } + } - // Offset the ISO DOW by the start of this week - int sow = weekDef.getFirstDayOfWeek().getValue(); - int dow = localizedDayOfWeek(temporal, sow); - + /** + * Map the field range to a week range + * @param temporal the temporal + * @param field the field to get the range of + * @return the ValueRange with the range adjusted to weeks. + */ + private ValueRange rangeByWeek(TemporalAccessor temporal, TemporalField field) { + int dow = localizedDayOfWeek(temporal); int offset = startOfWeekOffset(temporal.get(field), dow); ValueRange fieldRange = temporal.range(field); return ValueRange.of(computeWeek(offset, (int) fieldRange.getMinimum()), computeWeek(offset, (int) fieldRange.getMaximum())); } + /** + * Map the field range to a week range of a week year. + * @param temporal the temporal + * @param field the field to get the range of + * @return the ValueRange with the range adjusted to weeks. + */ + private ValueRange rangeWeekOfWeekBasedYear(TemporalAccessor temporal) { + if (!temporal.isSupported(DAY_OF_YEAR)) { + return WEEK_OF_YEAR_RANGE; + } + int dow = localizedDayOfWeek(temporal); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year + // Recompute from the last day of the previous year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.minus(doy + 7, DAYS); // Back down into previous year + return rangeWeekOfWeekBasedYear(date); + } + // Check if day of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + + if (week >= newYearWeek) { + // Overlaps with weeks of following year; recompute from a week in following year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.plus(yearLen - doy + 1 + 7, ChronoUnit.DAYS); + return rangeWeekOfWeekBasedYear(date); + } + return ValueRange.of(1, newYearWeek-1); + } + //----------------------------------------------------------------------- @Override public String toString() { --- old/src/share/classes/java/time/temporal/package-info.java 2013-04-11 23:15:56.000000000 -0700 +++ new/src/share/classes/java/time/temporal/package-info.java 2013-04-11 23:15:56.000000000 -0700 @@ -112,9 +112,9 @@ * such as the "last day of the month", or "next Wednesday". * These are modeled as functions that adjust a base date-time. * The functions implement {@link java.time.temporal.TemporalAdjuster} and operate on {@code Temporal}. - * A set of common functions are provided in {@link java.time.temporal.Adjusters}. + * A set of common functions are provided in {@code TemporalAdjuster}. * For example, to find the first occurrence of a day-of-week after a given date, use - * {@link java.time.temporal.Adjusters#next(DayOfWeek)}, such as + * {@link java.time.temporal.TemporalAdjuster#next(DayOfWeek)}, such as * {@code date.with(next(MONDAY))}. * Applications can also define adjusters by implementing {@code TemporalAdjuster}. *

    @@ -127,7 +127,7 @@ * The most common implementations of the query interface are method references. * The {@code from(TemporalAccessor)} methods on major classes can all be used, such as * {@code LocalDate::from} or {@code Month::from}. - * Further implementations are provided in {@link java.time.temporal.Queries}. + * Further implementations are provided in {@code TemporalQuery} as static methods. * Applications can also define queries by implementing {@code TemporalQuery}. *

    * --- old/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java 2013-04-11 23:15:57.000000000 -0700 +++ new/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java 2013-04-11 23:15:57.000000000 -0700 @@ -64,6 +64,7 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.StreamCorruptedException; import java.util.Arrays; @@ -75,7 +76,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; -import java.util.zip.ZipFile; /** * Loads time-zone rules for 'TZDB'. @@ -106,10 +106,8 @@ public TzdbZoneRulesProvider() { try { String libDir = System.getProperty("java.home") + File.separator + "lib"; - File tzdbJar = new File(libDir, "tzdb.jar"); - try (ZipFile zf = new ZipFile(tzdbJar); - DataInputStream dis = new DataInputStream( - zf.getInputStream(zf.getEntry("TZDB.dat")))) { + try (DataInputStream dis = new DataInputStream( + new FileInputStream(new File(libDir, "tzdb.dat")))) { load(dis); } } catch (Exception ex) { --- old/src/share/classes/java/time/zone/ZoneOffsetTransition.java 2013-04-11 23:15:58.000000000 -0700 +++ new/src/share/classes/java/time/zone/ZoneOffsetTransition.java 2013-04-11 23:15:57.000000000 -0700 @@ -321,7 +321,7 @@ } /** - * Does this transition represent a gap in the local time-line. + * Does this transition represent an overlap in the local time-line. *

    * Overlaps occur where there are local date-times that exist twice. * An example would be when the offset changes from {@code +02:00} to {@code +01:00}. --- old/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java 2013-04-11 23:15:58.000000000 -0700 +++ new/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java 2013-04-11 23:15:58.000000000 -0700 @@ -61,8 +61,8 @@ */ package java.time.zone; -import static java.time.temporal.Adjusters.nextOrSame; -import static java.time.temporal.Adjusters.previousOrSame; +import static java.time.temporal.TemporalAdjuster.nextOrSame; +import static java.time.temporal.TemporalAdjuster.previousOrSame; import java.io.DataInput; import java.io.DataOutput; --- old/src/share/classes/java/time/zone/ZoneRulesProvider.java 2013-04-11 23:15:59.000000000 -0700 +++ new/src/share/classes/java/time/zone/ZoneRulesProvider.java 2013-04-11 23:15:59.000000000 -0700 @@ -141,7 +141,7 @@ // if the property java.time.zone.DefaultZoneRulesProvider is // set then its value is the class name of the default provider final List loaded = new ArrayList<>(); - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider"); if (prop != null) { --- old/src/share/classes/java/util/Formatter.java 2013-04-11 23:15:59.000000000 -0700 +++ new/src/share/classes/java/util/Formatter.java 2013-04-11 23:15:59.000000000 -0700 @@ -56,7 +56,7 @@ import java.time.ZoneOffset; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; -import java.time.temporal.Queries; +import java.time.temporal.TemporalQuery; import sun.misc.DoubleConsts; import sun.misc.FormattedFloatingDecimal; @@ -4160,7 +4160,7 @@ break; } case DateTime.ZONE: { // 'Z' (symbol) - ZoneId zid = t.query(Queries.zone()); + ZoneId zid = t.query(TemporalQuery.zone()); if (zid == null) { throw new IllegalFormatConversionException(c, t.getClass()); } --- old/src/share/classes/java/util/GregorianCalendar.java 2013-04-11 23:16:00.000000000 -0700 +++ new/src/share/classes/java/util/GregorianCalendar.java 2013-04-11 23:16:00.000000000 -0700 @@ -45,7 +45,7 @@ import java.time.ZonedDateTime; import java.time.chrono.IsoChronology; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; +import java.time.temporal.TemporalQuery; import sun.util.calendar.BaseCalendar; import sun.util.calendar.CalendarDate; import sun.util.calendar.CalendarSystem; --- old/src/share/classes/java/util/TimeZone.java 2013-04-11 23:16:01.000000000 -0700 +++ new/src/share/classes/java/util/TimeZone.java 2013-04-11 23:16:01.000000000 -0700 @@ -559,7 +559,7 @@ * @since 1.8 */ public ZoneId toZoneId() { - return ZoneId.of(getID(), ZoneId.OLD_IDS_POST_2005); + return ZoneId.of(getID(), ZoneId.SHORT_IDS); } private static TimeZone getTimeZone(String ID, boolean fallback) { --- old/src/share/classes/sun/text/resources/FormatData.java 2013-04-11 23:16:02.000000000 -0700 +++ new/src/share/classes/sun/text/resources/FormatData.java 2013-04-11 23:16:01.000000000 -0700 @@ -79,9 +79,9 @@ package sun.text.resources; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData extends ListResourceBundle { +public class FormatData extends ParallelListResourceBundle { /** * Overrides ListResourceBundle */ @@ -117,12 +117,6 @@ "Heisei", }; - // Minguo era strings - final String[] rocEras ={ - "Before R.O.C.", - "R.O.C.", - }; - return new Object[][] { { "MonthNames", new String[] { @@ -158,6 +152,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Sunday", // Sunday @@ -205,13 +216,7 @@ }, { "Eras", julianEras }, - { "cldr.long.Eras", - new String[] { - "Before Christ", - "Anno Domini" - } - }, - { "cldr.short.Eras", + { "short.Eras", julianEras }, { "narrow.Eras", new String[] { @@ -230,10 +235,6 @@ }, { "japanese.Eras", japaneseEras }, - { "cldr.japanese.long.Eras", - japaneseEras }, - { "cldr.japanese.short.Eras", - japaneseEras }, { "japanese.short.Eras", japaneseEraAbbrs }, @@ -822,14 +823,6 @@ "H:mm", // short time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yyyy-MM-dd", - } - }, { "buddhist.DatePatterns", new String[] { "EEEE d MMMM G yyyy", // full date pattern @@ -851,14 +844,6 @@ "h:mm a", // short time pattern } }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yy-MM-dd", - } - }, { "japanese.DatePatterns", new String[] { "GGGG yyyy MMMM d (EEEE)", // full date pattern @@ -872,99 +857,7 @@ "{1} {0}" // date-time pattern } }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yyy-MM-dd", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, GGGG y MMMM dd", - "GGGG y MMMM d", - "GGGG y MMM d", - "G yyy-MM-dd", - } - }, - { "islamic.MonthNames", - new String[] { - "Muharram", - "Safar", - "Rabi\u02bb I", - "Rabi\u02bb II", - "Jumada I", - "Jumada II", - "Rajab", - "Sha\u02bbban", - "Ramadan", - "Shawwal", - "Dhu\u02bbl-Qi\u02bbdah", - "Dhu\u02bbl-Hijjah", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Muh.", - "Saf.", - "Rab. I", - "Rab. II", - "Jum. I", - "Jum. II", - "Raj.", - "Sha.", - "Ram.", - "Shaw.", - "Dhu\u02bbl-Q.", - "Dhu\u02bbl-H.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "AH", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, MMMM d, y G", - "MMMM d, y G", - "MMM d, y G", - "M/d/yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, MMMM d, y GGGG", - "MMMM d, y GGGG", - "MMM d, y GGGG", - "M/d/yy GGGG", - } - }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "Islamic-Civil Calendar" }, - { "calendarname.islamicc", "Islamic-Civil Calendar" }, - { "calendarname.islamic", "Islamic Calendar" }, - { "calendarname.japanese", "Japanese Calendar" }, - { "calendarname.gregorian", "Gregorian Calendar" }, - { "calendarname.gregory", "Gregorian Calendar" }, - { "calendarname.roc", "Minguo Calendar" }, - { "calendarname.buddhist", "Buddhist Calendar" }, - { "field.era", "Era" }, - { "field.year", "Year" }, - { "field.month", "Month" }, - { "field.week", "Week" }, - { "field.weekday", "Day of the Week" }, - { "field.dayperiod", "Dayperiod" }, - { "field.hour", "Hour" }, - { "field.minute", "Minute" }, - { "field.second", "Second" }, - { "field.zone", "Zone" }, }; } } --- old/src/share/classes/sun/text/resources/ar/FormatData_ar.java 2013-04-11 23:16:02.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ar/FormatData_ar.java 2013-04-11 23:16:02.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar extends ListResourceBundle { +public class FormatData_ar extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -126,6 +126,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u064a", + "\u0641", + "\u0645", + "\u0623", + "\u0648", + "\u0646", + "\u0644", + "\u063a", + "\u0633", + "\u0643", + "\u0628", + "\u062f", + "", + } + }, { "DayNames", new String[] { "\u0627\u0644\u0623\u062d\u062f", // Sunday @@ -148,6 +165,17 @@ "\u0633" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u0627\u0644\u0623\u062d\u062f", + "\u0627\u0644\u0627\u062b\u0646\u064a\u0646", + "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621", + "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621", + "\u0627\u0644\u062e\u0645\u064a\u0633", + "\u0627\u0644\u062c\u0645\u0639\u0629", + "\u0627\u0644\u0633\u0628\u062a", + } + }, { "DayNarrows", new String[] { "\u062d", @@ -171,6 +199,42 @@ "\u0645" } }, + { "short.Eras", + new String[] { + "\u0642.\u0645", + "\u0645", + } + }, + { "japanese.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "japanese.short.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, + { "buddhist.short.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, { "NumberPatterns", new String[] { "#,##0.###;#,##0.###-", // decimal pattern @@ -200,114 +264,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y GGGG", - "d MMMM\u060c y GGGG", - "dd\u200f/MM\u200f/y GGGG", - "d\u200f/M\u200f/y GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "\u0645\u062d\u0631\u0645", - "\u0635\u0641\u0631", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", - "\u0631\u062c\u0628", - "\u0634\u0639\u0628\u0627\u0646", - "\u0631\u0645\u0636\u0627\u0646", - "\u0634\u0648\u0627\u0644", - "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", - "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "\u0645\u062d\u0631\u0645", - "\u0635\u0641\u0631", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", - "\u0631\u062c\u0628", - "\u0634\u0639\u0628\u0627\u0646", - "\u0631\u0645\u0636\u0627\u0646", - "\u0634\u0648\u0627\u0644", - "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", - "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0647\u0640", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE\u060c d MMMM y", - "d MMMM y", - "d MMM\u060c y G", - "d\u200f/M\u200f/yyyy", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE\u060c d MMMM y", - "d MMMM y", - "d MMM\u060c y GGGG", - "d\u200f/M\u200f/yyyy", - } - }, - { "calendarname.islamic-civil", "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, - { "calendarname.islamicc", "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, - { "calendarname.islamic", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a" }, - { "calendarname.japanese", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a" }, - { "calendarname.gregorian", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, - { "calendarname.gregory", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, - { "calendarname.roc", "\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648" }, - { "calendarname.buddhist", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a" }, - { "field.era", "\u0627\u0644\u0639\u0635\u0631" }, - { "field.year", "\u0627\u0644\u0633\u0646\u0629" }, - { "field.month", "\u0627\u0644\u0634\u0647\u0631" }, - { "field.week", "\u0627\u0644\u0623\u0633\u0628\u0648\u0639" }, - { "field.weekday", "\u0627\u0644\u064a\u0648\u0645" }, - { "field.dayperiod", "\u0635/\u0645" }, - { "field.hour", "\u0627\u0644\u0633\u0627\u0639\u0627\u062a" }, - { "field.minute", "\u0627\u0644\u062f\u0642\u0627\u0626\u0642" }, - { "field.second", "\u0627\u0644\u062b\u0648\u0627\u0646\u064a" }, - { "field.zone", "\u0627\u0644\u062a\u0648\u0642\u064a\u062a" }, }; } } --- old/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java 2013-04-11 23:16:03.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java 2013-04-11 23:16:03.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_JO extends ListResourceBundle { +public class FormatData_ar_JO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java 2013-04-11 23:16:04.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java 2013-04-11 23:16:03.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_LB extends ListResourceBundle { +public class FormatData_ar_LB extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java 2013-04-11 23:16:04.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java 2013-04-11 23:16:04.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_SY extends ListResourceBundle { +public class FormatData_ar_SY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/be/FormatData_be.java 2013-04-11 23:16:05.000000000 -0700 +++ new/src/share/classes/sun/text/resources/be/FormatData_be.java 2013-04-11 23:16:04.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.be; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_be extends ListResourceBundle { +public class FormatData_be extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -177,6 +177,12 @@ "\u043d.\u0435." } }, + { "short.Eras", + new String[] { + "\u0434\u0430 \u043d.\u044d.", + "\u043d.\u044d.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -214,29 +220,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "d MMM y G", - "d.M.yy", - } - }, - { "calendarname.islamic-civil", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.buddhist", "\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "field.era", "\u044d\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434" }, - { "field.month", "\u043c\u0435\u0441\u044f\u0446" }, - { "field.week", "\u0442\u044b\u0434\u0437\u0435\u043d\u044c" }, - { "field.weekday", "\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f" }, - { "field.hour", "\u0433\u0430\u0434\u0437\u0456\u043d\u0430" }, - { "field.minute", "\u0445\u0432\u0456\u043b\u0456\u043d\u0430" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, }; } } --- old/src/share/classes/sun/text/resources/be/FormatData_be_BY.java 2013-04-11 23:16:05.000000000 -0700 +++ new/src/share/classes/sun/text/resources/be/FormatData_be_BY.java 2013-04-11 23:16:05.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.be; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_be_BY extends ListResourceBundle { +public class FormatData_be_BY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/bg/FormatData_bg.java 2013-04-11 23:16:06.000000000 -0700 +++ new/src/share/classes/sun/text/resources/bg/FormatData_bg.java 2013-04-11 23:16:06.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.bg; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_bg extends ListResourceBundle { +public class FormatData_bg extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u044f", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u044e", + "\u044e", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u041d\u0435\u0434\u0435\u043b\u044f", // Sunday @@ -160,6 +177,12 @@ "\u043d.\u0435." } }, + { "short.Eras", + new String[] { + "\u043f\u0440. \u043d. \u0435.", + "\u043e\u0442 \u043d. \u0435.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -197,41 +220,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u043c\u0443\u0445\u0430\u0440\u0430\u043c", - "\u0441\u0430\u0444\u0430\u0440", - "\u0440\u0430\u0431\u0438-1", - "\u0440\u0430\u0431\u0438-2", - "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1", - "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2", - "\u0440\u0430\u0434\u0436\u0430\u0431", - "\u0448\u0430\u0431\u0430\u043d", - "\u0440\u0430\u043c\u0430\u0437\u0430\u043d", - "\u0428\u0430\u0432\u0430\u043b", - "\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430", - "\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430", - "", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0435\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u043c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u0441\u0435\u0434\u043c\u0438\u0446\u0430" }, - { "field.weekday", "\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430" }, - { "field.dayperiod", "\u0434\u0435\u043d" }, - { "field.hour", "\u0447\u0430\u0441" }, - { "field.minute", "\u043c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } --- old/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java 2013-04-11 23:16:06.000000000 -0700 +++ new/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java 2013-04-11 23:16:06.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.bg; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_bg_BG extends ListResourceBundle { +public class FormatData_bg_BG extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ca/FormatData_ca.java 2013-04-11 23:16:07.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ca/FormatData_ca.java 2013-04-11 23:16:07.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.ca; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ca extends ListResourceBundle { +public class FormatData_ca extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -104,6 +104,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "J", + "G", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNames", new String[] { "gener", // january @@ -183,6 +200,17 @@ "dissabte" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Diumenge", + "Dilluns", + "Dimarts", + "Dimecres", + "Dijous", + "Divendres", + "Dissabte", + } + }, { "DayAbbreviations", new String[] { "dg.", // abb Sunday @@ -194,6 +222,17 @@ "ds." // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "dg", + "dl", + "dt", + "dc", + "dj", + "dv", + "ds", + } + }, { "DayNarrows", new String[] { "G", @@ -216,6 +255,12 @@ "s", } }, + { "short.Eras", + new String[] { + "aC", + "dC", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -253,24 +298,6 @@ } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "calendari civil isl\u00e0mic" }, - { "calendarname.islamicc", "calendari civil isl\u00e0mic" }, - { "calendarname.roc", "calendari de la Rep\u00fablica de Xina" }, - { "calendarname.islamic", "calendari musulm\u00e0" }, - { "calendarname.buddhist", "calendari budista" }, - { "calendarname.japanese", "calendari japon\u00e8s" }, - { "calendarname.gregorian", "calendari gregori\u00e0" }, - { "calendarname.gregory", "calendari gregori\u00e0" }, - { "field.era", "era" }, - { "field.year", "any" }, - { "field.month", "mes" }, - { "field.week", "setmana" }, - { "field.weekday", "dia de la setmana" }, - { "field.dayperiod", "a.m./p.m." }, - { "field.hour", "hora" }, - { "field.minute", "minut" }, - { "field.second", "segon" }, - { "field.zone", "zona" }, }; } } --- old/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java 2013-04-11 23:16:08.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java 2013-04-11 23:16:07.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.ca; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ca_ES extends ListResourceBundle { +public class FormatData_ca_ES extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/cs/FormatData_cs.java 2013-04-11 23:16:08.000000000 -0700 +++ new/src/share/classes/sun/text/resources/cs/FormatData_cs.java 2013-04-11 23:16:08.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.cs; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_cs extends ListResourceBundle { +public class FormatData_cs extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -155,6 +155,40 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "l", + "\u00fa", + "b", + "d", + "k", + "\u010d", + "\u010d", + "s", + "z", + "\u0159", + "l", + "p", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "l", + "\u00fa", + "b", + "d", + "k", + "\u010d", + "\u010d", + "s", + "z", + "\u0159", + "l", + "p", + "", + } + }, { "DayNames", new String[] { "Ned\u011ble", // Sunday @@ -166,6 +200,17 @@ "Sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "ned\u011ble", + "pond\u011bl\u00ed", + "\u00fater\u00fd", + "st\u0159eda", + "\u010dtvrtek", + "p\u00e1tek", + "sobota", + } + }, { "DayAbbreviations", new String[] { "Ne", // abb Sunday @@ -177,6 +222,17 @@ "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ne", + "po", + "\u00fat", + "st", + "\u010dt", + "p\u00e1", + "so", + } + }, { "DayNarrows", new String[] { "N", @@ -188,6 +244,17 @@ "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "\u00da", + "S", + "\u010c", + "P", + "S", + } + }, { "AmPmMarkers", new String[] { "dop.", // am marker @@ -200,6 +267,18 @@ "po Kr." } }, + { "short.Eras", + new String[] { + "p\u0159. n. l.", + "n. l.", + } + }, + { "narrow.Eras", + new String[] { + "p\u0159.n.l.", + "n. l.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -237,22 +316,6 @@ } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, - { "calendarname.islamicc", "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, - { "calendarname.islamic", "Muslimsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.buddhist", "Buddhistick\u00fd kalend\u00e1\u0159" }, - { "calendarname.japanese", "Japonsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.gregorian", "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.gregory", "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, - { "field.year", "Rok" }, - { "field.month", "M\u011bs\u00edc" }, - { "field.week", "T\u00fdden" }, - { "field.weekday", "Den v t\u00fddnu" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Hodina" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "\u010casov\u00e9 p\u00e1smo" }, }; } } --- old/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java 2013-04-11 23:16:09.000000000 -0700 +++ new/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java 2013-04-11 23:16:08.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.cs; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_cs_CZ extends ListResourceBundle { +public class FormatData_cs_CZ extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/da/FormatData_da.java 2013-04-11 23:16:09.000000000 -0700 +++ new/src/share/classes/sun/text/resources/da/FormatData_da.java 2013-04-11 23:16:09.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.da; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_da extends ListResourceBundle { +public class FormatData_da extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthAbbreviations", new String[] { "jan", // abb january @@ -186,6 +203,18 @@ "\ufffd" // NaN } }, + { "Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, { "TimePatterns", new String[] { "HH:mm:ss z", // full time pattern @@ -208,64 +237,6 @@ } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d/M/y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "verdslig islamisk kalender" }, - { "calendarname.islamicc", "verdslig islamisk kalender" }, - { "calendarname.roc", "kalender for Republikken Kina" }, - { "calendarname.islamic", "islamisk kalender" }, - { "calendarname.buddhist", "buddhistisk kalender" }, - { "calendarname.japanese", "japansk kalender" }, - { "calendarname.gregorian", "gregoriansk kalender" }, - { "calendarname.gregory", "gregoriansk kalender" }, - { "field.era", "\u00e6ra" }, - { "field.year", "\u00e5r" }, - { "field.month", "m\u00e5ned" }, - { "field.week", "uge" }, - { "field.weekday", "ugedag" }, - { "field.dayperiod", "dagtid" }, - { "field.hour", "time" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "tidszone" }, }; } } --- old/src/share/classes/sun/text/resources/da/FormatData_da_DK.java 2013-04-11 23:16:10.000000000 -0700 +++ new/src/share/classes/sun/text/resources/da/FormatData_da_DK.java 2013-04-11 23:16:10.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.da; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_da_DK extends ListResourceBundle { +public class FormatData_da_DK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/de/FormatData_de.java 2013-04-11 23:16:10.000000000 -0700 +++ new/src/share/classes/sun/text/resources/de/FormatData_de.java 2013-04-11 23:16:10.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de extends ListResourceBundle { +public class FormatData_de extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthAbbreviations", new String[] { "Jan", // abb january @@ -160,6 +177,17 @@ "Sa" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "So", + "Mo", + "Di", + "Mi", + "Do", + "Fr", + "Sa", + } + }, { "DayNarrows", new String[] { "S", @@ -177,6 +205,12 @@ "n. Chr." } }, + { "short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -214,72 +248,6 @@ } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d.M.y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d.M.y GGGG", - } - }, - { "calendarname.islamic-civil", "B\u00fcrgerlicher islamischer Kalender" }, - { "calendarname.islamicc", "B\u00fcrgerlicher islamischer Kalender" }, - { "calendarname.roc", "Kalender der Republik China" }, - { "calendarname.islamic", "Islamischer Kalender" }, - { "calendarname.buddhist", "Buddhistischer Kalender" }, - { "calendarname.japanese", "Japanischer Kalender" }, - { "calendarname.gregorian", "Gregorianischer Kalender" }, - { "calendarname.gregory", "Gregorianischer Kalender" }, - { "field.era", "Epoche" }, - { "field.year", "Jahr" }, - { "field.month", "Monat" }, - { "field.week", "Woche" }, - { "field.weekday", "Wochentag" }, - { "field.dayperiod", "Tagesh\u00e4lfte" }, - { "field.hour", "Stunde" }, - { "field.minute", "Minute" }, - { "field.second", "Sekunde" }, - { "field.zone", "Zone" }, }; } } --- old/src/share/classes/sun/text/resources/de/FormatData_de_AT.java 2013-04-11 23:16:11.000000000 -0700 +++ new/src/share/classes/sun/text/resources/de/FormatData_de_AT.java 2013-04-11 23:16:11.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_AT extends ListResourceBundle { +public class FormatData_de_AT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/de/FormatData_de_CH.java 2013-04-11 23:16:11.000000000 -0700 +++ new/src/share/classes/sun/text/resources/de/FormatData_de_CH.java 2013-04-11 23:16:11.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_CH extends ListResourceBundle { +public class FormatData_de_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/de/FormatData_de_DE.java 2013-04-11 23:16:12.000000000 -0700 +++ new/src/share/classes/sun/text/resources/de/FormatData_de_DE.java 2013-04-11 23:16:12.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_DE extends ListResourceBundle { +public class FormatData_de_DE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/de/FormatData_de_LU.java 2013-04-11 23:16:12.000000000 -0700 +++ new/src/share/classes/sun/text/resources/de/FormatData_de_LU.java 2013-04-11 23:16:12.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_LU extends ListResourceBundle { +public class FormatData_de_LU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/el/FormatData_el.java 2013-04-11 23:16:13.000000000 -0700 +++ new/src/share/classes/sun/text/resources/el/FormatData_el.java 2013-04-11 23:16:13.000000000 -0700 @@ -79,11 +79,11 @@ package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el extends ListResourceBundle { +public class FormatData_el extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -143,6 +143,57 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "\u0399\u03b1\u03bd", + "\u03a6\u03b5\u03b2", + "\u039c\u03ac\u03c1", + "\u0391\u03c0\u03c1", + "\u039c\u03ac\u03b9", + "\u0399\u03bf\u03cd\u03bd", + "\u0399\u03bf\u03cd\u03bb", + "\u0391\u03c5\u03b3", + "\u03a3\u03b5\u03c0", + "\u039f\u03ba\u03c4", + "\u039d\u03bf\u03ad", + "\u0394\u03b5\u03ba", + "", + } + }, + { "MonthNarrows", + new String[] { + "\u0399", + "\u03a6", + "\u039c", + "\u0391", + "\u039c", + "\u0399", + "\u0399", + "\u0391", + "\u03a3", + "\u039f", + "\u039d", + "\u0394", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "\u0399", + "\u03a6", + "\u039c", + "\u0391", + "\u039c", + "\u0399", + "\u0399", + "\u0391", + "\u03a3", + "\u039f", + "\u039d", + "\u0394", + "", + } + }, { "DayNames", new String[] { "\u039a\u03c5\u03c1\u03b9\u03b1\u03ba\u03ae", // Sunday @@ -154,6 +205,17 @@ "\u03a3\u03ac\u03b2\u03b2\u03b1\u03c4\u03bf" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u039a\u03c5\u03c1\u03b9\u03b1\u03ba\u03ae", + "\u0394\u03b5\u03c5\u03c4\u03ad\u03c1\u03b1", + "\u03a4\u03c1\u03af\u03c4\u03b7", + "\u03a4\u03b5\u03c4\u03ac\u03c1\u03c4\u03b7", + "\u03a0\u03ad\u03bc\u03c0\u03c4\u03b7", + "\u03a0\u03b1\u03c1\u03b1\u03c3\u03ba\u03b5\u03c5\u03ae", + "\u03a3\u03ac\u03b2\u03b2\u03b1\u03c4\u03bf", + } + }, { "DayAbbreviations", new String[] { "\u039a\u03c5\u03c1", // abb Sunday @@ -165,6 +227,17 @@ "\u03a3\u03b1\u03b2" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u039a\u03c5\u03c1", + "\u0394\u03b5\u03c5", + "\u03a4\u03c1\u03af", + "\u03a4\u03b5\u03c4", + "\u03a0\u03ad\u03bc", + "\u03a0\u03b1\u03c1", + "\u03a3\u03ac\u03b2", + } + }, { "DayNarrows", new String[] { "\u039a", @@ -176,6 +249,23 @@ "\u03a3", } }, + { "standalone.DayNarrows", + new String[] { + "\u039a", + "\u0394", + "\u03a4", + "\u03a4", + "\u03a0", + "\u03a0", + "\u03a3", + } + }, + { "short.Eras", + new String[] { + "\u03c0.\u03a7.", + "\u03bc.\u03a7.", + } + }, { "AmPmMarkers", new String[] { "\u03c0\u03bc", // am marker @@ -219,58 +309,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/yy", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM, y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.islamicc", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.islamic", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.japanese", "\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.gregorian", "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.gregory", "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.roc", "\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2" }, - { "calendarname.buddhist", "\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "field.era", "\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2" }, - { "field.year", "\u0388\u03c4\u03bf\u03c2" }, - { "field.month", "\u039c\u03ae\u03bd\u03b1\u03c2" }, - { "field.week", "\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1" }, - { "field.weekday", "\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2" }, - { "field.dayperiod", "\u03c0.\u03bc./\u03bc.\u03bc." }, - { "field.hour", "\u038f\u03c1\u03b1" }, - { "field.minute", "\u039b\u03b5\u03c0\u03c4\u03cc" }, - { "field.second", "\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf" }, - { "field.zone", "\u0396\u03ce\u03bd\u03b7" }, }; } } --- old/src/share/classes/sun/text/resources/el/FormatData_el_CY.java 2013-04-11 23:16:14.000000000 -0700 +++ new/src/share/classes/sun/text/resources/el/FormatData_el_CY.java 2013-04-11 23:16:13.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el_CY extends ListResourceBundle { +public class FormatData_el_CY extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", --- old/src/share/classes/sun/text/resources/el/FormatData_el_GR.java 2013-04-11 23:16:14.000000000 -0700 +++ new/src/share/classes/sun/text/resources/el/FormatData_el_GR.java 2013-04-11 23:16:14.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el_GR extends ListResourceBundle { +public class FormatData_el_GR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en.java 2013-04-11 23:16:15.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en.java 2013-04-11 23:16:15.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en extends ListResourceBundle { +public class FormatData_en extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { // This locale inherits almost everything from the root default locale. However, --- old/src/share/classes/sun/text/resources/en/FormatData_en_AU.java 2013-04-11 23:16:15.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_AU.java 2013-04-11 23:16:15.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_AU extends ListResourceBundle { +public class FormatData_en_AU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_CA.java 2013-04-11 23:16:16.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_CA.java 2013-04-11 23:16:16.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_CA extends ListResourceBundle { +public class FormatData_en_CA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_GB.java 2013-04-11 23:16:17.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_GB.java 2013-04-11 23:16:16.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_GB extends ListResourceBundle { +public class FormatData_en_GB extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_IE.java 2013-04-11 23:16:17.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_IE.java 2013-04-11 23:16:17.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_IE extends ListResourceBundle { +public class FormatData_en_IE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_IN.java 2013-04-11 23:16:18.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_IN.java 2013-04-11 23:16:17.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -31,16 +31,16 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; /** * The locale elements for English in India. * */ -public class FormatData_en_IN extends ListResourceBundle { +public class FormatData_en_IN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_MT.java 2013-04-11 23:16:18.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_MT.java 2013-04-11 23:16:18.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_MT extends ListResourceBundle { +public class FormatData_en_MT extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java 2013-04-11 23:16:19.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java 2013-04-11 23:16:19.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_NZ extends ListResourceBundle { +public class FormatData_en_NZ extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_PH.java 2013-04-11 23:16:19.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_PH.java 2013-04-11 23:16:19.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_PH extends ListResourceBundle { +public class FormatData_en_PH extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/en/FormatData_en_SG.java 2013-04-11 23:16:20.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_SG.java 2013-04-11 23:16:20.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_SG extends ListResourceBundle { +public class FormatData_en_SG extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/en/FormatData_en_US.java 2013-04-11 23:16:21.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_US.java 2013-04-11 23:16:20.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_US extends ListResourceBundle { +public class FormatData_en_US extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java 2013-04-11 23:16:21.000000000 -0700 +++ new/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java 2013-04-11 23:16:21.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_ZA extends ListResourceBundle { +public class FormatData_en_ZA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es.java 2013-04-11 23:16:22.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es.java 2013-04-11 23:16:21.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es extends ListResourceBundle { +public class FormatData_es extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "E", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "domingo", // Sunday @@ -151,6 +168,18 @@ "S", } }, + { "Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "short.Eras", + new String[] { + "a.C.", + "d.C.", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -195,72 +224,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/y GGGG", - "dd/MM/y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "calendario civil isl\u00e1mico" }, - { "calendarname.islamicc", "calendario civil isl\u00e1mico" }, - { "calendarname.islamic", "calendario isl\u00e1mico" }, - { "calendarname.japanese", "calendario japon\u00e9s" }, - { "calendarname.gregorian", "calendario gregoriano" }, - { "calendarname.gregory", "calendario gregoriano" }, - { "calendarname.roc", "calendario de la Rep\u00fablica de China" }, - { "calendarname.buddhist", "calendario budista" }, - { "field.era", "era" }, - { "field.year", "a\u00f1o" }, - { "field.month", "mes" }, - { "field.week", "semana" }, - { "field.weekday", "d\u00eda de la semana" }, - { "field.dayperiod", "periodo del d\u00eda" }, - { "field.hour", "hora" }, - { "field.minute", "minuto" }, - { "field.second", "segundo" }, - { "field.zone", "zona" }, }; } } --- old/src/share/classes/sun/text/resources/es/FormatData_es_AR.java 2013-04-11 23:16:22.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_AR.java 2013-04-11 23:16:22.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_AR extends ListResourceBundle { +public class FormatData_es_AR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_BO.java 2013-04-11 23:16:23.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_BO.java 2013-04-11 23:16:22.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_BO extends ListResourceBundle { +public class FormatData_es_BO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_CL.java 2013-04-11 23:16:23.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_CL.java 2013-04-11 23:16:23.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CL extends ListResourceBundle { +public class FormatData_es_CL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_CO.java 2013-04-11 23:16:24.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_CO.java 2013-04-11 23:16:24.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CO extends ListResourceBundle { +public class FormatData_es_CO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_CR.java 2013-04-11 23:16:24.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_CR.java 2013-04-11 23:16:24.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CR extends ListResourceBundle { +public class FormatData_es_CR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_DO.java 2013-04-11 23:16:25.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_DO.java 2013-04-11 23:16:25.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_DO extends ListResourceBundle { +public class FormatData_es_DO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_EC.java 2013-04-11 23:16:25.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_EC.java 2013-04-11 23:16:25.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_EC extends ListResourceBundle { +public class FormatData_es_EC extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_ES.java 2013-04-11 23:16:26.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_ES.java 2013-04-11 23:16:26.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_ES extends ListResourceBundle { +public class FormatData_es_ES extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_GT.java 2013-04-11 23:16:27.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_GT.java 2013-04-11 23:16:26.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_GT extends ListResourceBundle { +public class FormatData_es_GT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_HN.java 2013-04-11 23:16:27.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_HN.java 2013-04-11 23:16:27.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_HN extends ListResourceBundle { +public class FormatData_es_HN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_MX.java 2013-04-11 23:16:28.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_MX.java 2013-04-11 23:16:27.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_MX extends ListResourceBundle { +public class FormatData_es_MX extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_NI.java 2013-04-11 23:16:28.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_NI.java 2013-04-11 23:16:28.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_NI extends ListResourceBundle { +public class FormatData_es_NI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_PA.java 2013-04-11 23:16:29.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_PA.java 2013-04-11 23:16:28.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PA extends ListResourceBundle { +public class FormatData_es_PA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_PE.java 2013-04-11 23:16:29.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_PE.java 2013-04-11 23:16:29.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PE extends ListResourceBundle { +public class FormatData_es_PE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_PR.java 2013-04-11 23:16:30.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_PR.java 2013-04-11 23:16:30.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PR extends ListResourceBundle { +public class FormatData_es_PR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_PY.java 2013-04-11 23:16:30.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_PY.java 2013-04-11 23:16:30.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PY extends ListResourceBundle { +public class FormatData_es_PY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_SV.java 2013-04-11 23:16:31.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_SV.java 2013-04-11 23:16:31.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_SV extends ListResourceBundle { +public class FormatData_es_SV extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_US.java 2013-04-11 23:16:31.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_US.java 2013-04-11 23:16:31.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_US extends ListResourceBundle { +public class FormatData_es_US extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "AmPmMarkers", --- old/src/share/classes/sun/text/resources/es/FormatData_es_UY.java 2013-04-11 23:16:32.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_UY.java 2013-04-11 23:16:32.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_UY extends ListResourceBundle { +public class FormatData_es_UY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/es/FormatData_es_VE.java 2013-04-11 23:16:33.000000000 -0700 +++ new/src/share/classes/sun/text/resources/es/FormatData_es_VE.java 2013-04-11 23:16:32.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_VE extends ListResourceBundle { +public class FormatData_es_VE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/et/FormatData_et.java 2013-04-11 23:16:33.000000000 -0700 +++ new/src/share/classes/sun/text/resources/et/FormatData_et.java 2013-04-11 23:16:33.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.et; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_et extends ListResourceBundle { +public class FormatData_et extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "V", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "p\u00fchap\u00e4ev", // Sunday @@ -157,6 +174,12 @@ "m.a.j." } }, + { "short.Eras", + new String[] { + "e.m.a.", + "m.a.j.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -193,25 +216,6 @@ "{1} {0}" // date-time pattern } }, - { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "islami ilmalik kalender" }, - { "calendarname.islamicc", "islami ilmalik kalender" }, - { "calendarname.roc", "Hiina Vabariigi kalender" }, - { "calendarname.islamic", "islamikalender" }, - { "calendarname.buddhist", "budistlik kalender" }, - { "calendarname.japanese", "Jaapani kalender" }, - { "calendarname.gregorian", "Gregoriuse kalender" }, - { "calendarname.gregory", "Gregoriuse kalender" }, - { "field.era", "ajastu" }, - { "field.year", "aasta" }, - { "field.month", "kuu" }, - { "field.week", "n\u00e4dal" }, - { "field.weekday", "n\u00e4dalap\u00e4ev" }, - { "field.dayperiod", "enne/p\u00e4rast l\u00f5unat" }, - { "field.hour", "tund" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "v\u00f6\u00f6nd" }, }; } } --- old/src/share/classes/sun/text/resources/et/FormatData_et_EE.java 2013-04-11 23:16:34.000000000 -0700 +++ new/src/share/classes/sun/text/resources/et/FormatData_et_EE.java 2013-04-11 23:16:33.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.et; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_et_EE extends ListResourceBundle { +public class FormatData_et_EE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/fi/FormatData_fi.java 2013-04-11 23:16:34.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fi/FormatData_fi.java 2013-04-11 23:16:34.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.fi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fi extends ListResourceBundle { +public class FormatData_fi extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "T", + "H", + "M", + "H", + "T", + "K", + "H", + "E", + "S", + "L", + "M", + "J", + "", + } + }, { "standalone.MonthNarrows", new String[] { "T", @@ -169,6 +186,24 @@ "", } }, + { "long.Eras", + new String[] { + "ennen Kristuksen syntym\u00e4\u00e4", + "j\u00e4lkeen Kristuksen syntym\u00e4n", + } + }, + { "Eras", + new String[] { + "eKr.", + "jKr.", + } + }, + { "narrow.Eras", + new String[] { + "eK", + "jK", + } + }, { "DayNames", new String[] { "sunnuntai", // Sunday @@ -180,6 +215,17 @@ "lauantai" // Saturday } }, + { "standalone.DayNames", + new String[] { + "sunnuntai", + "maanantai", + "tiistai", + "keskiviikko", + "torstai", + "perjantai", + "lauantai", + } + }, { "DayAbbreviations", new String[] { "su", // abb Sunday @@ -191,6 +237,17 @@ "la" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "su", + "ma", + "ti", + "ke", + "to", + "pe", + "la", + } + }, { "DayNarrows", new String[] { "S", @@ -236,14 +293,6 @@ "H:mm", // short time pattern } }, - { "cldr.DatePatterns", - new String[] { - "cccc, d. MMMM y", - "d. MMMM y", - "d.M.yyyy", - "d.M.yyyy", - } - }, { "DatePatterns", new String[] { "d. MMMM'ta 'yyyy", // full date pattern @@ -270,89 +319,6 @@ "ip.", } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d.M.y GGGG", - "d.M.y GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "muharram", - "safar", - "rabi\u2019 al-awwal", - "rabi\u2019 al-akhir", - "d\u017eumada-l-ula", - "d\u017eumada-l-akhira", - "rad\u017eab", - "\u0161a\u2019ban", - "ramadan", - "\u0161awwal", - "dhu-l-qa\u2019da", - "dhu-l-hidd\u017ea", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d.M.y GGGG", - "d.M.y GGGG", - } - }, - { "calendarname.islamic-civil", "islamilainen siviilikalenteri" }, - { "calendarname.islamicc", "islamilainen siviilikalenteri" }, - { "calendarname.islamic", "islamilainen kalenteri" }, - { "calendarname.japanese", "japanilainen kalenteri" }, - { "calendarname.gregorian", "gregoriaaninen kalenteri" }, - { "calendarname.gregory", "gregoriaaninen kalenteri" }, - { "calendarname.roc", "Kiinan tasavallan kalenteri" }, - { "calendarname.buddhist", "buddhalainen kalenteri" }, - { "field.era", "aikakausi" }, - { "field.year", "vuosi" }, - { "field.month", "kuukausi" }, - { "field.week", "viikko" }, - { "field.weekday", "viikonp\u00e4iv\u00e4" }, - { "field.dayperiod", "vuorokaudenaika" }, - { "field.hour", "tunti" }, - { "field.minute", "minuutti" }, - { "field.second", "sekunti" }, - { "field.zone", "aikavy\u00f6hyke" }, }; } } --- old/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java 2013-04-11 23:16:35.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java 2013-04-11 23:16:35.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fi_FI extends ListResourceBundle { +public class FormatData_fi_FI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/fr/FormatData_fr.java 2013-04-11 23:16:35.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fr/FormatData_fr.java 2013-04-11 23:16:35.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr extends ListResourceBundle { +public class FormatData_fr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb mo month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "dimanche", // Sunday @@ -140,6 +157,17 @@ "sam." // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "dim.", + "lun.", + "mar.", + "mer.", + "jeu.", + "ven.", + "sam.", + } + }, { "DayNarrows", new String[] { "D", @@ -157,6 +185,30 @@ "ap. J.-C." } }, + { "short.Eras", + new String[] { + "av. J.-C.", + "ap. J.-C.", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "buddhist.short.Eras", + new String[] { + "BC", + "\u00e8re b.", + } + }, + { "buddhist.narrow.Eras", + new String[] { + "BC", + "E.B.", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -201,112 +253,6 @@ } }, { "DateTimePatternChars", "GaMjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM, y GGGG", - "d/M/y G", - } - }, - { "islamic.MonthNames", - new String[] { - "Mouharram", - "Safar", - "Rabi\u02bb-oul-Aououal", - "Rabi\u02bb-out-Tani", - "Djoumada-l-Oula", - "Djoumada-t-Tania", - "Radjab", - "Cha\u02bbban", - "Ramadan", - "Chaououal", - "Dou-l-Qa\u02bbda", - "Dou-l-Hidjja", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Mouh.", - "Saf.", - "Rabi\u02bb-oul-A.", - "Rabi\u02bb-out-T.", - "Djoum.-l-O.", - "Djoum.-t-T.", - "Radj.", - "Cha.", - "Ram.", - "Chaou.", - "Dou-l-Q.", - "Dou-l-H.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "AH", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM, y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "Calendrier civil musulman" }, - { "calendarname.islamicc", "Calendrier civil musulman" }, - { "calendarname.islamic", "Calendrier musulman" }, - { "calendarname.japanese", "Calendrier japonais" }, - { "calendarname.gregorian", "Calendrier gr\u00e9gorien" }, - { "calendarname.gregory", "Calendrier gr\u00e9gorien" }, - { "calendarname.roc", "Calendrier r\u00e9publicain chinois" }, - { "calendarname.buddhist", "Calendrier bouddhiste" }, - { "field.era", "\u00e8re" }, - { "field.year", "ann\u00e9e" }, - { "field.month", "mois" }, - { "field.week", "semaine" }, - { "field.weekday", "jour de la semaine" }, - { "field.dayperiod", "cadran" }, - { "field.hour", "heure" }, - { "field.minute", "minute" }, - { "field.second", "seconde" }, - { "field.zone", "fuseau horaire" }, }; } } --- old/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java 2013-04-11 23:16:36.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java 2013-04-11 23:16:36.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_BE extends ListResourceBundle { +public class FormatData_fr_BE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java 2013-04-11 23:16:36.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java 2013-04-11 23:16:36.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_CA extends ListResourceBundle { +public class FormatData_fr_CA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java 2013-04-11 23:16:37.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java 2013-04-11 23:16:37.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_CH extends ListResourceBundle { +public class FormatData_fr_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java 2013-04-11 23:16:38.000000000 -0700 +++ new/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java 2013-04-11 23:16:37.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_FR extends ListResourceBundle { +public class FormatData_fr_FR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ga/FormatData_ga.java 2013-04-11 23:16:38.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ga/FormatData_ga.java 2013-04-11 23:16:38.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ga; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ga extends ListResourceBundle { +public class FormatData_ga extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -81,6 +100,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "E", + "F", + "M", + "A", + "B", + "M", + "I", + "L", + "M", + "D", + "S", + "N", + "", + } + }, { "DayNames", new String[] { "D\u00e9 Domhnaigh", @@ -115,6 +151,12 @@ "AD", } }, + { "short.Eras", + new String[] { + "RC", + "AD", + } + }, { "NumberPatterns", new String[] { "#,##0.###", --- old/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java 2013-04-11 23:16:39.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java 2013-04-11 23:16:39.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ga; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ga_IE extends ListResourceBundle { +public class FormatData_ga_IE extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java 2013-04-11 23:16:39.000000000 -0700 +++ new/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java 2013-04-11 23:16:39.000000000 -0700 @@ -67,15 +67,15 @@ package sun.text.resources.hi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; /** * The locale elements for Hindi. * */ -public class FormatData_hi_IN extends ListResourceBundle { +public class FormatData_hi_IN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -113,6 +113,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u091c", + "\u092b\u093c", + "\u092e\u093e", + "\u0905", + "\u092e", + "\u091c\u0942", + "\u091c\u0941", + "\u0905", + "\u0938\u093f", + "\u0905", + "\u0928", + "\u0926\u093f", + "", + } + }, { "DayNames", new String[] { "\u0930\u0935\u093f\u0935\u093e\u0930", // Sunday @@ -158,6 +175,12 @@ "\u0938\u0928" } }, + { "short.Eras", + new String[] { + "\u0908\u0938\u093e\u092a\u0942\u0930\u094d\u0935", + "\u0938\u0928", + } + }, { "NumberElements", new String[] { ".", // decimal separator @@ -195,24 +218,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.islamicc", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.roc", "\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.islamic", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.buddhist", "\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.japanese", "\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.gregorian", "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.gregory", "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "field.era", "\u092f\u0941\u0917" }, - { "field.year", "\u0935\u0930\u094d\u0937" }, - { "field.month", "\u092e\u093e\u0938" }, - { "field.week", "\u0938\u092a\u094d\u0924\u093e\u0939" }, - { "field.weekday", "\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928" }, - { "field.dayperiod", "\u0938\u092e\u092f \u0905\u0935\u0927\u093f" }, - { "field.hour", "\u0918\u0902\u091f\u093e" }, - { "field.minute", "\u092e\u093f\u0928\u091f" }, - { "field.second", "\u0938\u0947\u0915\u0947\u0902\u0921" }, - { "field.zone", "\u0915\u094d\u0937\u0947\u0924\u094d\u0930" }, }; } } --- old/src/share/classes/sun/text/resources/hr/FormatData_hr.java 2013-04-11 23:16:40.000000000 -0700 +++ new/src/share/classes/sun/text/resources/hr/FormatData_hr.java 2013-04-11 23:16:40.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.hr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hr extends ListResourceBundle { +public class FormatData_hr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -157,6 +157,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + "5.", + "6.", + "7.", + "8.", + "9.", + "10.", + "11.", + "12.", + "", + } + }, { "standalone.MonthNarrows", new String[] { "1.", @@ -185,6 +202,17 @@ "subota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "nedjelja", + "ponedjeljak", + "utorak", + "srijeda", + "\u010detvrtak", + "petak", + "subota", + } + }, { "DayAbbreviations", new String[] { "ned", // abb Sunday @@ -196,6 +224,17 @@ "sub" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ned", + "pon", + "uto", + "sri", + "\u010det", + "pet", + "sub", + } + }, { "DayNarrows", new String[] { "N", @@ -218,6 +257,18 @@ "s", } }, + { "Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "short.Eras", + new String[] { + "p. n. e.", + "A. D.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -255,58 +306,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y.", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y. G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y. G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d. MMMM y. GGGG", - "d. MMMM y. GGGG", - "d. M. y. GGGG", - "d.M.y. GGGG", - } - }, - { "calendarname.islamic-civil", "islamski civilni kalendar" }, - { "calendarname.islamicc", "islamski civilni kalendar" }, - { "calendarname.roc", "kalendar Republike Kine" }, - { "calendarname.islamic", "islamski kalendar" }, - { "calendarname.buddhist", "budisti\u010dki kalendar" }, - { "calendarname.japanese", "japanski kalendar" }, - { "calendarname.gregorian", "gregorijanski kalendar" }, - { "calendarname.gregory", "gregorijanski kalendar" }, - { "field.era", "era" }, - { "field.year", "godina" }, - { "field.month", "mjesec" }, - { "field.week", "tjedan" }, - { "field.weekday", "dan u tjednu" }, - { "field.dayperiod", "dio dana" }, - { "field.hour", "sat" }, - { "field.minute", "minuta" }, - { "field.second", "sekunda" }, - { "field.zone", "zona" }, }; } } --- old/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java 2013-04-11 23:16:40.000000000 -0700 +++ new/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java 2013-04-11 23:16:40.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.hr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hr_HR extends ListResourceBundle { +public class FormatData_hr_HR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/hu/FormatData_hu.java 2013-04-11 23:16:41.000000000 -0700 +++ new/src/share/classes/sun/text/resources/hu/FormatData_hu.java 2013-04-11 23:16:41.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.hu; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hu extends ListResourceBundle { +public class FormatData_hu extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "janu\u00e1r", + "febru\u00e1r", + "m\u00e1rcius", + "\u00e1prilis", + "m\u00e1jus", + "j\u00fanius", + "j\u00falius", + "augusztus", + "szeptember", + "okt\u00f3ber", + "november", + "december", + "", + } + }, { "MonthAbbreviations", new String[] { "jan.", // abb january @@ -118,6 +135,57 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan.", + "febr.", + "m\u00e1rc.", + "\u00e1pr.", + "m\u00e1j.", + "j\u00fan.", + "j\u00fal.", + "aug.", + "szept.", + "okt.", + "nov.", + "dec.", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "\u00c1", + "M", + "J", + "J", + "A", + "Sz", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "\u00c1", + "M", + "J", + "J", + "A", + "Sz", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "vas\u00e1rnap", // Sunday @@ -129,6 +197,17 @@ "szombat" // Saturday } }, + { "standalone.DayNames", + new String[] { + "vas\u00e1rnap", + "h\u00e9tf\u0151", + "kedd", + "szerda", + "cs\u00fct\u00f6rt\u00f6k", + "p\u00e9ntek", + "szombat", + } + }, { "DayAbbreviations", new String[] { "V", // abb Sunday @@ -140,6 +219,17 @@ "Szo" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "V", + "H", + "K", + "Sze", + "Cs", + "P", + "Szo", + } + }, { "DayNarrows", new String[] { "V", @@ -151,6 +241,17 @@ "Sz", } }, + { "standalone.DayNarrows", + new String[] { + "V", + "H", + "K", + "Sz", + "Cs", + "P", + "Sz", + } + }, { "AmPmMarkers", new String[] { "DE", // am marker @@ -163,6 +264,12 @@ "i.u." } }, + { "short.Eras", + new String[] { + "i. e.", + "i. sz.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -200,47 +307,18 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", + { "buddhist.Eras", new String[] { - "Moharrem", - "Safar", - "R\u00e9bi el avvel", - "R\u00e9bi el accher", - "Dsem\u00e1di el avvel", - "Dsem\u00e1di el accher", - "Redseb", - "Sab\u00e1n", - "Ramad\u00e1n", - "Sevv\u00e1l", - "Ds\u00fcl kade", - "Ds\u00fcl hedse", - "", + "BC", + "BK", } }, - { "islamic.Eras", + { "buddhist.short.Eras", new String[] { - "", - "MF", + "BC", + "BK", } }, - { "calendarname.islamic-civil", "iszl\u00e1m civil napt\u00e1r" }, - { "calendarname.islamicc", "iszl\u00e1m civil napt\u00e1r" }, - { "calendarname.islamic", "iszl\u00e1m napt\u00e1r" }, - { "calendarname.japanese", "jap\u00e1n napt\u00e1r" }, - { "calendarname.gregorian", "Gergely-napt\u00e1r" }, - { "calendarname.gregory", "Gergely-napt\u00e1r" }, - { "calendarname.roc", "K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r" }, - { "calendarname.buddhist", "buddhista napt\u00e1r" }, - { "field.era", "\u00e9ra" }, - { "field.year", "\u00e9v" }, - { "field.month", "h\u00f3nap" }, - { "field.week", "h\u00e9t" }, - { "field.weekday", "h\u00e9t napja" }, - { "field.dayperiod", "napszak" }, - { "field.hour", "\u00f3ra" }, - { "field.minute", "perc" }, - { "field.second", "m\u00e1sodperc" }, - { "field.zone", "z\u00f3na" }, }; } } --- old/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java 2013-04-11 23:16:42.000000000 -0700 +++ new/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java 2013-04-11 23:16:41.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.hu; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hu_HU extends ListResourceBundle { +public class FormatData_hu_HU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/in/FormatData_in.java 2013-04-11 23:16:42.000000000 -0700 +++ new/src/share/classes/sun/text/resources/in/FormatData_in.java 2013-04-11 23:16:42.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.in; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in extends ListResourceBundle { +public class FormatData_in extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", --- old/src/share/classes/sun/text/resources/in/FormatData_in_ID.java 2013-04-11 23:16:43.000000000 -0700 +++ new/src/share/classes/sun/text/resources/in/FormatData_in_ID.java 2013-04-11 23:16:42.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.in; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in_ID extends ListResourceBundle { +public class FormatData_in_ID extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "TimePatterns", --- old/src/share/classes/sun/text/resources/is/FormatData_is.java 2013-04-11 23:16:43.000000000 -0700 +++ new/src/share/classes/sun/text/resources/is/FormatData_is.java 2013-04-11 23:16:43.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.is; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_is extends ListResourceBundle { +public class FormatData_is extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "\u00c1", + "L", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "j", @@ -216,13 +233,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u00cdslamskt borgaradagatal" }, - { "calendarname.islamicc", "\u00cdslamskt borgaradagatal" }, - { "calendarname.islamic", "\u00cdslamskt dagatal" }, - { "calendarname.buddhist", "B\u00fadd\u00edskt dagatal" }, - { "calendarname.japanese", "Japanskt dagatal" }, - { "calendarname.gregorian", "Gregor\u00edskt dagatal" }, - { "calendarname.gregory", "Gregor\u00edskt dagatal" }, }; } } --- old/src/share/classes/sun/text/resources/is/FormatData_is_IS.java 2013-04-11 23:16:44.000000000 -0700 +++ new/src/share/classes/sun/text/resources/is/FormatData_is_IS.java 2013-04-11 23:16:44.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.is; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_is_IS extends ListResourceBundle { +public class FormatData_is_IS extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/it/FormatData_it.java 2013-04-11 23:16:44.000000000 -0700 +++ new/src/share/classes/sun/text/resources/it/FormatData_it.java 2013-04-11 23:16:44.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it extends ListResourceBundle { +public class FormatData_it extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,40 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "G", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "G", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "domenica", // Sunday @@ -146,6 +180,17 @@ "sabato" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Domenica", + "Luned\u00ec", + "Marted\u00ec", + "Mercoled\u00ec", + "Gioved\u00ec", + "Venerd\u00ec", + "Sabato", + } + }, { "DayAbbreviations", new String[] { "dom", // abb Sunday @@ -174,6 +219,12 @@ "dopo Cristo" } }, + { "short.Eras", + new String[] { + "aC", + "dC", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -211,71 +262,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "dd MMMM y GGGG", - "dd/MMM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "dd MMMM y GGGG", - "dd/MMM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "calendario civile islamico" }, - { "calendarname.islamicc", "calendario civile islamico" }, - { "calendarname.islamic", "calendario islamico" }, - { "calendarname.buddhist", "calendario buddista" }, - { "calendarname.japanese", "calendario giapponese" }, - { "calendarname.gregorian", "calendario gregoriano" }, - { "calendarname.gregory", "calendario gregoriano" }, - { "field.era", "era" }, - { "field.year", "anno" }, - { "field.month", "mese" }, - { "field.week", "settimana" }, - { "field.weekday", "giorno della settimana" }, - { "field.dayperiod", "periodo del giorno" }, - { "field.hour", "ora" }, - { "field.minute", "minuto" }, - { "field.second", "secondo" }, - { "field.zone", "zona" }, }; } } --- old/src/share/classes/sun/text/resources/it/FormatData_it_CH.java 2013-04-11 23:16:45.000000000 -0700 +++ new/src/share/classes/sun/text/resources/it/FormatData_it_CH.java 2013-04-11 23:16:45.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it_CH extends ListResourceBundle { +public class FormatData_it_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/it/FormatData_it_IT.java 2013-04-11 23:16:45.000000000 -0700 +++ new/src/share/classes/sun/text/resources/it/FormatData_it_IT.java 2013-04-11 23:16:45.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it_IT extends ListResourceBundle { +public class FormatData_it_IT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/iw/FormatData_iw.java 2013-04-11 23:16:46.000000000 -0700 +++ new/src/share/classes/sun/text/resources/iw/FormatData_iw.java 2013-04-11 23:16:46.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.iw; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw extends ListResourceBundle { +public class FormatData_iw extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "DayNames", new String[] { "\u05d9\u05d5\u05dd \u05e8\u05d0\u05e9\u05d5\u05df", // Sunday @@ -185,6 +202,12 @@ "\u05dc\u05e4\u05e1\u05d4\"\u05e0" } }, + { "short.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d4\u05f4\u05e1", + "\u05dc\u05e1\u05d4\u05f4\u05e0", + } + }, { "TimePatterns", new String[] { "HH:mm:ss z", // full time pattern @@ -207,46 +230,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u05de\u05d5\u05d7\u05e8\u05dd", - "\u05e1\u05e4\u05e8", - "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", - "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", - "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", - "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", - "\u05e8\u05d2\u05f3\u05d0\u05d1", - "\u05e9\u05e2\u05d1\u05d0\u05df", - "\u05e8\u05d0\u05de\u05d3\u05df", - "\u05e9\u05d5\u05d5\u05d0\u05dc", - "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", - "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", - } - }, - { "calendarname.islamic-civil", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, - { "calendarname.islamicc", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, - { "calendarname.islamic", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, - { "calendarname.buddhist", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, - { "calendarname.japanese", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, - { "calendarname.gregorian", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, - { "calendarname.gregory", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, - { "field.era", "\u05ea\u05e7\u05d5\u05e4\u05d4" }, - { "field.year", "\u05e9\u05e0\u05d4" }, - { "field.month", "\u05d7\u05d5\u05d3\u05e9" }, - { "field.week", "\u05e9\u05d1\u05d5\u05e2" }, - { "field.weekday", "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, - { "field.dayperiod", "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, - { "field.hour", "\u05e9\u05e2\u05d4" }, - { "field.minute", "\u05d3\u05e7\u05d4" }, - { "field.second", "\u05e9\u05e0\u05d9\u05d9\u05d4" }, - { "field.zone", "\u05d0\u05d6\u05d5\u05e8" }, }; } } --- old/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java 2013-04-11 23:16:47.000000000 -0700 +++ new/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java 2013-04-11 23:16:46.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.iw; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw_IL extends ListResourceBundle { +public class FormatData_iw_IL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ja/FormatData_ja.java 2013-04-11 23:16:47.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ja/FormatData_ja.java 2013-04-11 23:16:47.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.ja; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ja extends ListResourceBundle { +public class FormatData_ja extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -182,16 +182,7 @@ "\u4ecf\u66a6", // Butsureki } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "Gy/MM/dd", - "Gy/MM/dd", - } - }, { "japanese.Eras", japaneseEras }, - { "cldr.japanese.short.Eras", japaneseEras }, { "japanese.FirstYear", new String[] { // first year name "\u5143", // "Gan"-nen @@ -233,14 +224,6 @@ "{1} {0}" // date-time pattern } }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy/MM/dd", - } - }, { "japanese.DatePatterns", new String[] { "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern @@ -263,42 +246,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/MM/dd", - "Gy/MM/dd", - } - }, - { "roc.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "GGGGy/MM/dd", - "GGGGy/MM/dd", - } - }, - { "calendarname.islamic-civil", "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.islamicc", "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.islamic", "\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.japanese", "\u548c\u66a6" }, - { "calendarname.gregorian", "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, - { "calendarname.gregory", "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, - { "calendarname.roc", "\u4e2d\u83ef\u6c11\u56fd\u66a6" }, - { "calendarname.buddhist", "\u30bf\u30a4\u4ecf\u6559\u66a6" }, - { "field.era", "\u6642\u4ee3" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u9031" }, - { "field.weekday", "\u66dc\u65e5" }, - { "field.dayperiod", "\u5348\u524d/\u5348\u5f8c" }, - { "field.hour", "\u6642" }, - { "field.minute", "\u5206" }, - { "field.second", "\u79d2" }, - { "field.zone", "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3" }, }; } } --- old/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java 2013-04-11 23:16:48.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java 2013-04-11 23:16:48.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ja; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ja_JP extends ListResourceBundle { +public class FormatData_ja_JP extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ko/FormatData_ko.java 2013-04-11 23:16:48.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ko/FormatData_ko.java 2013-04-11 23:16:48.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.ko; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ko extends ListResourceBundle { +public class FormatData_ko extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -123,6 +123,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1\uc6d4", + "2\uc6d4", + "3\uc6d4", + "4\uc6d4", + "5\uc6d4", + "6\uc6d4", + "7\uc6d4", + "8\uc6d4", + "9\uc6d4", + "10\uc6d4", + "11\uc6d4", + "12\uc6d4", + "", + } + }, { "DayNames", new String[] { "\uc77c\uc694\uc77c", // Sunday @@ -156,6 +173,27 @@ "\ud1a0", } }, + { "Eras", + new String[] { + "\uae30\uc6d0\uc804", + "\uc11c\uae30", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\ubd88\uae30", + } + }, + { "japanese.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, { "AmPmMarkers", new String[] { "\uc624\uc804", // am marker @@ -183,34 +221,15 @@ "{1} {0}" // date-time pattern } }, - { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", + { "buddhist.DatePatterns", new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", + "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", + "GGGG y\ub144 M\uc6d4 d\uc77c", + "GGGG y. M. d", + "GGGG y. M. d", } }, - { "roc.DatePatterns", + { "japanese.DatePatterns", new String[] { "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", "GGGG y\ub144 M\uc6d4 d\uc77c", @@ -218,24 +237,7 @@ "GGGG y. M. d", } }, - { "calendarname.islamic-civil", "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, - { "calendarname.islamicc", "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, - { "calendarname.islamic", "\uc774\uc2ac\ub78c\ub825" }, - { "calendarname.japanese", "\uc77c\ubcf8\ub825" }, - { "calendarname.gregorian", "\ud0dc\uc591\ub825" }, - { "calendarname.gregory", "\ud0dc\uc591\ub825" }, - { "calendarname.roc", "\ub300\ub9cc\ub825" }, - { "calendarname.buddhist", "\ubd88\uad50\ub825" }, - { "field.era", "\uc5f0\ud638" }, - { "field.year", "\ub144" }, - { "field.month", "\uc6d4" }, - { "field.week", "\uc8fc" }, - { "field.weekday", "\uc694\uc77c" }, - { "field.dayperiod", "\uc624\uc804/\uc624\ud6c4" }, - { "field.hour", "\uc2dc" }, - { "field.minute", "\ubd84" }, - { "field.second", "\ucd08" }, - { "field.zone", "\uc2dc\uac04\ub300" }, + { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, }; } } --- old/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java 2013-04-11 23:16:49.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java 2013-04-11 23:16:49.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ko; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ko_KR extends ListResourceBundle { +public class FormatData_ko_KR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/lt/FormatData_lt.java 2013-04-11 23:16:49.000000000 -0700 +++ new/src/share/classes/sun/text/resources/lt/FormatData_lt.java 2013-04-11 23:16:49.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.lt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lt extends ListResourceBundle { +public class FormatData_lt extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,40 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "Saus.", + "Vas.", + "Kov.", + "Bal.", + "Geg.", + "Bir.", + "Liep.", + "Rugp.", + "Rugs.", + "Spal.", + "Lapkr.", + "Gruod.", + "", + } + }, + { "MonthNarrows", + new String[] { + "S", + "V", + "K", + "B", + "G", + "B", + "L", + "R", + "R", + "S", + "L", + "G", + "", + } + }, { "standalone.MonthNarrows", new String[] { "S", @@ -163,6 +197,17 @@ "\u0160e\u0161tadienis" // Saturday } }, + { "standalone.DayNames", + new String[] { + "sekmadienis", + "pirmadienis", + "antradienis", + "tre\u010diadienis", + "ketvirtadienis", + "penktadienis", + "\u0161e\u0161tadienis", + } + }, { "DayAbbreviations", new String[] { "Sk", // abb Sunday @@ -174,6 +219,17 @@ "\u0160t" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "Sk", + "Pr", + "An", + "Tr", + "Kt", + "Pn", + "\u0160t", + } + }, { "DayNarrows", new String[] { "S", @@ -202,6 +258,12 @@ "po.Kr." } }, + { "short.Eras", + new String[] { + "pr. Kr.", + "po Kr.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -239,32 +301,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "y G, MMMM d, EEEE", - "G y MMMM d", - "G y MMM d", - "GGGGG yyyy-MM-dd", - } - }, - { "calendarname.islamic-civil", "Pilietinis islamo kalendorius" }, - { "calendarname.islamicc", "Pilietinis islamo kalendorius" }, - { "calendarname.islamic", "Islamo kalendorius" }, - { "calendarname.japanese", "Japon\u0173 kalendorius" }, - { "calendarname.gregorian", "Grigaliaus kalendorius" }, - { "calendarname.gregory", "Grigaliaus kalendorius" }, - { "calendarname.roc", "Kinijos Respublikos kalendorius" }, - { "calendarname.buddhist", "Budist\u0173 kalendorius" }, - { "field.era", "era" }, - { "field.year", "metai" }, - { "field.month", "m\u0117nuo" }, - { "field.week", "savait\u0117" }, - { "field.weekday", "savait\u0117s diena" }, - { "field.dayperiod", "dienos metas" }, - { "field.hour", "valanda" }, - { "field.minute", "minut\u0117" }, - { "field.second", "sekund\u0117" }, - { "field.zone", "laiko juosta" }, }; } } --- old/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java 2013-04-11 23:16:50.000000000 -0700 +++ new/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java 2013-04-11 23:16:50.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.lt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lt_LT extends ListResourceBundle { +public class FormatData_lt_LT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/lv/FormatData_lv.java 2013-04-11 23:16:51.000000000 -0700 +++ new/src/share/classes/sun/text/resources/lv/FormatData_lv.java 2013-04-11 23:16:50.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.lv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lv extends ListResourceBundle { +public class FormatData_lv extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "sv\u0113tdiena", // Sunday @@ -211,41 +228,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "muharams", - "safars", - "1. rab\u012b", - "2. rab\u012b", - "1. d\u017eum\u0101d\u0101", - "2. d\u017eum\u0101d\u0101", - "rad\u017eabs", - "\u0161abans", - "ramad\u0101ns", - "\u0161auvals", - "du al-kid\u0101", - "du al-hid\u017e\u0101", - "", - } - }, - { "calendarname.islamic-civil", "isl\u0101ma pilso\u0146u kalend\u0101rs" }, - { "calendarname.islamicc", "isl\u0101ma pilso\u0146u kalend\u0101rs" }, - { "calendarname.islamic", "isl\u0101ma kalend\u0101rs" }, - { "calendarname.japanese", "jap\u0101\u0146u kalend\u0101rs" }, - { "calendarname.gregorian", "Gregora kalend\u0101rs" }, - { "calendarname.gregory", "Gregora kalend\u0101rs" }, - { "calendarname.roc", "\u0136\u012bnas Republikas kalend\u0101rs" }, - { "calendarname.buddhist", "budistu kalend\u0101rs" }, - { "field.era", "\u0113ra" }, - { "field.year", "Gads" }, - { "field.month", "M\u0113nesis" }, - { "field.week", "Ned\u0113\u013ca" }, - { "field.weekday", "Ned\u0113\u013cas diena" }, - { "field.dayperiod", "Dayperiod" }, - { "field.hour", "Stundas" }, - { "field.minute", "Min\u016btes" }, - { "field.second", "Sekundes" }, - { "field.zone", "Josla" }, }; } } --- old/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java 2013-04-11 23:16:51.000000000 -0700 +++ new/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java 2013-04-11 23:16:51.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.lv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lv_LV extends ListResourceBundle { +public class FormatData_lv_LV extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/mk/FormatData_mk.java 2013-04-11 23:16:52.000000000 -0700 +++ new/src/share/classes/sun/text/resources/mk/FormatData_mk.java 2013-04-11 23:16:51.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.mk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mk extends ListResourceBundle { +public class FormatData_mk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0435\u043b\u0430", // Sunday @@ -194,24 +211,6 @@ } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0415\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u041c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u041d\u0435\u0434\u0435\u043b\u0430" }, - { "field.weekday", "\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430" }, - { "field.dayperiod", "\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435" }, - { "field.hour", "\u0427\u0430\u0441" }, - { "field.minute", "\u041c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } --- old/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java 2013-04-11 23:16:52.000000000 -0700 +++ new/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java 2013-04-11 23:16:52.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.mk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mk_MK extends ListResourceBundle { +public class FormatData_mk_MK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ms/FormatData_ms.java 2013-04-11 23:16:53.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ms/FormatData_ms.java 2013-04-11 23:16:53.000000000 -0700 @@ -40,9 +40,9 @@ package sun.text.resources.ms; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ms extends ListResourceBundle { +public class FormatData_ms extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -79,6 +79,40 @@ "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "O", + "S", + "O", + "N", + "D", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "O", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "J", @@ -189,71 +223,6 @@ "{1} {0}", } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM y GGGG", - "d MMMM y GGGG", - "dd/MM/y GGGG", - "d/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y GGGG", - "d MMMM y GGGG", - "dd/MM/y GGGG", - "d/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "Kalendar Sivil Islam" }, - { "calendarname.islamicc", "Kalendar Sivil Islam" }, - { "calendarname.islamic", "Kalendar Islam" }, - { "calendarname.buddhist", "Kalendar Buddha" }, - { "calendarname.japanese", "Kalendar Jepun" }, - { "calendarname.roc", "Kalendar Minguo" }, - { "calendarname.gregorian", "Kalendar Gregory" }, - { "calendarname.gregory", "Kalendar Gregory" }, - { "field.year", "Tahun" }, - { "field.month", "Bulan" }, - { "field.week", "Minggu" }, - { "field.weekday", "Hari dalam Minggu" }, - { "field.dayperiod", "PG/PTG" }, - { "field.hour", "Jam" }, - { "field.minute", "Minit" }, - { "field.second", "Kedua" }, - { "field.zone", "Zon Waktu" }, }; } } --- old/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java 2013-04-11 23:16:53.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java 2013-04-11 23:16:53.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ms; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ms_MY extends ListResourceBundle { +public class FormatData_ms_MY extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/mt/FormatData_mt.java 2013-04-11 23:16:54.000000000 -0700 +++ new/src/share/classes/sun/text/resources/mt/FormatData_mt.java 2013-04-11 23:16:54.000000000 -0700 @@ -40,9 +40,9 @@ package sun.text.resources.mt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mt extends ListResourceBundle { +public class FormatData_mt extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -79,6 +79,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "\u0120", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Il-\u0126add", @@ -167,22 +184,6 @@ "{1} {0}", } }, - { "calendarname.islamic-civil", "Kalendarju Islamiku-\u010aivili" }, - { "calendarname.islamicc", "Kalendarju Islamiku-\u010aivili" }, - { "calendarname.islamic", "Kalendarju Islamiku" }, - { "calendarname.buddhist", "Kalendarju Buddist" }, - { "calendarname.japanese", "Kalendarju \u0120appuni\u017c" }, - { "calendarname.gregorian", "Kalendarju Gregorjan" }, - { "calendarname.gregory", "Kalendarju Gregorjan" }, - { "field.era", "Epoka" }, - { "field.year", "Sena" }, - { "field.month", "Xahar" }, - { "field.week", "\u0120img\u0127a" }, - { "field.weekday", "Jum tal-\u0120img\u0127a" }, - { "field.hour", "Sieg\u0127a" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekonda" }, - { "field.zone", "\u017bona" }, }; } } --- old/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java 2013-04-11 23:16:54.000000000 -0700 +++ new/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java 2013-04-11 23:16:54.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.mt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mt_MT extends ListResourceBundle { +public class FormatData_mt_MT extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", --- old/src/share/classes/sun/text/resources/nl/FormatData_nl.java 2013-04-11 23:16:55.000000000 -0700 +++ new/src/share/classes/sun/text/resources/nl/FormatData_nl.java 2013-04-11 23:16:55.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl extends ListResourceBundle { +public class FormatData_nl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "zondag", // Sunday @@ -194,111 +211,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "dd-MM-yy G", - } - }, - { "islamic.MonthNames", - new String[] { - "Moeharram", - "Safar", - "Rabi\u02bba al awal", - "Rabi\u02bba al thani", - "Joemad\u02bbal awal", - "Joemad\u02bbal thani", - "Rajab", - "Sja\u02bbaban", - "Ramadan", - "Sjawal", - "Doe al ka\u02bbaba", - "Doe al hizja", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Moeh.", - "Saf.", - "Rab. I", - "Rab. II", - "Joem. I", - "Joem. II", - "Raj.", - "Sja.", - "Ram.", - "Sjaw.", - "Doe al k.", - "Doe al h.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "Sa\u02bbna Hizjria", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "dd-MM-yy GGGG", - } - }, - { "calendarname.islamic-civil", "Islamitische kalender (cyclisch)" }, - { "calendarname.islamicc", "Islamitische kalender (cyclisch)" }, - { "calendarname.roc", "Kalender van de Chinese Republiek" }, - { "calendarname.islamic", "Islamitische kalender" }, - { "calendarname.buddhist", "Boeddhistische kalender" }, - { "calendarname.japanese", "Japanse kalender" }, - { "calendarname.gregorian", "Gregoriaanse kalender" }, - { "calendarname.gregory", "Gregoriaanse kalender" }, - { "field.era", "Tijdperk" }, - { "field.year", "Jaar" }, - { "field.month", "Maand" }, - { "field.weekday", "Dag van de week" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Uur" }, - { "field.minute", "Minuut" }, - { "field.second", "Seconde" }, - { "field.zone", "Zone" }, }; } } --- old/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java 2013-04-11 23:16:55.000000000 -0700 +++ new/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java 2013-04-11 23:16:55.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl_BE extends ListResourceBundle { +public class FormatData_nl_BE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java 2013-04-11 23:16:56.000000000 -0700 +++ new/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java 2013-04-11 23:16:56.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl_NL extends ListResourceBundle { +public class FormatData_nl_NL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/no/FormatData_no.java 2013-04-11 23:16:57.000000000 -0700 +++ new/src/share/classes/sun/text/resources/no/FormatData_no.java 2013-04-11 23:16:56.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no extends ListResourceBundle { +public class FormatData_no extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -65,6 +65,23 @@ "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "januar", + "februar", + "mars", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "desember", + "", + } + }, { "MonthAbbreviations", new String[] { "jan", // abb january @@ -82,6 +99,57 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan", + "feb", + "mar", + "apr", + "mai", + "jun", + "jul", + "aug", + "sep", + "okt", + "nov", + "des", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "s\u00f8ndag", // Sunday @@ -93,6 +161,17 @@ "l\u00f8rdag" // Saturday } }, + { "standalone.DayNames", + new String[] { + "s\u00f8ndag", + "mandag", + "tirsdag", + "onsdag", + "torsdag", + "fredag", + "l\u00f8rdag", + } + }, { "DayAbbreviations", new String[] { "s\u00f8", // abb Sunday @@ -104,6 +183,39 @@ "l\u00f8" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "s\u00f8.", + "ma.", + "ti.", + "on.", + "to.", + "fr.", + "l\u00f8.", + } + }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, + { "standalone.DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, { "NumberElements", new String[] { ",", // decimal separator --- old/src/share/classes/sun/text/resources/no/FormatData_no_NO.java 2013-04-11 23:16:57.000000000 -0700 +++ new/src/share/classes/sun/text/resources/no/FormatData_no_NO.java 2013-04-11 23:16:57.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no_NO extends ListResourceBundle { +public class FormatData_no_NO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java 2013-04-11 23:16:58.000000000 -0700 +++ new/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java 2013-04-11 23:16:57.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no_NO_NY extends ListResourceBundle { +public class FormatData_no_NO_NY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/pl/FormatData_pl.java 2013-04-11 23:16:58.000000000 -0700 +++ new/src/share/classes/sun/text/resources/pl/FormatData_pl.java 2013-04-11 23:16:58.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.pl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pl extends ListResourceBundle { +public class FormatData_pl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,57 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "sty", + "lut", + "mar", + "kwi", + "maj", + "cze", + "lip", + "sie", + "wrz", + "pa\u017a", + "lis", + "gru", + "", + } + }, + { "MonthNarrows", + new String[] { + "s", + "l", + "m", + "k", + "m", + "c", + "l", + "s", + "w", + "p", + "l", + "g", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "s", + "l", + "m", + "k", + "m", + "c", + "l", + "s", + "w", + "p", + "l", + "g", + "", + } + }, { "DayNames", new String[] { "niedziela", // Sunday @@ -146,6 +197,17 @@ "sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "niedziela", + "poniedzia\u0142ek", + "wtorek", + "\u015broda", + "czwartek", + "pi\u0105tek", + "sobota", + } + }, { "DayAbbreviations", new String[] { "N", // abb Sunday @@ -157,6 +219,17 @@ "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "niedz.", + "pon.", + "wt.", + "\u015br.", + "czw.", + "pt.", + "sob.", + } + }, { "DayNarrows", new String[] { "N", @@ -168,6 +241,17 @@ "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "W", + "\u015a", + "C", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "p.n.e.", @@ -211,71 +295,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "calendarname.islamic-civil", "kalendarz islamski (metoda obliczeniowa)" }, - { "calendarname.islamicc", "kalendarz islamski (metoda obliczeniowa)" }, - { "calendarname.islamic", "kalendarz islamski (metoda wzrokowa)" }, - { "calendarname.japanese", "kalendarz japo\u0144ski" }, - { "calendarname.gregorian", "kalendarz gregoria\u0144ski" }, - { "calendarname.gregory", "kalendarz gregoria\u0144ski" }, - { "calendarname.roc", "kalendarz Republiki Chi\u0144skiej" }, - { "calendarname.buddhist", "kalendarz buddyjski" }, - { "field.era", "Era" }, - { "field.year", "Rok" }, - { "field.month", "Miesi\u0105c" }, - { "field.week", "Tydzie\u0144" }, - { "field.weekday", "Dzie\u0144 tygodnia" }, - { "field.hour", "Godzina" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "Strefa" }, }; } } --- old/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java 2013-04-11 23:16:59.000000000 -0700 +++ new/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java 2013-04-11 23:16:59.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pl_PL extends ListResourceBundle { +public class FormatData_pl_PL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/pt/FormatData_pt.java 2013-04-11 23:16:59.000000000 -0700 +++ new/src/share/classes/sun/text/resources/pt/FormatData_pt.java 2013-04-11 23:16:59.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt extends ListResourceBundle { +public class FormatData_pt extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Domingo", // Sunday @@ -151,6 +168,18 @@ "S", } }, + { "long.Eras", + new String[] { + "Antes de Cristo", + "Ano do Senhor", + } + }, + { "Eras", + new String[] { + "a.C.", + "d.C.", + } + }, { "NumberElements", new String[] { ",", // decimal al separator @@ -188,64 +217,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "d/M/yy", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/yyyy G", - "d/M/yyyy", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/yyyy GGGG", - "d/M/yyyy", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/yyyy G", - "d/M/yyyy", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/yyyy GGGG", - "d/M/yyyy", - } - }, - { "calendarname.islamic-civil", "Calend\u00e1rio Civil Isl\u00e2mico" }, - { "calendarname.islamicc", "Calend\u00e1rio Civil Isl\u00e2mico" }, - { "calendarname.islamic", "Calend\u00e1rio Isl\u00e2mico" }, - { "calendarname.japanese", "Calend\u00e1rio Japon\u00eas" }, - { "calendarname.gregorian", "Calend\u00e1rio Gregoriano" }, - { "calendarname.gregory", "Calend\u00e1rio Gregoriano" }, - { "calendarname.roc", "Calend\u00e1rio da Rep\u00fablica da China" }, - { "calendarname.buddhist", "Calend\u00e1rio Budista" }, - { "field.era", "Era" }, - { "field.year", "Ano" }, - { "field.month", "M\u00eas" }, - { "field.week", "Semana" }, - { "field.weekday", "Dia da semana" }, - { "field.dayperiod", "Per\u00edodo do dia" }, - { "field.hour", "Hora" }, - { "field.minute", "Minuto" }, - { "field.second", "Segundo" }, - { "field.zone", "Fuso" }, }; } } --- old/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java 2013-04-11 23:17:00.000000000 -0700 +++ new/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java 2013-04-11 23:17:00.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt_BR extends ListResourceBundle { +public class FormatData_pt_BR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java 2013-04-11 23:17:00.000000000 -0700 +++ new/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java 2013-04-11 23:17:00.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt_PT extends ListResourceBundle { +public class FormatData_pt_PT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ro/FormatData_ro.java 2013-04-11 23:17:01.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ro/FormatData_ro.java 2013-04-11 23:17:01.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.ro; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ro extends ListResourceBundle { +public class FormatData_ro extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "ianuarie", + "februarie", + "martie", + "aprilie", + "mai", + "iunie", + "iulie", + "august", + "septembrie", + "octombrie", + "noiembrie", + "decembrie", + "", + } + }, { "MonthAbbreviations", new String[] { "Ian", // abb january @@ -118,6 +135,40 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "ian.", + "feb.", + "mar.", + "apr.", + "mai", + "iun.", + "iul.", + "aug.", + "sept.", + "oct.", + "nov.", + "dec.", + "", + } + }, + { "MonthNarrows", + new String[] { + "I", + "F", + "M", + "A", + "M", + "I", + "I", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "I", @@ -146,6 +197,17 @@ "s\u00e2mb\u0103t\u0103" // Saturday } }, + { "standalone.DayNames", + new String[] { + "duminic\u0103", + "luni", + "mar\u021bi", + "miercuri", + "joi", + "vineri", + "s\u00e2mb\u0103t\u0103", + } + }, { "DayAbbreviations", new String[] { "D", // abb Sunday @@ -157,18 +219,28 @@ "S" // abb Saturday } }, - // commented out DayNarrows because most names are contributed. -// { "DayNarrows", -// new String[] { -// "D", -// "", -// "", -// "", -// "", -// "", -// "", -// } -// }, + { "standalone.DayAbbreviations", + new String[] { + "Du", + "Lu", + "Ma", + "Mi", + "Jo", + "Vi", + "S\u00e2", + } + }, + { "DayNarrows", + new String[] { + "D", + "L", + "M", + "M", + "J", + "V", + "S", + } + }, { "standalone.DayNarrows", new String[] { "D", @@ -223,32 +295,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "d MMMM y G", - "d MMM y G", - "d/M/yyyy", - } - }, - { "calendarname.islamic-civil", "calendar islamic civil" }, - { "calendarname.islamicc", "calendar islamic civil" }, - { "calendarname.roc", "calendar al Republicii Chineze" }, - { "calendarname.islamic", "calendar islamic" }, - { "calendarname.buddhist", "calendar budist" }, - { "calendarname.japanese", "calendar japonez" }, - { "calendarname.gregorian", "calendar gregorian" }, - { "calendarname.gregory", "calendar gregorian" }, - { "field.era", "er\u0103" }, - { "field.year", "an" }, - { "field.month", "lun\u0103" }, - { "field.week", "s\u0103pt\u0103m\u00e2n\u0103" }, - { "field.weekday", "zi a s\u0103pt\u0103m\u00e2nii" }, - { "field.dayperiod", "perioada zilei" }, - { "field.hour", "or\u0103" }, - { "field.minute", "minut" }, - { "field.second", "secund\u0103" }, - { "field.zone", "zon\u0103" }, }; } } --- old/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java 2013-04-11 23:17:02.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java 2013-04-11 23:17:01.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ro; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ro_RO extends ListResourceBundle { +public class FormatData_ro_RO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/ru/FormatData_ru.java 2013-04-11 23:17:02.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ru/FormatData_ru.java 2013-04-11 23:17:02.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.ru; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ru extends ListResourceBundle { +public class FormatData_ru extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,40 @@ "", // month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u042f", + "\u0424", + "\u041c", + "\u0410", + "\u041c", + "\u0418", + "\u0418", + "\u0410", + "\u0421", + "\u041e", + "\u041d", + "\u0414", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "\u042f", + "\u0424", + "\u041c", + "\u0410", + "\u041c", + "\u0418", + "\u0418", + "\u0410", + "\u0421", + "\u041e", + "\u041d", + "\u0414", + "", + } + }, { "DayNames", new String[] { "\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435", // Sunday @@ -163,6 +197,17 @@ "\u0441\u0443\u0431\u0431\u043e\u0442\u0430" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435", + "\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a", + "\u0412\u0442\u043e\u0440\u043d\u0438\u043a", + "\u0421\u0440\u0435\u0434\u0430", + "\u0427\u0435\u0442\u0432\u0435\u0440\u0433", + "\u041f\u044f\u0442\u043d\u0438\u0446\u0430", + "\u0421\u0443\u0431\u0431\u043e\u0442\u0430", + } + }, { "DayAbbreviations", new String[] { "\u0412\u0441", // abb Sunday @@ -174,6 +219,17 @@ "\u0421\u0431" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u0412\u0441", + "\u041f\u043d", + "\u0412\u0442", + "\u0421\u0440", + "\u0427\u0442", + "\u041f\u0442", + "\u0421\u0431", + } + }, { "DayNarrows", new String[] { "\u0412", @@ -239,88 +295,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. GGGG", - "d MMMM y\u00a0'\u0433'. GGGG", - "dd.MM.yyyy GGGG", - "dd.MM.yy GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", - "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", - "\u0420\u0430\u0434\u0436\u0430\u0431", - "\u0428\u0430\u0430\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", - "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. GGGG", - "d MMMM y\u00a0'\u0433'. GGGG", - "dd.MM.yyyy GGGG", - "dd.MM.yy GGGG", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.roc", "\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "field.era", "\u042d\u0440\u0430" }, - { "field.year", "\u0413\u043e\u0434" }, - { "field.month", "\u041c\u0435\u0441\u044f\u0446" }, - { "field.week", "\u041d\u0435\u0434\u0435\u043b\u044f" }, - { "field.weekday", "\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438" }, - { "field.hour", "\u0427\u0430\u0441" }, - { "field.minute", "\u041c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441" }, }; } } --- old/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java 2013-04-11 23:17:03.000000000 -0700 +++ new/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java 2013-04-11 23:17:02.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ru; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ru_RU extends ListResourceBundle { +public class FormatData_ru_RU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/sk/FormatData_sk.java 2013-04-11 23:17:03.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sk/FormatData_sk.java 2013-04-11 23:17:03.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.sk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sk extends ListResourceBundle { +public class FormatData_sk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "Nede\u013ea", // Sunday @@ -163,6 +180,17 @@ "Sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "nede\u013ea", + "pondelok", + "utorok", + "streda", + "\u0161tvrtok", + "piatok", + "sobota", + } + }, { "DayAbbreviations", new String[] { "Ne", // abb Sunday @@ -174,6 +202,17 @@ "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ne", + "po", + "ut", + "st", + "\u0161t", + "pi", + "so", + } + }, { "DayNarrows", new String[] { "N", @@ -185,6 +224,17 @@ "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "U", + "S", + "\u0160", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "pred n.l.", @@ -228,23 +278,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, - { "calendarname.islamicc", "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, - { "calendarname.islamic", "Islamsk\u00fd kalend\u00e1r" }, - { "calendarname.buddhist", "Buddhistick\u00fd kalend\u00e1r" }, - { "calendarname.japanese", "Japonsk\u00fd kalend\u00e1r" }, - { "calendarname.gregorian", "Gregori\u00e1nsky kalend\u00e1r" }, - { "calendarname.gregory", "Gregori\u00e1nsky kalend\u00e1r" }, - { "field.era", "\u00c9ra" }, - { "field.year", "Rok" }, - { "field.month", "Mesiac" }, - { "field.week", "T\u00fd\u017ede\u0148" }, - { "field.weekday", "De\u0148 v t\u00fd\u017edni" }, - { "field.dayperiod", "\u010cas\u0165 d\u0148a" }, - { "field.hour", "Hodina" }, - { "field.minute", "Min\u00fata" }, - { "field.second", "Sekunda" }, - { "field.zone", "P\u00e1smo" }, }; } } --- old/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java 2013-04-11 23:17:04.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java 2013-04-11 23:17:04.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sk_SK extends ListResourceBundle { +public class FormatData_sk_SK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/sl/FormatData_sl.java 2013-04-11 23:17:04.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sl/FormatData_sl.java 2013-04-11 23:17:04.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.sl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sl extends ListResourceBundle { +public class FormatData_sl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "Nedelja", // Sunday @@ -157,6 +174,17 @@ "Sob" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ned", + "pon", + "tor", + "sre", + "\u010det", + "pet", + "sob", + } + }, { "DayNarrows", new String[] { "n", @@ -211,24 +239,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "islamski civilni koledar" }, - { "calendarname.islamicc", "islamski civilni koledar" }, - { "calendarname.roc", "kitajski dr\u017eavni koledar" }, - { "calendarname.islamic", "islamski koledar" }, - { "calendarname.buddhist", "budisti\u010dni koledar" }, - { "calendarname.japanese", "japonski koledar" }, - { "calendarname.gregorian", "gregorijanski koledar" }, - { "calendarname.gregory", "gregorijanski koledar" }, - { "field.era", "Doba" }, - { "field.year", "Leto" }, - { "field.month", "Mesec" }, - { "field.week", "Teden" }, - { "field.weekday", "Dan v tednu" }, - { "field.dayperiod", "\u010cas dneva" }, - { "field.hour", "Ura" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "Obmo\u010dje" }, }; } } --- old/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java 2013-04-11 23:17:05.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java 2013-04-11 23:17:05.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sl_SI extends ListResourceBundle { +public class FormatData_sl_SI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/sq/FormatData_sq.java 2013-04-11 23:17:06.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sq/FormatData_sq.java 2013-04-11 23:17:05.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sq; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sq extends ListResourceBundle { +public class FormatData_sq extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -82,6 +82,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "S", + "M", + "P", + "M", + "Q", + "K", + "G", + "S", + "T", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "e diel", // Sunday --- old/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java 2013-04-11 23:17:06.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java 2013-04-11 23:17:06.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sq; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sq_AL extends ListResourceBundle { +public class FormatData_sq_AL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/sr/FormatData_sr.java 2013-04-11 23:17:07.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr.java 2013-04-11 23:17:06.000000000 -0700 @@ -40,9 +40,9 @@ package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr extends ListResourceBundle { +public class FormatData_sr extends ParallelListResourceBundle { @Override protected final Object[][] getContents() { final String[] rocEras = { @@ -84,6 +84,40 @@ "", } }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0435\u0459\u0430", @@ -179,57 +213,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, MMMM d, y G", - "MMMM d, y G", - "MMM d, y G", - "M/d/yy G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0440\u0430\u0445\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0438\u02bb I", - "\u0420\u0430\u0431\u0438\u02bb II", - "\u0408\u0443\u043c\u0430\u0434\u0430 I", - "\u0408\u0443\u043c\u0430\u0434\u0430 II", - "\u0420\u0430\u0452\u0430\u0431", - "\u0428\u0430\u02bb\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0428\u0430\u0432\u0430\u043b", - "\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430", - "\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0410\u0425", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0435\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u043c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u043d\u0435\u0434\u0435\u0459\u0430" }, - { "field.weekday", "\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438" }, - { "field.dayperiod", "\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435" }, - { "field.hour", "\u0447\u0430\u0441" }, - { "field.minute", "\u043c\u0438\u043d\u0443\u0442" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java 2013-04-11 23:17:07.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java 2013-04-11 23:17:07.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_BA extends ListResourceBundle { +public class FormatData_sr_BA extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java 2013-04-11 23:17:08.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java 2013-04-11 23:17:08.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_CS extends ListResourceBundle { +public class FormatData_sr_CS extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java 2013-04-11 23:17:08.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java 2013-04-11 23:17:08.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -61,12 +61,11 @@ * written authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_Latn extends ListResourceBundle { +public class FormatData_sr_Latn extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -103,6 +102,23 @@ "", } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "nedelja", @@ -125,6 +141,17 @@ "sub", } }, + { "DayNarrows", + new String[] { + "n", + "p", + "u", + "s", + "\u010d", + "p", + "s", + } + }, { "Eras", new String[] { "p. n. e.", --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java 2013-04-11 23:17:09.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java 2013-04-11 23:17:09.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -61,12 +61,11 @@ * written authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_Latn_ME extends ListResourceBundle { +public class FormatData_sr_Latn_ME extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "TimePatterns", --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java 2013-04-11 23:17:09.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java 2013-04-11 23:17:09.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_ME extends ListResourceBundle { +public class FormatData_sr_ME extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; --- old/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java 2013-04-11 23:17:10.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java 2013-04-11 23:17:10.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_RS extends ListResourceBundle { +public class FormatData_sr_RS extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; --- old/src/share/classes/sun/text/resources/sv/FormatData_sv.java 2013-04-11 23:17:11.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sv/FormatData_sv.java 2013-04-11 23:17:10.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.sv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sv extends ListResourceBundle { +public class FormatData_sv extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -106,6 +106,23 @@ "" // month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "MonthAbbreviations", new String[] { "jan", // abb january @@ -123,6 +140,23 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan", + "feb", + "mar", + "apr", + "maj", + "jun", + "jul", + "aug", + "sep", + "okt", + "nov", + "dec", + "", + } + }, { "standalone.MonthNarrows", new String[] { "J", @@ -162,6 +196,17 @@ "l\u00f6" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "s\u00f6n", + "m\u00e5n", + "tis", + "ons", + "tor", + "fre", + "l\u00f6r", + } + }, { "DayNarrows", new String[] { "S", @@ -173,6 +218,17 @@ "L", } }, + { "standalone.DayNames", + new String[] { + "s\u00f6ndag", + "m\u00e5ndag", + "tisdag", + "onsdag", + "torsdag", + "fredag", + "l\u00f6rdag", + } + }, { "standalone.DayNarrows", new String[] { "S", @@ -184,6 +240,18 @@ "L", } }, + { "Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, { "narrow.Eras", new String[] { "f.Kr.", @@ -239,74 +307,6 @@ } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G yyyy-MM-dd", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "GGGG y-MM-dd", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "GGGG y-MM-dd", - } - }, - { "calendarname.islamic-civil", "islamisk civil kalender" }, - { "calendarname.islamicc", "islamisk civil kalender" }, - { "calendarname.islamic", "islamisk kalender" }, - { "calendarname.japanese", "japansk kalender" }, - { "calendarname.gregorian", "gregoriansk kalender" }, - { "calendarname.gregory", "gregoriansk kalender" }, - { "calendarname.roc", "kinesiska republikens kalender" }, - { "calendarname.buddhist", "buddistisk kalender" }, - { "field.era", "era" }, - { "field.year", "\u00e5r" }, - { "field.month", "m\u00e5nad" }, - { "field.week", "vecka" }, - { "field.weekday", "veckodag" }, - { "field.dayperiod", "fm/em" }, - { "field.hour", "timme" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "tidszon" }, }; } } --- old/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java 2013-04-11 23:17:11.000000000 -0700 +++ new/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java 2013-04-11 23:17:11.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sv_SE extends ListResourceBundle { +public class FormatData_sv_SE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/th/FormatData_th.java 2013-04-11 23:17:12.000000000 -0700 +++ new/src/share/classes/sun/text/resources/th/FormatData_th.java 2013-04-11 23:17:11.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.th; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_th extends ListResourceBundle { +public class FormatData_th extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { String[] timePatterns = new String[] { @@ -135,6 +135,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0e21.\u0e04.", + "\u0e01.\u0e1e.", + "\u0e21\u0e35.\u0e04.", + "\u0e40\u0e21.\u0e22.", + "\u0e1e.\u0e04.", + "\u0e21\u0e34.\u0e22", + "\u0e01.\u0e04.", + "\u0e2a.\u0e04.", + "\u0e01.\u0e22.", + "\u0e15.\u0e04.", + "\u0e1e.\u0e22.", + "\u0e18.\u0e04.", + "", + } + }, { "standalone.MonthNarrows", new String[] { "\u0e21.\u0e04.", @@ -209,23 +226,39 @@ "\u0e04.\u0e28." } }, + { "short.Eras", + new String[] { + "\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28.", + "\u0e04.\u0e28.", + } + }, { "narrow.Eras", new String[] { "\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28.", "\u0e04.\u0e28.", } }, - { "buddhist.TimePatterns", - timePatterns + { "japanese.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } }, - { "cldr.buddhist.DatePatterns", + { "japanese.short.Eras", new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM G y", - "d MMMM y", - "d MMM y", - "d/M/yyyy", + "\u0e04.\u0e28.", + "\u0e21", + "\u0e17", + "\u0e0a", + "\u0e2e", } }, + { "buddhist.TimePatterns", + timePatterns + }, { "buddhist.DatePatterns", datePatterns }, @@ -242,77 +275,6 @@ dateTimePatterns }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35G y", - "d MMM G y", - "d/M/yy", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35G y", - "d MMM G y", - "d/M/yy", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35GGGG y", - "d MMM GGGG y", - "d/M/yy", - } - }, - { "islamic.MonthNames", - new String[] { - "\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21", - "\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c", - "\u0e23\u0e2d\u0e1a\u0e35 I", - "\u0e23\u0e2d\u0e1a\u0e35 II", - "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I", - "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II", - "\u0e23\u0e2d\u0e08\u0e31\u0e1a", - "\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19", - "\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19", - "\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25", - "\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c", - "\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c", - "", - } - }, - { "islamic.long.Eras", - new String[] { - "", - "\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0e2e.\u0e28.", - } - }, - { "calendarname.islamic-civil", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, - { "calendarname.islamicc", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, - { "calendarname.islamic", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21" }, - { "calendarname.japanese", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, - { "calendarname.gregorian", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, - { "calendarname.gregory", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, - { "calendarname.roc", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19" }, - { "calendarname.buddhist", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, - { "field.era", "\u0e2a\u0e21\u0e31\u0e22" }, - { "field.year", "\u0e1b\u0e35" }, - { "field.month", "\u0e40\u0e14\u0e37\u0e2d\u0e19" }, - { "field.week", "\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, - { "field.weekday", "\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, - { "field.dayperiod", "\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19" }, - { "field.hour", "\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07" }, - { "field.minute", "\u0e19\u0e32\u0e17\u0e35" }, - { "field.second", "\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35" }, - { "field.zone", "\u0e40\u0e02\u0e15" }, }; } } --- old/src/share/classes/sun/text/resources/th/FormatData_th_TH.java 2013-04-11 23:17:12.000000000 -0700 +++ new/src/share/classes/sun/text/resources/th/FormatData_th_TH.java 2013-04-11 23:17:12.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.th; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_th_TH extends ListResourceBundle { +public class FormatData_th_TH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/tr/FormatData_tr.java 2013-04-11 23:17:13.000000000 -0700 +++ new/src/share/classes/sun/text/resources/tr/FormatData_tr.java 2013-04-11 23:17:13.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.tr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_tr extends ListResourceBundle { +public class FormatData_tr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "Ocak", + "\u015eubat", + "Mart", + "Nisan", + "May\u0131s", + "Haziran", + "Temmuz", + "A\u011fustos", + "Eyl\u00fcl", + "Ekim", + "Kas\u0131m", + "Aral\u0131k", + "", + } + }, { "MonthAbbreviations", new String[] { "Oca", // abb january @@ -118,6 +135,40 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "Oca", + "\u015eub", + "Mar", + "Nis", + "May", + "Haz", + "Tem", + "A\u011fu", + "Eyl", + "Eki", + "Kas", + "Ara", + "", + } + }, + { "MonthNarrows", + new String[] { + "O", + "\u015e", + "M", + "N", + "M", + "H", + "T", + "A", + "E", + "E", + "K", + "A", + "", + } + }, { "standalone.MonthNarrows", new String[] { "O", @@ -146,6 +197,17 @@ "Cumartesi" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Pazar", + "Pazartesi", + "Sal\u0131", + "\u00c7ar\u015famba", + "Per\u015fembe", + "Cuma", + "Cumartesi", + } + }, { "DayAbbreviations", new String[] { "Paz", // abb Sunday @@ -157,6 +219,17 @@ "Cmt" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "Paz", + "Pzt", + "Sal", + "\u00c7ar", + "Per", + "Cum", + "Cmt", + } + }, { "DayNarrows", new String[] { "P", @@ -168,6 +241,29 @@ "C", } }, + { "standalone.DayNarrows", + new String[] { + "P", + "P", + "S", + "\u00c7", + "P", + "C", + "C", + } + }, + { "long.Eras", + new String[] { + "Milattan \u00d6nce", + "Milattan Sonra", + } + }, + { "Eras", + new String[] { + "M\u00d6", + "MS", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -212,89 +308,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "roc.DatePatterns", - new String[] { - "dd MMMM y GGGG EEEE", - "dd MMMM y GGGG", - "dd MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "Muharrem", - "Safer", - "Rebi\u00fclevvel", - "Rebi\u00fclahir", - "Cemaziyelevvel", - "Cemaziyelahir", - "Recep", - "\u015eaban", - "Ramazan", - "\u015eevval", - "Zilkade", - "Zilhicce", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "dd MMMM y GGGG EEEE", - "dd MMMM y GGGG", - "dd MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "calendarname.islamic-civil", "Arap Takvimi" }, - { "calendarname.islamicc", "Arap Takvimi" }, - { "calendarname.islamic", "Hicri Takvim" }, - { "calendarname.japanese", "Japon Takvimi" }, - { "calendarname.gregorian", "Miladi Takvim" }, - { "calendarname.gregory", "Miladi Takvim" }, - { "calendarname.roc", "\u00c7in Cumhuriyeti Takvimi" }, - { "calendarname.buddhist", "Budist Takvimi" }, - { "field.era", "Miladi D\u00f6nem" }, - { "field.year", "Y\u0131l" }, - { "field.month", "Ay" }, - { "field.week", "Hafta" }, - { "field.weekday", "Haftan\u0131n G\u00fcn\u00fc" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Saat" }, - { "field.minute", "Dakika" }, - { "field.second", "Saniye" }, - { "field.zone", "Saat Dilimi" }, }; } } --- old/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java 2013-04-11 23:17:13.000000000 -0700 +++ new/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java 2013-04-11 23:17:13.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.tr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_tr_TR extends ListResourceBundle { +public class FormatData_tr_TR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/uk/FormatData_uk.java 2013-04-11 23:17:14.000000000 -0700 +++ new/src/share/classes/sun/text/resources/uk/FormatData_uk.java 2013-04-11 23:17:14.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.uk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_uk extends ListResourceBundle { +public class FormatData_uk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0421", + "\u041b", + "\u0411", + "\u041a", + "\u0422", + "\u0427", + "\u041b", + "\u0421", + "\u0412", + "\u0416", + "\u041b", + "\u0413", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0456\u043b\u044f", // Sunday @@ -228,41 +245,6 @@ } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0456 I", - "\u0420\u0430\u0431\u0456 II", - "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I", - "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II", - "\u0420\u0430\u0434\u0436\u0430\u0431", - "\u0428\u0430\u0430\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0414\u0430\u0432\u0432\u0430\u043b", - "\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430", - "\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430", - "", - } - }, - { "calendarname.islamic-civil", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0415\u0440\u0430" }, - { "field.year", "\u0420\u0456\u043a" }, - { "field.month", "\u041c\u0456\u0441\u044f\u0446\u044c" }, - { "field.week", "\u0422\u0438\u0436\u0434\u0435\u043d\u044c" }, - { "field.weekday", "\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f" }, - { "field.dayperiod", "\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438" }, - { "field.hour", "\u0413\u043e\u0434\u0438\u043d\u0430" }, - { "field.minute", "\u0425\u0432\u0438\u043b\u0438\u043d\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0417\u043e\u043d\u0430" }, }; } } --- old/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java 2013-04-11 23:17:15.000000000 -0700 +++ new/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java 2013-04-11 23:17:14.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.uk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_uk_UA extends ListResourceBundle { +public class FormatData_uk_UA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/vi/FormatData_vi.java 2013-04-11 23:17:15.000000000 -0700 +++ new/src/share/classes/sun/text/resources/vi/FormatData_vi.java 2013-04-11 23:17:15.000000000 -0700 @@ -78,11 +78,11 @@ package sun.text.resources.vi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_vi extends ListResourceBundle { +public class FormatData_vi extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -120,6 +120,23 @@ "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "DayNames", new String[] { "Ch\u1ee7 nh\u1eadt", // Sunday @@ -153,6 +170,17 @@ "T7", } }, + { "standalone.DayNarrows", + new String[] { + "CN", + "T2", + "T3", + "T4", + "T5", + "T6", + "T7", + } + }, { "AmPmMarkers", new String[] { "SA", // am marker @@ -201,72 +229,6 @@ "{0} {1}" // date-time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-yyyy G", - "dd/MM/yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", - "dd-MM-y GGGG", - "dd/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", - "dd-MM-y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "L\u1ecbch Islamic-Civil" }, - { "calendarname.islamicc", "L\u1ecbch Islamic-Civil" }, - { "calendarname.islamic", "L\u1ecbch Islamic" }, - { "calendarname.buddhist", "L\u1ecbch Ph\u1eadt Gi\u00e1o" }, - { "calendarname.japanese", "L\u1ecbch Nh\u1eadt B\u1ea3n" }, - { "calendarname.roc", "L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c" }, - { "calendarname.gregorian", "L\u1ecbch Gregory" }, - { "calendarname.gregory", "L\u1ecbch Gregory" }, - { "field.era", "Th\u1eddi \u0111\u1ea1i" }, - { "field.year", "N\u0103m" }, - { "field.month", "Th\u00e1ng" }, - { "field.week", "Tu\u1ea7n" }, - { "field.weekday", "Ng\u00e0y trong tu\u1ea7n" }, - { "field.dayperiod", "SA/CH" }, - { "field.hour", "Gi\u1edd" }, - { "field.minute", "Ph\u00fat" }, - { "field.second", "Gi\u00e2y" }, - { "field.zone", "M\u00fai gi\u1edd" }, }; } } --- old/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java 2013-04-11 23:17:16.000000000 -0700 +++ new/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java 2013-04-11 23:17:15.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -42,11 +42,11 @@ package sun.text.resources.vi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_vi_VN extends ListResourceBundle { +public class FormatData_vi_VN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/zh/FormatData_zh.java 2013-04-11 23:17:16.000000000 -0700 +++ new/src/share/classes/sun/text/resources/zh/FormatData_zh.java 2013-04-11 23:17:16.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh extends ListResourceBundle { +public class FormatData_zh extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -106,6 +106,23 @@ "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "\u4e00\u6708", + "\u4e8c\u6708", + "\u4e09\u6708", + "\u56db\u6708", + "\u4e94\u6708", + "\u516d\u6708", + "\u4e03\u6708", + "\u516b\u6708", + "\u4e5d\u6708", + "\u5341\u6708", + "\u5341\u4e00\u6708", + "\u5341\u4e8c\u6708", + "", + } + }, { "MonthAbbreviations", new String[] { "\u4e00\u6708", // abb january @@ -123,6 +140,40 @@ "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "\u4e00\u6708", + "\u4e8c\u6708", + "\u4e09\u6708", + "\u56db\u6708", + "\u4e94\u6708", + "\u516d\u6708", + "\u4e03\u6708", + "\u516b\u6708", + "\u4e5d\u6708", + "\u5341\u6708", + "\u5341\u4e00\u6708", + "\u5341\u4e8c\u6708", + "", + } + }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "standalone.MonthNarrows", new String[] { "1\u6708", @@ -151,6 +202,17 @@ "\u661f\u671f\u516d" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u661f\u671f\u65e5", + "\u661f\u671f\u4e00", + "\u661f\u671f\u4e8c", + "\u661f\u671f\u4e09", + "\u661f\u671f\u56db", + "\u661f\u671f\u4e94", + "\u661f\u671f\u516d", + } + }, { "DayAbbreviations", new String[] { "\u661f\u671f\u65e5", // abb Sunday @@ -162,6 +224,17 @@ "\u661f\u671f\u516d" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u5468\u65e5", + "\u5468\u4e00", + "\u5468\u4e8c", + "\u5468\u4e09", + "\u5468\u56db", + "\u5468\u4e94", + "\u5468\u516d", + } + }, { "DayNarrows", new String[] { "\u65e5", @@ -173,6 +246,17 @@ "\u516d", } }, + { "standalone.DayNarrows", + new String[] { + "\u65e5", + "\u4e00", + "\u4e8c", + "\u4e09", + "\u56db", + "\u4e94", + "\u516d", + } + }, { "AmPmMarkers", new String[] { "\u4e0a\u5348", // am marker @@ -185,6 +269,21 @@ "\u516c\u5143" } }, + { "buddhist.Eras", + new String[] { + "BC", + "\u4f5b\u5386", + } + }, + { "japanese.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, { "TimePatterns", new String[] { "ahh'\u65f6'mm'\u5206'ss'\u79d2' z", // full time pattern @@ -206,49 +305,15 @@ "{1} {0}" // date-time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gyyyy-M-d", - "Gy-M-d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy-MM-dd", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy-M-d", - "Gy-M-d", - } - }, - { "roc.DatePatterns", + { "buddhist.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", + "GGGGyyyy-M-d", "GGGGy-M-d", - "GGGGy-M-d", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy-MM-dd", } }, - { "islamic.DatePatterns", + { "japanese.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", @@ -256,24 +321,6 @@ "GGGGyy-MM-dd", } }, - { "calendarname.islamic-civil", "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, - { "calendarname.islamicc", "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, - { "calendarname.islamic", "\u4f0a\u65af\u5170\u65e5\u5386" }, - { "calendarname.japanese", "\u65e5\u672c\u65e5\u5386" }, - { "calendarname.gregorian", "\u516c\u5386" }, - { "calendarname.gregory", "\u516c\u5386" }, - { "calendarname.roc", "\u6c11\u56fd\u65e5\u5386" }, - { "calendarname.buddhist", "\u4f5b\u6559\u65e5\u5386" }, - { "field.era", "\u65f6\u671f" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u5468" }, - { "field.weekday", "\u5468\u5929" }, - { "field.dayperiod", "\u4e0a\u5348/\u4e0b\u5348" }, - { "field.hour", "\u5c0f\u65f6" }, - { "field.minute", "\u5206\u949f" }, - { "field.second", "\u79d2\u949f" }, - { "field.zone", "\u533a\u57df" }, }; } } --- old/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java 2013-04-11 23:17:17.000000000 -0700 +++ new/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java 2013-04-11 23:17:17.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,11 +40,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_CN extends ListResourceBundle { +public class FormatData_zh_CN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { --- old/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java 2013-04-11 23:17:17.000000000 -0700 +++ new/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java 2013-04-11 23:17:17.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -40,13 +40,13 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; import java.util.Locale; import java.util.ResourceBundle; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.ResourceBundleBasedAdapter; -public class FormatData_zh_HK extends ListResourceBundle { +public class FormatData_zh_HK extends ParallelListResourceBundle { // reparent to zh_TW for traditional Chinese names public FormatData_zh_HK() { @@ -56,7 +56,7 @@ } /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { --- old/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java 2013-04-11 23:17:18.000000000 -0700 +++ new/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java 2013-04-11 23:17:18.000000000 -0700 @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_SG extends ListResourceBundle { +public class FormatData_zh_SG extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "DayAbbreviations", --- old/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java 2013-04-11 23:17:19.000000000 -0700 +++ new/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java 2013-04-11 23:17:18.000000000 -0700 @@ -76,11 +76,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_TW extends ListResourceBundle { +public class FormatData_zh_TW extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -95,6 +95,40 @@ "\u897f\u5143" } }, + { "standalone.MonthAbbreviations", + new String[] { + "1\u6708", + "2\u6708", + "3\u6708", + "4\u6708", + "5\u6708", + "6\u6708", + "7\u6708", + "8\u6708", + "9\u6708", + "10\u6708", + "11\u6708", + "12\u6708", + "", + } + }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -123,34 +157,7 @@ "{1} {0}" // date-time pattern } }, - { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "roc.DatePatterns", + { "buddhist.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", @@ -158,15 +165,7 @@ "GGGGy/M/d", } }, - { "cldr.islamic.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "islamic.DatePatterns", + { "japanese.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", @@ -174,23 +173,7 @@ "GGGGy/M/d", } }, - { "calendarname.islamic-civil", "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, - { "calendarname.islamicc", "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, - { "calendarname.islamic", "\u4f0a\u65af\u862d\u66c6\u6cd5" }, - { "calendarname.japanese", "\u65e5\u672c\u66c6\u6cd5" }, - { "calendarname.gregorian", "\u516c\u66c6" }, - { "calendarname.gregory", "\u516c\u66c6" }, - { "calendarname.roc", "\u6c11\u570b\u66c6" }, - { "calendarname.buddhist", "\u4f5b\u6559\u66c6\u6cd5" }, - { "field.era", "\u5e74\u4ee3" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u9031" }, - { "field.weekday", "\u9031\u5929" }, - { "field.dayperiod", "\u4e0a\u5348/\u4e0b\u5348" }, - { "field.hour", "\u5c0f\u6642" }, - { "field.minute", "\u5206\u9418" }, - { "field.second", "\u79d2" }, + { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, }; } } --- old/src/share/classes/sun/util/calendar/ZoneInfo.java 2013-04-11 23:17:19.000000000 -0700 +++ new/src/share/classes/sun/util/calendar/ZoneInfo.java 2013-04-11 23:17:19.000000000 -0700 @@ -561,8 +561,7 @@ * @return an array of time zone IDs. */ public static String[] getAvailableIDs() { - Set idSet = ZoneInfoFile.getZoneIds(); - return idSet.toArray(new String[idSet.size()]); + return ZoneInfoFile.getZoneIds(); } /** --- old/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2013-04-11 23:17:20.000000000 -0700 +++ new/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2013-04-11 23:17:20.000000000 -0700 @@ -29,21 +29,13 @@ import java.io.DataInput; import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.StreamCorruptedException; import java.security.AccessController; import java.security.PrivilegedAction; -import java.time.DayOfWeek; import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Month; -import java.time.OffsetDateTime; import java.time.ZoneOffset; -import java.time.zone.ZoneRules; -import java.time.zone.ZoneOffsetTransition; -import java.time.zone.ZoneOffsetTransitionRule; -import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; - import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -58,7 +50,7 @@ import java.util.SimpleTimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.CRC32; -import java.util.zip.ZipFile; +import sun.security.action.GetPropertyAction; /** * Loads TZDB time-zone rules for j.u.TimeZone @@ -72,8 +64,13 @@ * * @return a set of time zone IDs. */ - public static Set getZoneIds() { - return zones.keySet(); + public static String[] getZoneIds() { + String[] ids = Arrays.copyOf(regions, regions.length + oldMappings.length); + int i = regions.length; + for (int j = 0; j < oldMappings.length; j++) { + ids[i++] = oldMappings[j][0]; + } + return ids; } /** @@ -86,8 +83,8 @@ */ public static String[] getZoneIds(int rawOffset) { List ids = new ArrayList<>(); - for (String id : zones.keySet()) { - ZoneInfo zi = getZoneInfo0(id); + for (String id : getZoneIds()) { + ZoneInfo zi = getZoneInfo(id); if (zi.getRawOffset() == rawOffset) { ids.add(id); } @@ -102,17 +99,42 @@ } public static ZoneInfo getZoneInfo(String zoneId) { - if (!zones.containsKey(zoneId)) { + if (zoneId == null) { return null; } - // ZoneInfo is mutable, return the copy - ZoneInfo zi = getZoneInfo0(zoneId); - zi = (ZoneInfo)zi.clone(); - zi.setID(zoneId); + if (zi != null) { + zi = (ZoneInfo)zi.clone(); + zi.setID(zoneId); + } return zi; } + private static ZoneInfo getZoneInfo0(String zoneId) { + try { + ZoneInfo zi = zones.get(zoneId); + if (zi != null) { + return zi; + } + String zid = zoneId; + if (aliases.containsKey(zoneId)) { + zid = aliases.get(zoneId); + } + int index = Arrays.binarySearch(regions, zid); + if (index < 0) { + return null; + } + byte[] bytes = ruleArray[indices[index]]; + DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); + zi = getZoneInfo(dis, zid); + zones.put(zoneId, zi); + return zi; + } catch (Exception ex) { + throw new RuntimeException("Invalid binary time-zone data: TZDB:" + + zoneId + ", version: " + versionId, ex); + } + } + /** * Returns a Map from alias time zone IDs to their standard * time zone IDs. @@ -120,7 +142,7 @@ * @return an unmodified alias mapping */ public static Map getAliasMap() { - return aliases; + return Collections.unmodifiableMap(aliases); } /** @@ -143,23 +165,11 @@ public static ZoneInfo getCustomTimeZone(String originalId, int gmtOffset) { String id = toCustomID(gmtOffset); return new ZoneInfo(id, gmtOffset); -/* - ZoneInfo zi = getFromCache(id); - if (zi == null) { - zi = new ZoneInfo(id, gmtOffset); - zi = addToCache(id, zi); - if (!id.equals(originalId)) { - zi = addToCache(originalId, zi); - } - } - return (ZoneInfo) zi.clone(); -*/ } public static String toCustomID(int gmtOffset) { char sign; int offset = gmtOffset / 60000; - if (offset >= 0) { sign = '+'; } else { @@ -181,49 +191,59 @@ return new String(buf); } - /////////////////////////////////////////////////////////// - - private static ZoneInfo getZoneInfo0(String zoneId) { - try { - - Object obj = zones.get(zoneId); - if (obj instanceof byte[]) { - byte[] bytes = (byte[]) obj; - DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); - obj = getZoneInfo(dis, zoneId); - zones.put(zoneId, obj); - } - return (ZoneInfo)obj; - } catch (Exception ex) { - throw new RuntimeException("Invalid binary time-zone data: TZDB:" + - zoneId + ", version: " + versionId, ex); - } - } - private ZoneInfoFile() { } private static String versionId; - private final static Map zones = new ConcurrentHashMap<>(); + private final static Map zones = new ConcurrentHashMap<>(); private static Map aliases = new HashMap<>(); + private static byte[][] ruleArray; + private static String[] regions; + private static int[] indices; + // Flag for supporting JDK backward compatible IDs, such as "EST". private static final boolean USE_OLDMAPPING; + private static String[][] oldMappings = new String[][] { + { "ACT", "Australia/Darwin" }, + { "AET", "Australia/Sydney" }, + { "AGT", "America/Argentina/Buenos_Aires" }, + { "ART", "Africa/Cairo" }, + { "AST", "America/Anchorage" }, + { "BET", "America/Sao_Paulo" }, + { "BST", "Asia/Dhaka" }, + { "CAT", "Africa/Harare" }, + { "CNT", "America/St_Johns" }, + { "CST", "America/Chicago" }, + { "CTT", "Asia/Shanghai" }, + { "EAT", "Africa/Addis_Ababa" }, + { "ECT", "Europe/Paris" }, + { "IET", "America/Indiana/Indianapolis" }, + { "IST", "Asia/Kolkata" }, + { "JST", "Asia/Tokyo" }, + { "MIT", "Pacific/Apia" }, + { "NET", "Asia/Yerevan" }, + { "NST", "Pacific/Auckland" }, + { "PLT", "Asia/Karachi" }, + { "PNT", "America/Phoenix" }, + { "PRT", "America/Puerto_Rico" }, + { "PST", "America/Los_Angeles" }, + { "SST", "Pacific/Guadalcanal" }, + { "VST", "Asia/Ho_Chi_Minh" }, + }; + static { String oldmapping = AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT); + new GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT); USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true")); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - String libDir = System.getProperty("java.home") + File.separator + "lib"; - File tzdbJar = new File(libDir, "tzdb.jar"); - try (ZipFile zf = new ZipFile(tzdbJar); - DataInputStream dis = new DataInputStream( - zf.getInputStream(zf.getEntry("TZDB.dat")))) { + try (DataInputStream dis = new DataInputStream( + new FileInputStream(new File(libDir, "tzdb.dat")))) { load(dis); } } catch (Exception x) { @@ -234,56 +254,14 @@ }); } - // Must be invoked after loading in all data private static void addOldMapping() { - String[][] oldMappings = new String[][] { - { "ACT", "Australia/Darwin" }, - { "AET", "Australia/Sydney" }, - { "AGT", "America/Argentina/Buenos_Aires" }, - { "ART", "Africa/Cairo" }, - { "AST", "America/Anchorage" }, - { "BET", "America/Sao_Paulo" }, - { "BST", "Asia/Dhaka" }, - { "CAT", "Africa/Harare" }, - { "CNT", "America/St_Johns" }, - { "CST", "America/Chicago" }, - { "CTT", "Asia/Shanghai" }, - { "EAT", "Africa/Addis_Ababa" }, - { "ECT", "Europe/Paris" }, - { "IET", "America/Indiana/Indianapolis" }, - { "IST", "Asia/Kolkata" }, - { "JST", "Asia/Tokyo" }, - { "MIT", "Pacific/Apia" }, - { "NET", "Asia/Yerevan" }, - { "NST", "Pacific/Auckland" }, - { "PLT", "Asia/Karachi" }, - { "PNT", "America/Phoenix" }, - { "PRT", "America/Puerto_Rico" }, - { "PST", "America/Los_Angeles" }, - { "SST", "Pacific/Guadalcanal" }, - { "VST", "Asia/Ho_Chi_Minh" }, - }; for (String[] alias : oldMappings) { - String k = alias[0]; - String v = alias[1]; - if (zones.containsKey(v)) { // make sure we do have the data - aliases.put(k, v); - zones.put(k, zones.get(v)); - } + aliases.put(alias[0], alias[1]); } if (USE_OLDMAPPING) { - if (zones.containsKey("America/New_York")) { - aliases.put("EST", "America/New_York"); - zones.put("EST", zones.get("America/New_York")); - } - if (zones.containsKey("America/Denver")) { - aliases.put("MST", "America/Denver"); - zones.put("MST", zones.get("America/Denver")); - } - if (zones.containsKey("Pacific/Honolulu")) { - aliases.put("HST", "Pacific/Honolulu"); - zones.put("HST", zones.get("Pacific/Honolulu")); - } + aliases.put("EST", "America/New_York"); + aliases.put("MST", "America/Denver"); + aliases.put("HST", "Pacific/Honolulu"); } } @@ -316,7 +294,7 @@ } // rules int ruleCount = dis.readShort(); - Object[] ruleArray = new Object[ruleCount]; + ruleArray = new byte[ruleCount][]; for (int i = 0; i < ruleCount; i++) { byte[] bytes = new byte[dis.readShort()]; dis.readFully(bytes); @@ -325,11 +303,11 @@ // link version-region-rules, only keep the last version, if more than one for (int i = 0; i < versionCount; i++) { regionCount = dis.readShort(); - zones.clear(); + regions = new String[regionCount]; + indices = new int[regionCount]; for (int j = 0; j < regionCount; j++) { - String region = regionArray[dis.readShort()]; - Object rule = ruleArray[dis.readShort() & 0xffff]; - zones.put(region, rule); + regions[j] = regionArray[dis.readShort()]; + indices[j] = dis.readShort(); } } // remove the following ids from the map, they @@ -346,7 +324,6 @@ } // old us time-zone names addOldMapping(); - aliases = Collections.unmodifiableMap(aliases); } /////////////////////////Ser///////////////////////////////// @@ -374,7 +351,7 @@ int ruleSize = in.readByte(); ZoneOffsetTransitionRule[] rules = new ZoneOffsetTransitionRule[ruleSize]; for (int i = 0; i < ruleSize; i++) { - rules[i] = readZOTRule(in); + rules[i] = new ZoneOffsetTransitionRule(in); } return getZoneInfo(zoneId, stdTrans, stdOffsets, savTrans, savOffsets, rules); } @@ -396,31 +373,19 @@ } } - static ZoneOffsetTransitionRule readZOTRule(DataInput in) throws IOException { - int data = in.readInt(); - Month month = Month.of(data >>> 28); - int dom = ((data & (63 << 22)) >>> 22) - 32; - int dowByte = (data & (7 << 19)) >>> 19; - DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte); - int timeByte = (data & (31 << 14)) >>> 14; - TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12]; - int stdByte = (data & (255 << 4)) >>> 4; - int beforeByte = (data & (3 << 2)) >>> 2; - int afterByte = (data & 3); - LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0)); - ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900)); - ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800)); - ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800)); - return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after); - } - /////////////////////////ZoneRules --> ZoneInfo///////////////////////////////// // ZoneInfo starts with UTC1900 private static final long UTC1900 = -2208988800L; + // ZoneInfo ends with UTC2037 - private static final long UTC2037 = - LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; + // LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; + private static final long UTC2037 = 2145916799L; + + // ZoneInfo has an ending entry for 2037, this need to be offset by + // a "rawOffset" + // LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC)); + private static final long LDT2037 = 2114380800L; /* Get a ZoneInfo instance. * @@ -460,15 +425,12 @@ // offsets.length > 16 (4-bit index limit) // last year in trans table // It should not matter to use before or after offset for year - int lastyear = LocalDateTime.ofEpochSecond( - savingsInstantTransitions[savingsInstantTransitions.length - 1], 0, - ZoneOffset.ofTotalSeconds(wallOffsets[savingsInstantTransitions.length - 1])).getYear(); - // int lastyear = savingsLocalTransitions[savingsLocalTransitions.length - 1].getYear(); - + int lastyear = getYear(savingsInstantTransitions[savingsInstantTransitions.length - 1], + wallOffsets[savingsInstantTransitions.length - 1]); int i = 0, k = 1; while (i < savingsInstantTransitions.length && savingsInstantTransitions[i] < UTC1900) { - i++; // skip any date before UTC1900 + i++; // skip any date before UTC1900 } if (i < savingsInstantTransitions.length) { // javazic writes the last GMT offset into index 0! @@ -478,26 +440,27 @@ } // ZoneInfo has a beginning entry for 1900. // Only add it if this is not the only one in table - nOffsets = addTrans(transitions, nTrans++, offsets, nOffsets, + nOffsets = addTrans(transitions, nTrans++, + offsets, nOffsets, UTC1900, wallOffsets[i], getStandardOffset(standardTransitions, standardOffsets, UTC1900)); } + for (; i < savingsInstantTransitions.length; i++) { - //if (savingsLocalTransitions[i * 2].getYear() > LASTYEAR) { - if (savingsInstantTransitions[i] > UTC2037) { + long trans = savingsInstantTransitions[i]; + if (trans > UTC2037) { // no trans beyond LASTYEAR lastyear = LASTYEAR; break; } - long trans = savingsInstantTransitions[i]; while (k < standardTransitions.length) { // some standard offset transitions don't exist in // savingInstantTrans, if the offset "change" doesn't // really change the "effectiveWallOffset". For example // the 1999/2000 pair in Zone Arg/Buenos_Aires, in which // the daylightsaving "happened" but it actually does - // not result in the timezone switch. ZoneInfo however + // not result in the timezone switch. ZoneInfo however // needs them in its transitions table long trans_s = standardTransitions[k]; if (trans_s >= UTC1900) { @@ -514,6 +477,7 @@ trans_s, wallOffsets[i], standardOffsets[k+1]); + } } k++; @@ -528,6 +492,7 @@ trans, wallOffsets[i + 1], getStandardOffset(standardTransitions, standardOffsets, trans)); + } // append any leftover standard trans while (k < standardTransitions.length) { @@ -546,38 +511,35 @@ // fill the gap between the last trans until LASTYEAR while (lastyear++ < LASTYEAR) { for (ZoneOffsetTransitionRule zotr : lastRules) { - ZoneOffsetTransition zot = zotr.createTransition(lastyear); - //long trans = zot.getDateTimeBefore().toEpochSecond(); - long trans = zot.toEpochSecond(); + long trans = zotr.getTransitionEpochSecond(lastyear); if (nOffsets + 2 >= offsets.length) { offsets = Arrays.copyOf(offsets, offsets.length + 100); } if (nTrans + 1 >= transitions.length) { transitions = Arrays.copyOf(transitions, transitions.length + 100); } - nOffsets = addTrans(transitions, nTrans++, offsets, nOffsets, + nOffsets = addTrans(transitions, nTrans++, + offsets, nOffsets, trans, - zot.getOffsetAfter().getTotalSeconds(), - getStandardOffset(standardTransitions, standardOffsets, trans)); + zotr.offsetAfter, + zotr.standardOffset); } } ZoneOffsetTransitionRule startRule = lastRules[lastRules.length - 2]; ZoneOffsetTransitionRule endRule = lastRules[lastRules.length - 1]; params = new int[10]; - if (startRule.getOffsetBefore().compareTo(startRule.getOffsetAfter()) < 0 && - endRule.getOffsetBefore().compareTo(endRule.getOffsetAfter()) > 0) { + if (startRule.offsetAfter - startRule.offsetBefore < 0 && + endRule.offsetAfter - endRule.offsetBefore > 0) { ZoneOffsetTransitionRule tmp; tmp = startRule; startRule = endRule; endRule = tmp; } - params[0] = startRule.getMonth().getValue() - 1; - // params[1] = startRule.getDayOfMonthIndicator(); - // params[2] = toCalendarDOW[startRule.getDayOfWeek().getValue()]; - int dom = startRule.getDayOfMonthIndicator(); - DayOfWeek dow = startRule.getDayOfWeek(); - if (dow == null) { - params[1] = startRule.getDayOfMonthIndicator(); + params[0] = startRule.month - 1; + int dom = startRule.dom; + int dow = startRule.dow; + if (dow == -1) { + params[1] = dom; params[2] = 0; } else { // ZoneRulesBuilder adjusts < 0 case (-1, for last, don't have @@ -590,41 +552,38 @@ // "last", it works for now. if (dom < 0 || dom >= 24) { params[1] = -1; - params[2] = toCalendarDOW[dow.getValue()]; + params[2] = toCalendarDOW[dow]; } else { params[1] = dom; // To specify a day of week on or after an exact day of month, // set the month to an exact month value, day-of-month to the // day on or after which the rule is applied, and day-of-week // to a negative Calendar.DAY_OF_WEEK DAY_OF_WEEK field value. - params[2] = -toCalendarDOW[dow.getValue()]; + params[2] = -toCalendarDOW[dow]; } } - params[3] = startRule.getLocalTime().toSecondOfDay() * 1000; - params[4] = toSTZTime[startRule.getTimeDefinition().ordinal()]; - - params[5] = endRule.getMonth().getValue() - 1; - // params[6] = endRule.getDayOfMonthIndicator(); - // params[7] = toCalendarDOW[endRule.getDayOfWeek().getValue()]; - dom = endRule.getDayOfMonthIndicator(); - dow = endRule.getDayOfWeek(); - if (dow == null) { + params[3] = startRule.secondOfDay * 1000; + params[4] = toSTZTime[startRule.timeDefinition]; + params[5] = endRule.month - 1; + dom = endRule.dom; + dow = endRule.dow; + if (dow == -1) { params[6] = dom; params[7] = 0; } else { // hacking: see comment above if (dom < 0 || dom >= 24) { params[6] = -1; - params[7] = toCalendarDOW[dow.getValue()]; + params[7] = toCalendarDOW[dow]; } else { params[6] = dom; - params[7] = -toCalendarDOW[dow.getValue()]; + params[7] = -toCalendarDOW[dow]; } } - params[8] = endRule.getLocalTime().toSecondOfDay() * 1000; - params[9] = toSTZTime[endRule.getTimeDefinition().ordinal()]; - dstSavings = (startRule.getOffsetAfter().getTotalSeconds() - - startRule.getOffsetBefore().getTotalSeconds()) * 1000; + params[8] = endRule.secondOfDay * 1000; + params[9] = toSTZTime[endRule.timeDefinition]; + dstSavings = (startRule.offsetAfter - startRule.offsetBefore) * 1000; + // Note: known mismatching -> Asia/Amman // ZoneInfo : startDayOfWeek=5 <= Thursday // startTime=86400000 <= 24 hours @@ -638,14 +597,17 @@ } else if (nTrans > 0) { // only do this if there is something in table already if (lastyear < LASTYEAR) { // ZoneInfo has an ending entry for 2037 - long trans = OffsetDateTime.of(LASTYEAR, Month.JANUARY.getValue(), 1, 0, 0, 0, 0, - ZoneOffset.ofTotalSeconds(rawOffset/1000)) - .toEpochSecond(); + //long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0, + // ZoneOffset.ofTotalSeconds(rawOffset/1000)) + // .toEpochSecond(); + long trans = LDT2037 - rawOffset/1000; + int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000); if (offsetIndex == nOffsets) nOffsets++; transitions[nTrans++] = (trans * 1000) << TRANSITION_NSHIFT | (offsetIndex & OFFSET_MASK); + } else if (savingsInstantTransitions.length > 2) { // Workaround: create the params based on the last pair for // zones like Israel and Iran which have trans defined @@ -670,40 +632,28 @@ long endTrans = savingsInstantTransitions[m - 1]; int endOffset = wallOffsets[m - 1 + 1]; int endStd = getStandardOffset(standardTransitions, standardOffsets, endTrans); - if (startOffset > startStd && endOffset == endStd) { - /* - m = savingsLocalTransitions.length; - LocalDateTime startLDT = savingsLocalTransitions[m -4]; //gap - LocalDateTime endLDT = savingsLocalTransitions[m - 1]; //over - */ // last - 1 trans m = savingsInstantTransitions.length - 2; ZoneOffset before = ZoneOffset.ofTotalSeconds(wallOffsets[m]); ZoneOffset after = ZoneOffset.ofTotalSeconds(wallOffsets[m + 1]); - ZoneOffsetTransition trans = ZoneOffsetTransition.of( - LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before), - before, - after); + LocalDateTime ldt = LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before); LocalDateTime startLDT; - if (trans.isGap()) { - startLDT = trans.getDateTimeBefore(); + if (after.getTotalSeconds() > before.getTotalSeconds()) { // isGap() + startLDT = ldt; } else { - startLDT = trans.getDateTimeAfter(); + startLDT = ldt.plusSeconds(wallOffsets[m + 1] - wallOffsets[m]); } // last trans m = savingsInstantTransitions.length - 1; before = ZoneOffset.ofTotalSeconds(wallOffsets[m]); after = ZoneOffset.ofTotalSeconds(wallOffsets[m + 1]); - trans = ZoneOffsetTransition.of( - LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before), - before, - after); + ldt = LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before); LocalDateTime endLDT; - if (trans.isGap()) { - endLDT = trans.getDateTimeAfter(); + if (after.getTotalSeconds() > before.getTotalSeconds()) { // isGap() + endLDT = ldt.plusSeconds(wallOffsets[m + 1] - wallOffsets[m]); } else { - endLDT = trans.getDateTimeBefore(); + endLDT = ldt; } params = new int[10]; params[0] = startLDT.getMonthValue() - 1; @@ -722,14 +672,14 @@ } if (transitions != null && transitions.length != nTrans) { if (nTrans == 0) { - transitions = null; + transitions = null; } else { transitions = Arrays.copyOf(transitions, nTrans); } } if (offsets != null && offsets.length != nOffsets) { if (nOffsets == 0) { - offsets = null; + offsets = null; } else { offsets = Arrays.copyOf(offsets, nOffsets); } @@ -762,15 +712,59 @@ private static int getStandardOffset(long[] standardTransitions, int[] standardOffsets, long epochSec) { - int index = Arrays.binarySearch(standardTransitions, epochSec); - if (index < 0) { - // switch negative insert position to start of matched range - index = -index - 2; - } - return standardOffsets[index + 1]; + // The size of stdOffsets is [0..9], with most are + // [1..4] entries , simple loop search is faster + // + // int index = Arrays.binarySearch(standardTransitions, epochSec); + // if (index < 0) { + // // switch negative insert position to start of matched range + // index = -index - 2; + // } + // return standardOffsets[index + 1]; + int index = 0; + for (; index < standardTransitions.length; index++) { + if (epochSec < standardTransitions[index]) { + break; + } + } + return standardOffsets[index]; + } + + static final int SECONDS_PER_DAY = 86400; + static final int DAYS_PER_CYCLE = 146097; + static final long DAYS_0000_TO_1970 = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L); + + private static int getYear(long epochSecond, int offset) { + long second = epochSecond + offset; // overflow caught later + long epochDay = Math.floorDiv(second, SECONDS_PER_DAY); + long zeroDay = epochDay + DAYS_0000_TO_1970; + // find the march-based year + zeroDay -= 60; // adjust to 0000-03-01 so leap day is at end of four year cycle + long adjust = 0; + if (zeroDay < 0) { + // adjust negative years to positive for calculation + long adjustCycles = (zeroDay + 1) / DAYS_PER_CYCLE - 1; + adjust = adjustCycles * 400; + zeroDay += -adjustCycles * DAYS_PER_CYCLE; + } + long yearEst = (400 * zeroDay + 591) / DAYS_PER_CYCLE; + long doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); + if (doyEst < 0) { + // fix estimate + yearEst--; + doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); + } + yearEst += adjust; // reset any negative year + int marchDoy0 = (int) doyEst; + // convert march-based values back to january-based + int marchMonth0 = (marchDoy0 * 5 + 2) / 153; + int month = (marchMonth0 + 2) % 12 + 1; + int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1; + yearEst += marchMonth0 / 10; + return (int)yearEst; } - private static int toCalendarDOW[] = new int[] { + private static final int toCalendarDOW[] = new int[] { -1, Calendar.MONDAY, Calendar.TUESDAY, @@ -781,7 +775,7 @@ Calendar.SUNDAY }; - private static int toSTZTime[] = new int[] { + private static final int toSTZTime[] = new int[] { SimpleTimeZone.UTC_TIME, SimpleTimeZone.WALL_TIME, SimpleTimeZone.STANDARD_TIME, @@ -823,28 +817,152 @@ return nOffsets; } - ///////////////////////////////////////////////////////////// // ZoneInfo checksum, copy/pasted from javazic private static class Checksum extends CRC32 { public void update(int val) { byte[] b = new byte[4]; - b[0] = (byte)((val >>> 24) & 0xff); - b[1] = (byte)((val >>> 16) & 0xff); - b[2] = (byte)((val >>> 8) & 0xff); - b[3] = (byte)(val & 0xff); + b[0] = (byte)(val >>> 24); + b[1] = (byte)(val >>> 16); + b[2] = (byte)(val >>> 8); + b[3] = (byte)(val); update(b); } void update(long val) { byte[] b = new byte[8]; - b[0] = (byte)((val >>> 56) & 0xff); - b[1] = (byte)((val >>> 48) & 0xff); - b[2] = (byte)((val >>> 40) & 0xff); - b[3] = (byte)((val >>> 32) & 0xff); - b[4] = (byte)((val >>> 24) & 0xff); - b[5] = (byte)((val >>> 16) & 0xff); - b[6] = (byte)((val >>> 8) & 0xff); - b[7] = (byte)(val & 0xff); + b[0] = (byte)(val >>> 56); + b[1] = (byte)(val >>> 48); + b[2] = (byte)(val >>> 40); + b[3] = (byte)(val >>> 32); + b[4] = (byte)(val >>> 24); + b[5] = (byte)(val >>> 16); + b[6] = (byte)(val >>> 8); + b[7] = (byte)(val); update(b); } } + + // A simple/raw version of j.t.ZoneOffsetTransitionRule + private static class ZoneOffsetTransitionRule { + private final int month; + private final byte dom; + private final int dow; + private final int secondOfDay; + private final boolean timeEndOfDay; + private final int timeDefinition; + private final int standardOffset; + private final int offsetBefore; + private final int offsetAfter; + + ZoneOffsetTransitionRule(DataInput in) throws IOException { + int data = in.readInt(); + int dowByte = (data & (7 << 19)) >>> 19; + int timeByte = (data & (31 << 14)) >>> 14; + int stdByte = (data & (255 << 4)) >>> 4; + int beforeByte = (data & (3 << 2)) >>> 2; + int afterByte = (data & 3); + + this.month = data >>> 28; + this.dom = (byte)(((data & (63 << 22)) >>> 22) - 32); + this.dow = dowByte == 0 ? -1 : dowByte; + this.secondOfDay = timeByte == 31 ? in.readInt() : timeByte * 3600; + this.timeEndOfDay = timeByte == 24; + this.timeDefinition = (data & (3 << 12)) >>> 12; + + this.standardOffset = stdByte == 255 ? in.readInt() : (stdByte - 128) * 900; + this.offsetBefore = beforeByte == 3 ? in.readInt() : standardOffset + beforeByte * 1800; + this.offsetAfter = afterByte == 3 ? in.readInt() : standardOffset + afterByte * 1800; + } + + long getTransitionEpochSecond(int year) { + long epochDay = 0; + if (dom < 0) { + epochDay = toEpochDay(year, month, lengthOfMonth(year, month) + 1 + dom); + if (dow != -1) { + epochDay = previousOrSame(epochDay, dow); + } + } else { + epochDay = toEpochDay(year, month, dom); + if (dow != -1) { + epochDay = nextOrSame(epochDay, dow); + } + } + if (timeEndOfDay) { + epochDay += 1; + } + int difference = 0; + switch (timeDefinition) { + case 0: // UTC + difference = 0; + break; + case 1: // WALL + difference = -offsetBefore; + break; + case 2: //STANDARD + difference = -standardOffset; + break; + } + return epochDay * 86400 + secondOfDay + difference; + } + + static final boolean isLeapYear(int year) { + return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0); + } + + static final int lengthOfMonth(int year, int month) { + switch (month) { + case 2: //FEBRUARY: + return isLeapYear(year)? 29 : 28; + case 4: //APRIL: + case 6: //JUNE: + case 9: //SEPTEMBER: + case 11: //NOVEMBER: + return 30; + default: + return 31; + } + } + + static final long toEpochDay(int year, int month, int day) { + long y = year; + long m = month; + long total = 0; + total += 365 * y; + if (y >= 0) { + total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400; + } else { + total -= y / -4 - y / -100 + y / -400; + } + total += ((367 * m - 362) / 12); + total += day - 1; + if (m > 2) { + total--; + if (!isLeapYear(year)) { + total--; + } + } + return total - DAYS_0000_TO_1970; + } + + static final long previousOrSame(long epochDay, int dayOfWeek) { + return adjust(epochDay, dayOfWeek, 1); + } + + static final long nextOrSame(long epochDay, int dayOfWeek) { + return adjust(epochDay, dayOfWeek, 0); + } + + static final long adjust(long epochDay, int dow, int relative) { + int calDow = (int)Math.floorMod(epochDay + 3, 7L) + 1; + if (relative < 2 && calDow == dow) { + return epochDay; + } + if ((relative & 1) == 0) { + int daysDiff = calDow - dow; + return epochDay + (daysDiff >= 0 ? 7 - daysDiff : -daysDiff); + } else { + int daysDiff = dow - calDow; + return epochDay - (daysDiff >= 0 ? 7 - daysDiff : -daysDiff); + } + } + } } --- old/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java 2013-04-11 23:17:20.000000000 -0700 +++ new/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java 2013-04-11 23:17:20.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -69,7 +69,7 @@ field, value, style, false); } - public static String retrieveCldrFieldValueName(String id, int field, int value, int style, Locale locale) { + public static String retrieveJavaTimeFieldValueName(String id, int field, int value, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); String name; @@ -89,7 +89,7 @@ normalizeCalendarType(id), field, style, false); } - public static Map retrieveCldrFieldValueNames(String id, int field, int style, Locale locale) { + public static Map retrieveJavaTimeFieldValueNames(String id, int field, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); Map map; @@ -133,14 +133,14 @@ int field = (int) params[0]; int value = (int) params[1]; int style = (int) params[2]; - boolean cldr = (boolean) params[3]; + boolean javatime = (boolean) params[3]; - // If cldr is true, resources from CLDR have precedence over JRE + // If javatime is true, resources from CLDR have precedence over JRE // native resources. - if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { String name; name = ((CalendarNameProviderImpl)calendarNameProvider) - .getCldrDisplayName(requestID, field, value, style, locale); + .getJavaTimeDisplayName(requestID, field, value, style, locale); return name; } return calendarNameProvider.getDisplayName(requestID, field, value, style, locale); @@ -165,14 +165,14 @@ assert params.length == 3; int field = (int) params[0]; int style = (int) params[1]; - boolean cldr = (boolean) params[2]; + boolean javatime = (boolean) params[2]; - // If cldr is true, resources from CLDR have precedence over JRE + // If javatime is true, resources from CLDR have precedence over JRE // native resources. - if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { Map map; map = ((CalendarNameProviderImpl)calendarNameProvider) - .getCldrDisplayNames(requestID, field, style, locale); + .getJavaTimeDisplayNames(requestID, field, style, locale); return map; } return calendarNameProvider.getDisplayNames(requestID, field, style, locale); --- old/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java 2013-04-11 23:17:21.000000000 -0700 +++ new/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java 2013-04-11 23:17:21.000000000 -0700 @@ -53,15 +53,16 @@ return getDisplayNameImpl(calendarType, field, value, style, locale, false); } - public String getCldrDisplayName(String calendarType, int field, int value, int style, Locale locale) { + public String getJavaTimeDisplayName(String calendarType, int field, int value, int style, Locale locale) { return getDisplayNameImpl(calendarType, field, value, style, locale, true); } - public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean cldr) { + public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; - String key = getResourceKey(calendarType, field, style, cldr); + String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { - String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key); + LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); + String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; @@ -104,18 +105,19 @@ } // NOTE: This method should be used ONLY BY JSR 310 classes. - public Map getCldrDisplayNames(String calendarType, int field, int style, Locale locale) { + public Map getJavaTimeDisplayNames(String calendarType, int field, int style, Locale locale) { Map names; names = getDisplayNamesImpl(calendarType, field, style, locale, true); return names.isEmpty() ? null : names; } private Map getDisplayNamesImpl(String calendarType, int field, - int style, Locale locale, boolean cldr) { - String key = getResourceKey(calendarType, field, style, cldr); + int style, Locale locale, boolean javatime) { + String key = getResourceKey(calendarType, field, style, javatime); Map map = new TreeMap<>(LengthBasedComparator.INSTANCE); if (key != null) { - String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key); + LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); + String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null) { if (!hasDuplicates(strings)) { if (field == YEAR) { @@ -220,7 +222,7 @@ return false; } - private String getResourceKey(String type, int field, int style, boolean cldr) { + private String getResourceKey(String type, int field, int style, boolean javatime) { int baseStyle = getBaseStyle(style); boolean isStandalone = (style != baseStyle); @@ -229,9 +231,9 @@ } boolean isNarrow = (baseStyle == NARROW_FORMAT); StringBuilder key = new StringBuilder(); - // If cldr is true, use prefix "cldr.". - if (cldr) { - key.append("cldr."); + // If javatime is true, use prefix "java.time.". + if (javatime) { + key.append("java.time."); } switch (field) { case ERA: @@ -245,7 +247,7 @@ // due to historical reasons. (JRE DateFormatSymbols.getEras returns // abbreviations while other getShort*() return abbreviations.) if (this.type == LocaleProviderAdapter.Type.JRE) { - if (cldr) { + if (javatime) { if (baseStyle == LONG) { key.append("long."); } @@ -253,7 +255,7 @@ if (baseStyle == SHORT) { key.append("short."); } - } else { // CLDR + } else { // this.type == LocaleProviderAdapter.Type.CLDR if (baseStyle == LONG) { key.append("long."); } --- old/src/share/classes/sun/util/locale/provider/LocaleResources.java 2013-04-11 23:17:21.000000000 -0700 +++ new/src/share/classes/sun/util/locale/provider/LocaleResources.java 2013-04-11 23:17:21.000000000 -0700 @@ -54,6 +54,7 @@ import sun.util.calendar.ZoneInfo; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; import sun.util.resources.TimeZoneNamesBundle; /** @@ -331,6 +332,25 @@ return names; } + String[] getJavaTimeNames(String key) { + String[] names = null; + String cacheKey = CALENDAR_NAMES + key; + + removeEmptyReferences(); + ResourceReference data = cache.get(cacheKey); + + if (data == null || ((names = (String[]) data.get()) == null)) { + ResourceBundle rb = getJavaTimeFormatData(); + if (rb.containsKey(key)) { + names = rb.getStringArray(key); + cache.put(cacheKey, + new ResourceReference(cacheKey, (Object) names, referenceQueue)); + } + } + + return names; + } + public String getDateTimePattern(int timeStyle, int dateStyle, Calendar cal) { if (cal == null) { cal = Calendar.getInstance(locale); @@ -347,10 +367,10 @@ * @param calType the calendar type for the pattern * @return the pattern string */ - public String getCldrDateTimePattern(int timeStyle, int dateStyle, String calType) { + public String getJavaTimeDateTimePattern(int timeStyle, int dateStyle, String calType) { calType = CalendarDataUtility.normalizeCalendarType(calType); String pattern; - pattern = getDateTimePattern("cldr.", timeStyle, dateStyle, calType); + pattern = getDateTimePattern("java.time.", timeStyle, dateStyle, calType); if (pattern == null) { pattern = getDateTimePattern(null, timeStyle, dateStyle, calType); } @@ -430,8 +450,12 @@ * The FormatData should be used only for accessing extra * resources required by JSR 310. */ - public ResourceBundle getFormatData() { - return localeData.getDateFormatData(locale); + public ResourceBundle getJavaTimeFormatData() { + ResourceBundle rb = localeData.getDateFormatData(locale); + if (rb instanceof ParallelListResourceBundle) { + localeData.setSupplementary((ParallelListResourceBundle) rb); + } + return rb; } private String getDateTimePattern(String prefix, String key, int styleIndex, String calendarType) { @@ -451,7 +475,7 @@ Object value = NULLOBJECT; if (data == null || ((value = data.get()) == null)) { - ResourceBundle r = localeData.getDateFormatData(locale); + ResourceBundle r = (prefix != null) ? getJavaTimeFormatData() : localeData.getDateFormatData(locale); if (r.containsKey(resourceKey)) { value = r.getStringArray(resourceKey); } else { --- old/src/share/classes/sun/util/resources/LocaleData.java 2013-04-11 23:17:22.000000000 -0700 +++ new/src/share/classes/sun/util/resources/LocaleData.java 2013-04-11 23:17:22.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -42,9 +42,11 @@ import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.MissingResourceException; import java.util.ResourceBundle; import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; @@ -122,6 +124,30 @@ return getBundle(type.getTextResourcesPackage() + ".FormatData", locale); } + public void setSupplementary(ParallelListResourceBundle formatData) { + if (!formatData.areParallelContentsComplete()) { + String suppName = type.getTextResourcesPackage() + ".JavaTimeSupplementary"; + setSupplementary(suppName, formatData); + } + } + + private boolean setSupplementary(String suppName, ParallelListResourceBundle formatData) { + ParallelListResourceBundle parent = (ParallelListResourceBundle) formatData.getParent(); + boolean resetKeySet = false; + if (parent != null) { + resetKeySet = setSupplementary(suppName, parent); + } + OpenListResourceBundle supp = getSupplementary(suppName, formatData.getLocale()); + formatData.setParallelContents(supp); + resetKeySet |= supp != null; + // If any parents or this bundle has parallel data, reset keyset to create + // a new keyset with the data. + if (resetKeySet) { + formatData.resetKeySet(); + } + return resetKeySet; + } + /** * Gets a number format data resource bundle, using privileges * to allow accessing a sun.* package. @@ -132,22 +158,37 @@ public static ResourceBundle getBundle(final String baseName, final Locale locale) { return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public ResourceBundle run() { - return ResourceBundle. - getBundle(baseName, locale, - LocaleDataResourceBundleControl.getRBControlInstance()); - } - }); + @Override + public ResourceBundle run() { + return ResourceBundle + .getBundle(baseName, locale, LocaleDataResourceBundleControl.INSTANCE); + } + }); + } + + private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public OpenListResourceBundle run() { + OpenListResourceBundle rb = null; + try { + rb = (OpenListResourceBundle) ResourceBundle.getBundle(baseName, + locale, SupplementaryResourceBundleControl.INSTANCE); + + } catch (MissingResourceException e) { + // return null if no supplementary is available + } + return rb; + } + }); } private static class LocaleDataResourceBundleControl extends ResourceBundle.Control { /* Singlton instance of ResourceBundle.Control. */ - private static LocaleDataResourceBundleControl rbControlInstance = + private static final LocaleDataResourceBundleControl INSTANCE = new LocaleDataResourceBundleControl(); - public static LocaleDataResourceBundleControl getRBControlInstance() { - return rbControlInstance; + private LocaleDataResourceBundleControl() { } /* @@ -243,6 +284,25 @@ } return super.toBundleName(newBaseName, locale); } + } + + private static class SupplementaryResourceBundleControl extends LocaleDataResourceBundleControl { + private static final SupplementaryResourceBundleControl INSTANCE = + new SupplementaryResourceBundleControl(); + + private SupplementaryResourceBundleControl() { + } + @Override + public List getCandidateLocales(String baseName, Locale locale) { + // Specifiy only the given locale + return Arrays.asList(locale); + } + + @Override + public long getTimeToLive(String baseName, Locale locale) { + assert baseName.contains("JavaTimeSupplementary"); + return TTL_DONT_CACHE; + } } } --- old/src/share/classes/sun/util/resources/OpenListResourceBundle.java 2013-04-11 23:17:23.000000000 -0700 +++ new/src/share/classes/sun/util/resources/OpenListResourceBundle.java 2013-04-11 23:17:22.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 @@ -68,7 +68,7 @@ // Implements java.util.ResourceBundle.handleGetObject; inherits javadoc specification. @Override - public Object handleGetObject(String key) { + protected Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } @@ -82,18 +82,18 @@ */ @Override public Enumeration getKeys() { - ResourceBundle parent = this.parent; - return new ResourceBundleEnumeration(handleGetKeys(), - (parent != null) ? parent.getKeys() : null); - } + ResourceBundle parentBundle = this.parent; + return new ResourceBundleEnumeration(handleKeySet(), + (parentBundle != null) ? parentBundle.getKeys() : null); + } /** * Returns a set of keys provided in this resource bundle, * including no parents. */ - public Set handleGetKeys() { + @Override + protected Set handleKeySet() { loadLookupTablesIfNecessary(); - return lookup.keySet(); } @@ -103,7 +103,7 @@ return keyset; } Set ks = createSet(); - ks.addAll(handleGetKeys()); + ks.addAll(handleKeySet()); if (parent != null) { ks.addAll(parent.keySet()); } --- old/src/share/lib/calendars.properties 2013-04-11 23:17:23.000000000 -0700 +++ new/src/share/lib/calendars.properties 2013-04-11 23:17:23.000000000 -0700 @@ -52,3 +52,9 @@ calendar.thai-buddhist.year-boundary: \ day1=4-1,since=-79302585600000; \ day1=1-1,since=-915148800000 + +# +# Hijrah calendars +# +calendar.hijrah.Hijrah-umalqura: hijrah-config-umalqura.properties +calendar.hijrah.Hijrah-umalqura.type: islamic-umalqura --- old/test/java/time/tck/java/time/AbstractDateTimeTest.java 2013-04-11 23:17:24.000000000 -0700 +++ new/test/java/time/tck/java/time/AbstractDateTimeTest.java 2013-04-11 23:17:23.000000000 -0700 @@ -59,19 +59,16 @@ */ package tck.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; -import java.util.List; - +import java.time.DateTimeException; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; +import java.util.List; import org.testng.annotations.Test; -import test.java.time.AbstractTest; import test.java.time.temporal.MockFieldNoValue; /** @@ -100,7 +97,7 @@ //----------------------------------------------------------------------- // isSupported(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -109,7 +106,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -118,7 +115,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_null() { for (TemporalAccessor sample : samples()) { assertEquals(sample.isSupported(null), false, "Failed on " + sample); @@ -128,7 +125,7 @@ //----------------------------------------------------------------------- // range(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -137,7 +134,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -151,7 +148,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -166,7 +163,7 @@ //----------------------------------------------------------------------- // get(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -184,7 +181,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -205,7 +202,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -220,7 +217,7 @@ //----------------------------------------------------------------------- // getLong(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -229,7 +226,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -250,7 +247,7 @@ } } - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -263,7 +260,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void basicTest_query() { for (TemporalAccessor sample : samples()) { assertEquals(sample.query(new TemporalQuery() { --- old/test/java/time/tck/java/time/TCKClock.java 2013-04-11 23:17:24.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKClock.java 2013-04-11 23:17:24.000000000 -0700 @@ -59,10 +59,12 @@ */ package tck.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; +import java.time.Clock; +import java.time.Instant; +import java.time.ZoneId; + import org.testng.annotations.Test; /** --- old/test/java/time/tck/java/time/TCKDayOfWeek.java 2013-04-11 23:17:25.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKDayOfWeek.java 2013-04-11 23:17:25.000000000 -0700 @@ -70,12 +70,10 @@ import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalTime; -import java.time.chrono.IsoChronology; import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; @@ -125,7 +123,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = 1; i <= 7; i++) { DayOfWeek test = DayOfWeek.of(i); @@ -134,28 +132,28 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_valueTooLow() { DayOfWeek.of(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_valueTooHigh() { DayOfWeek.of(8); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(DayOfWeek.from(LocalDate.of(2011, 6, 6)), DayOfWeek.MONDAY); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { DayOfWeek.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { DayOfWeek.from((TemporalAccessor) null); } @@ -179,13 +177,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {DayOfWeek.FRIDAY, Queries.chronology(), null}, - {DayOfWeek.FRIDAY, Queries.zoneId(), null}, - {DayOfWeek.FRIDAY, Queries.precision(), ChronoUnit.DAYS}, - {DayOfWeek.FRIDAY, Queries.zone(), null}, - {DayOfWeek.FRIDAY, Queries.offset(), null}, - {DayOfWeek.FRIDAY, Queries.localDate(), null}, - {DayOfWeek.FRIDAY, Queries.localTime(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.chronology(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.zoneId(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.precision(), ChronoUnit.DAYS}, + {DayOfWeek.FRIDAY, TemporalQuery.zone(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.offset(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.localDate(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.localTime(), null}, }; } @@ -207,17 +205,17 @@ //----------------------------------------------------------------------- // getText() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getText() { assertEquals(DayOfWeek.MONDAY.getDisplayName(TextStyle.SHORT, Locale.US), "Mon"); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullStyle() { DayOfWeek.MONDAY.getDisplayName(null, Locale.US); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullLocale() { DayOfWeek.MONDAY.getDisplayName(TextStyle.FULL, null); } @@ -264,7 +262,7 @@ }; } - @Test(dataProvider="plus", groups={"tck"}) + @Test(dataProvider="plus") public void test_plus_long(int base, long amount, int expected) { assertEquals(DayOfWeek.of(base).plus(amount), DayOfWeek.of(expected)); } @@ -295,7 +293,7 @@ }; } - @Test(dataProvider="minus", groups={"tck"}) + @Test(dataProvider="minus") public void test_minus_long(int base, long amount, int expected) { assertEquals(DayOfWeek.of(base).minus(amount), DayOfWeek.of(expected)); } @@ -303,7 +301,7 @@ //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustInto() { assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 2)), LocalDate.of(2012, 8, 27)); assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 3)), LocalDate.of(2012, 9, 3)); @@ -312,7 +310,7 @@ assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 11)), LocalDate.of(2012, 9, 10)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustInto_null() { DayOfWeek.MONDAY.adjustInto((Temporal) null); } @@ -320,7 +318,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { assertEquals(DayOfWeek.MONDAY.toString(), "MONDAY"); assertEquals(DayOfWeek.TUESDAY.toString(), "TUESDAY"); @@ -334,7 +332,7 @@ //----------------------------------------------------------------------- // generated methods //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_enum() { assertEquals(DayOfWeek.valueOf("MONDAY"), DayOfWeek.MONDAY); assertEquals(DayOfWeek.values()[0], DayOfWeek.MONDAY); --- old/test/java/time/tck/java/time/TCKDuration.java 2013-04-11 23:17:26.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKDuration.java 2013-04-11 23:17:25.000000000 -0700 @@ -72,20 +72,23 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; +import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.Period; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -98,6 +101,8 @@ @Test public class TCKDuration extends AbstractTCKTest { + private static final long CYCLE_SECS = 146097L * 86400L; + //----------------------------------------------------------------------- @Test public void test_serialization() throws Exception { @@ -121,7 +126,7 @@ //----------------------------------------------------------------------- // constants //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_zero() { assertEquals(Duration.ZERO.getSeconds(), 0L); assertEquals(Duration.ZERO.getNano(), 0); @@ -130,7 +135,7 @@ //----------------------------------------------------------------------- // ofSeconds(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_seconds_long() { for (long i = -2; i <= 2; i++) { Duration t = Duration.ofSeconds(i); @@ -142,7 +147,7 @@ //----------------------------------------------------------------------- // ofSeconds(long,long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_seconds_long_long() { for (long i = -2; i <= 2; i++) { for (int j = 0; j < 10; j++) { @@ -163,14 +168,14 @@ } } - @Test(groups={"tck"}) + @Test public void factory_seconds_long_long_nanosNegativeAdjusted() { Duration test = Duration.ofSeconds(2L, -1); assertEquals(test.getSeconds(), 1); assertEquals(test.getNano(), 999999999); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_seconds_long_long_tooBig() { Duration.ofSeconds(Long.MAX_VALUE, 1000000000); } @@ -195,7 +200,7 @@ }; } - @Test(dataProvider="MillisDurationNoNanos", groups={"tck"}) + @Test(dataProvider="MillisDurationNoNanos") public void factory_millis_long(long millis, long expectedSeconds, int expectedNanoOfSecond) { Duration test = Duration.ofMillis(millis); assertEquals(test.getSeconds(), expectedSeconds); @@ -205,35 +210,35 @@ //----------------------------------------------------------------------- // ofNanos(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_nanos_nanos() { Duration test = Duration.ofNanos(1); assertEquals(test.getSeconds(), 0); assertEquals(test.getNano(), 1); } - @Test(groups={"tck"}) + @Test public void factory_nanos_nanosSecs() { Duration test = Duration.ofNanos(1000000002); assertEquals(test.getSeconds(), 1); assertEquals(test.getNano(), 2); } - @Test(groups={"tck"}) + @Test public void factory_nanos_negative() { Duration test = Duration.ofNanos(-2000000001); assertEquals(test.getSeconds(), -3); assertEquals(test.getNano(), 999999999); } - @Test(groups={"tck"}) + @Test public void factory_nanos_max() { Duration test = Duration.ofNanos(Long.MAX_VALUE); assertEquals(test.getSeconds(), Long.MAX_VALUE / 1000000000); assertEquals(test.getNano(), Long.MAX_VALUE % 1000000000); } - @Test(groups={"tck"}) + @Test public void factory_nanos_min() { Duration test = Duration.ofNanos(Long.MIN_VALUE); assertEquals(test.getSeconds(), Long.MIN_VALUE / 1000000000 - 1); @@ -243,33 +248,33 @@ //----------------------------------------------------------------------- // ofMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_minutes() { Duration test = Duration.ofMinutes(2); assertEquals(test.getSeconds(), 120); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_minutes_max() { Duration test = Duration.ofMinutes(Long.MAX_VALUE / 60); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 60) * 60); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_minutes_min() { Duration test = Duration.ofMinutes(Long.MIN_VALUE / 60); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 60) * 60); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_minutes_tooBig() { Duration.ofMinutes(Long.MAX_VALUE / 60 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_minutes_tooSmall() { Duration.ofMinutes(Long.MIN_VALUE / 60 - 1); } @@ -277,33 +282,33 @@ //----------------------------------------------------------------------- // ofHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_hours() { Duration test = Duration.ofHours(2); assertEquals(test.getSeconds(), 2 * 3600); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_hours_max() { Duration test = Duration.ofHours(Long.MAX_VALUE / 3600); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 3600) * 3600); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_hours_min() { Duration test = Duration.ofHours(Long.MIN_VALUE / 3600); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 3600) * 3600); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_hours_tooBig() { Duration.ofHours(Long.MAX_VALUE / 3600 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_hours_tooSmall() { Duration.ofHours(Long.MIN_VALUE / 3600 - 1); } @@ -311,33 +316,33 @@ //----------------------------------------------------------------------- // ofDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_days() { Duration test = Duration.ofDays(2); assertEquals(test.getSeconds(), 2 * 86400); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_days_max() { Duration test = Duration.ofDays(Long.MAX_VALUE / 86400); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 86400) * 86400); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_days_min() { Duration test = Duration.ofDays(Long.MIN_VALUE / 86400); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 86400) * 86400); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_days_tooBig() { Duration.ofDays(Long.MAX_VALUE / 86400 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_days_tooSmall() { Duration.ofDays(Long.MIN_VALUE / 86400 - 1); } @@ -405,7 +410,7 @@ }; } - @Test(dataProvider="OfTemporalUnit", groups={"tck"}) + @Test(dataProvider="OfTemporalUnit") public void factory_of_longTemporalUnit(long amount, TemporalUnit unit, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.of(amount, unit); assertEquals(t.getSeconds(), expectedSeconds); @@ -424,76 +429,93 @@ }; } - @Test(dataProvider="OfTemporalUnitOutOfRange", expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(dataProvider="OfTemporalUnitOutOfRange", expectedExceptions=ArithmeticException.class) public void factory_of_longTemporalUnit_outOfRange(long amount, TemporalUnit unit) { Duration.of(amount, unit); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_longTemporalUnit_estimatedUnit() { Duration.of(2, WEEKS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_longTemporalUnit_null() { Duration.of(1, (TemporalUnit) null); } //----------------------------------------------------------------------- - // between() + // from(TemporalAmount) //----------------------------------------------------------------------- - @DataProvider(name="durationBetweenInstant") - Object[][] data_durationBetweenInstant() { - return new Object[][] { - {0, 0, 0, 0, 0, 0}, - {3, 0, 7, 0, 4, 0}, - {3, 20, 7, 50, 4, 30}, - {3, 80, 7, 50, 3, 999999970}, - {7, 0, 3, 0, -4, 0}, - }; - } - - @Test(dataProvider="durationBetweenInstant") - public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { - Instant start = Instant.ofEpochSecond(secs1, nanos1); - Instant end = Instant.ofEpochSecond(secs2, nanos2); - Duration t = Duration.between(start, end); - assertEquals(t.getSeconds(), expectedSeconds); - assertEquals(t.getNano(), expectedNanoOfSecond); + @Test + public void factory_from_TemporalAmount_Duration() { + TemporalAmount amount = Duration.ofHours(3); + assertEquals(Duration.from(amount), Duration.ofHours(3)); } - @DataProvider(name="durationBetweenLocalTime") - Object[][] data_durationBetweenLocalTime() { - return new Object[][] { - {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 45), 15L, 0}, - {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 25), -5L, 0}, + @Test + public void factory_from_TemporalAmount_DaysNanos() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + if (unit == DAYS) { + return 23; + } else { + return 45; + } + } + @Override + public List getUnits() { + List list = new ArrayList<>(); + list.add(DAYS); + list.add(NANOS); + return list; + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } }; + Duration t = Duration.from(amount); + assertEquals(t.getSeconds(), 23 * 86400); + assertEquals(t.getNano(), 45); } - @Test(dataProvider="durationBetweenLocalTime") - public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { - Duration t = Duration.between(start, end); - assertEquals(t.getSeconds(), expectedSeconds); - assertEquals(t.getNano(), expectedNanoOfSecond); - } - - @Test(expectedExceptions=DateTimeException.class) - public void factory_between_TemporalTemporal_mixedTypes() { - Instant start = Instant.ofEpochSecond(1); - ZonedDateTime end = Instant.ofEpochSecond(4).atZone(ZoneOffset.UTC); - Duration.between(start, end); + @Test(expectedExceptions = ArithmeticException.class) + public void factory_from_TemporalAmount_Minutes_tooBig() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + return (Long.MAX_VALUE / 60) + 2; + } + @Override + public List getUnits() { + return Collections.singletonList(MINUTES); + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } + }; + Duration.from(amount); } - @Test(expectedExceptions=NullPointerException.class) - public void factory_between__TemporalTemporal_startNull() { - Instant end = Instant.ofEpochSecond(1); - Duration.between(null, end); + @Test(expectedExceptions = DateTimeException.class) + public void factory_from_TemporalAmount_Period() { + Duration.from(Period.ZERO); } - @Test(expectedExceptions=NullPointerException.class) - public void factory_between__TemporalTemporal_endNull() { - Instant start = Instant.ofEpochSecond(1); - Duration.between(start, null); + @Test(expectedExceptions = NullPointerException.class) + public void factory_from_TemporalAmount_null() { + Duration.from(null); } //----------------------------------------------------------------------- @@ -749,17 +771,115 @@ } //----------------------------------------------------------------------- - @Test - public void test_deserialization() throws Exception { - Duration orginal = Duration.ofSeconds(2); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - Duration ser = (Duration) in.readObject(); - assertEquals(Duration.ofSeconds(2), ser); + // between() + //----------------------------------------------------------------------- + @DataProvider(name="durationBetweenInstant") + Object[][] data_durationBetweenInstant() { + return new Object[][] { + {0, 0, 0, 0, 0, 0}, + {3, 0, 7, 0, 4, 0}, + {7, 0, 3, 0, -4, 0}, + + {3, 20, 7, 50, 4, 30}, + {3, 80, 7, 50, 3, 999999970}, + {3, 80, 7, 79, 3, 999999999}, + {3, 80, 7, 80, 4, 0}, + {3, 80, 7, 81, 4, 1}, + }; + } + + @Test(dataProvider="durationBetweenInstant") + public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { + Instant start = Instant.ofEpochSecond(secs1, nanos1); + Instant end = Instant.ofEpochSecond(secs2, nanos2); + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenInstant") + public void factory_between_TemporalTemporal_Instant_negated(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { + Instant start = Instant.ofEpochSecond(secs1, nanos1); + Instant end = Instant.ofEpochSecond(secs2, nanos2); + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @DataProvider(name="durationBetweenLocalTime") + Object[][] data_durationBetweenLocalTime() { + return new Object[][] { + {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 45), 15L, 0}, + {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 25), -5L, 0}, + }; + } + + @Test(dataProvider="durationBetweenLocalTime") + public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenLocalTime") + public void factory_between_TemporalTemporal_LT_negated(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @DataProvider(name="durationBetweenLocalDateTime") + Object[][] data_durationBetweenLocalDateTime() { + return new Object[][] { + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 65_000_000), -2L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), -1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 65_000_000), 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 65_000_000), 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 65_000_000), 2L, 500_000_000}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 565_000_000), -1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 565_000_000), 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 565_000_000), 2L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 565_000_000), 3L, 500_000_000}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 65_000_000), -1L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), 0L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 65_000_000), 1L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 65_000_000), 2L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 65_000_000), 3L, 0}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 30, 565_000_000), 2 * CYCLE_SECS - 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 31, 565_000_000), 2 * CYCLE_SECS + 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 32, 565_000_000), 2 * CYCLE_SECS + 1L, 500_000_000}, + }; + } + + @Test(dataProvider="durationBetweenLocalDateTime") + public void factory_between_TemporalTemporal_LDT(LocalDateTime start, LocalDateTime end, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenLocalDateTime") + public void factory_between_TemporalTemporal_LDT_negated(LocalDateTime start, LocalDateTime end, long expectedSeconds, int expectedNanoOfSecond) { + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @Test(expectedExceptions=DateTimeException.class) + public void factory_between_TemporalTemporal_mixedTypes() { + Instant start = Instant.ofEpochSecond(1); + ZonedDateTime end = Instant.ofEpochSecond(4).atZone(ZoneOffset.UTC); + Duration.between(start, end); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_between__TemporalTemporal_startNull() { + Instant end = Instant.ofEpochSecond(1); + Duration.between(null, end); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_between__TemporalTemporal_endNull() { + Instant start = Instant.ofEpochSecond(1); + Duration.between(start, null); } //----------------------------------------------------------------------- @@ -977,27 +1097,27 @@ }; } - @Test(dataProvider="Plus", groups={"tck"}) + @Test(dataProvider="Plus") public void plus(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos).plus(Duration.ofSeconds(otherSeconds, otherNanos)); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void plusOverflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.plus(Duration.ofSeconds(0, 1)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void plusOverflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE); t.plus(Duration.ofSeconds(-1, 999999999)); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_seconds() { Duration t = Duration.ofSeconds(1); t = t.plus(1, SECONDS); @@ -1005,7 +1125,7 @@ assertEquals(0, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_millis() { Duration t = Duration.ofSeconds(1); t = t.plus(1, MILLIS); @@ -1013,7 +1133,7 @@ assertEquals(1000000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_micros() { Duration t = Duration.ofSeconds(1); t = t.plus(1, MICROS); @@ -1021,7 +1141,7 @@ assertEquals(1000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_nanos() { Duration t = Duration.ofSeconds(1); t = t.plus(1, NANOS); @@ -1029,13 +1149,139 @@ assertEquals(1, t.getNano()); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void plus_longTemporalUnit_null() { Duration t = Duration.ofSeconds(1); t.plus(1, (TemporalUnit) null); } //----------------------------------------------------------------------- + @DataProvider(name="PlusDays") + Object[][] provider_plusDays_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/3600/24, 0, Long.MAX_VALUE/3600/24}, + {Long.MIN_VALUE/3600/24, 0, Long.MIN_VALUE/3600/24}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/3600/24, Long.MIN_VALUE/3600/24 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/3600/24, Long.MAX_VALUE/3600/24 - 1}, + }; + } + + @Test(dataProvider="PlusDays") + public void plusDays_long(long days, long amount, long expectedDays) { + Duration t = Duration.ofDays(days); + t = t.plusDays(amount); + assertEquals(t.toDays(), expectedDays); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusDays_long_overflowTooBig() { + Duration t = Duration.ofDays(1); + t.plusDays(Long.MAX_VALUE/3600/24); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusDays_long_overflowTooSmall() { + Duration t = Duration.ofDays(-1); + t.plusDays(Long.MIN_VALUE/3600/24); + } + + //----------------------------------------------------------------------- + @DataProvider(name="PlusHours") + Object[][] provider_plusHours_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/3600, 0, Long.MAX_VALUE/3600}, + {Long.MIN_VALUE/3600, 0, Long.MIN_VALUE/3600}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/3600, Long.MIN_VALUE/3600 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/3600, Long.MAX_VALUE/3600 - 1}, + }; + } + + @Test(dataProvider="PlusHours") + public void plusHours_long(long hours, long amount, long expectedHours) { + Duration t = Duration.ofHours(hours); + t = t.plusHours(amount); + assertEquals(t.toHours(), expectedHours); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusHours_long_overflowTooBig() { + Duration t = Duration.ofHours(1); + t.plusHours(Long.MAX_VALUE/3600); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusHours_long_overflowTooSmall() { + Duration t = Duration.ofHours(-1); + t.plusHours(Long.MIN_VALUE/3600); + } + + //----------------------------------------------------------------------- + @DataProvider(name="PlusMinutes") + Object[][] provider_plusMinutes_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/60, 0, Long.MAX_VALUE/60}, + {Long.MIN_VALUE/60, 0, Long.MIN_VALUE/60}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/60, Long.MIN_VALUE/60 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/60, Long.MAX_VALUE/60 - 1}, + }; + } + + @Test(dataProvider="PlusMinutes") + public void plusMinutes_long(long minutes, long amount, long expectedMinutes) { + Duration t = Duration.ofMinutes(minutes); + t = t.plusMinutes(amount); + assertEquals(t.toMinutes(), expectedMinutes); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusMinutes_long_overflowTooBig() { + Duration t = Duration.ofMinutes(1); + t.plusMinutes(Long.MAX_VALUE/60); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusMinutes_long_overflowTooSmall() { + Duration t = Duration.ofMinutes(-1); + t.plusMinutes(Long.MIN_VALUE/60); + } + + //----------------------------------------------------------------------- @DataProvider(name="PlusSeconds") Object[][] provider_plusSeconds_long() { return new Object[][] { @@ -1062,7 +1308,7 @@ }; } - @Test(dataProvider="PlusSeconds", groups={"tck"}) + @Test(dataProvider="PlusSeconds") public void plusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusSeconds(amount); @@ -1070,13 +1316,13 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusSeconds_long_overflowTooBig() { Duration t = Duration.ofSeconds(1, 0); t.plusSeconds(Long.MAX_VALUE); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusSeconds_long_overflowTooSmall() { Duration t = Duration.ofSeconds(-1, 0); t.plusSeconds(Long.MIN_VALUE); @@ -1138,21 +1384,21 @@ }; } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds + 1, nanos); t = t.plusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds + 1); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds - 1, nanos); t = t.plusMillis(amount); @@ -1160,7 +1406,7 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(groups={"tck"}) + @Test public void plusMillis_long_max() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 998999999); t = t.plusMillis(1); @@ -1168,13 +1414,13 @@ assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusMillis_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999000000); t.plusMillis(1); } - @Test(groups={"tck"}) + @Test public void plusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.plusMillis(-1); @@ -1182,7 +1428,7 @@ assertEquals(t.getNano(), 0); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusMillis_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.plusMillis(-1); @@ -1264,7 +1510,7 @@ }; } - @Test(dataProvider="PlusNanos", groups={"tck"}) + @Test(dataProvider="PlusNanos") public void plusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusNanos(amount); @@ -1272,13 +1518,13 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusNanos_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.plusNanos(1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusNanos_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.plusNanos(-1); @@ -1470,27 +1716,27 @@ }; } - @Test(dataProvider="Minus", groups={"tck"}) + @Test(dataProvider="Minus") public void minus(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos).minus(Duration.ofSeconds(otherSeconds, otherNanos)); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void minusOverflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE); t.minus(Duration.ofSeconds(0, 1)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void minusOverflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.minus(Duration.ofSeconds(-1, 999999999)); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_seconds() { Duration t = Duration.ofSeconds(1); t = t.minus(1, SECONDS); @@ -1498,7 +1744,7 @@ assertEquals(0, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_millis() { Duration t = Duration.ofSeconds(1); t = t.minus(1, MILLIS); @@ -1506,7 +1752,7 @@ assertEquals(999000000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_micros() { Duration t = Duration.ofSeconds(1); t = t.minus(1, MICROS); @@ -1514,7 +1760,7 @@ assertEquals(999999000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_nanos() { Duration t = Duration.ofSeconds(1); t = t.minus(1, NANOS); @@ -1522,13 +1768,139 @@ assertEquals(999999999, t.getNano()); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void minus_longTemporalUnit_null() { Duration t = Duration.ofSeconds(1); t.minus(1, (TemporalUnit) null); } //----------------------------------------------------------------------- + @DataProvider(name="MinusDays") + Object[][] provider_minusDays_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/3600/24, 0, Long.MAX_VALUE/3600/24}, + {Long.MIN_VALUE/3600/24, 0, Long.MIN_VALUE/3600/24}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/3600/24, 1, Long.MAX_VALUE/3600/24 - 1}, + {Long.MIN_VALUE/3600/24, -1, Long.MIN_VALUE/3600/24 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusDays") + public void minusDays_long(long days, long amount, long expectedDays) { + Duration t = Duration.ofDays(days); + t = t.minusDays(amount); + assertEquals(t.toDays(), expectedDays); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusDays_long_overflowTooBig() { + Duration t = Duration.ofDays(Long.MAX_VALUE/3600/24); + t.minusDays(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusDays_long_overflowTooSmall() { + Duration t = Duration.ofDays(Long.MIN_VALUE/3600/24); + t.minusDays(1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="MinusHours") + Object[][] provider_minusHours_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/3600, 0, Long.MAX_VALUE/3600}, + {Long.MIN_VALUE/3600, 0, Long.MIN_VALUE/3600}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/3600, 1, Long.MAX_VALUE/3600 - 1}, + {Long.MIN_VALUE/3600, -1, Long.MIN_VALUE/3600 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusHours") + public void minusHours_long(long hours, long amount, long expectedHours) { + Duration t = Duration.ofHours(hours); + t = t.minusHours(amount); + assertEquals(t.toHours(), expectedHours); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusHours_long_overflowTooBig() { + Duration t = Duration.ofHours(Long.MAX_VALUE/3600); + t.minusHours(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusHours_long_overflowTooSmall() { + Duration t = Duration.ofHours(Long.MIN_VALUE/3600); + t.minusHours(1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="MinusMinutes") + Object[][] provider_minusminutes_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/60, 0, Long.MAX_VALUE/60}, + {Long.MIN_VALUE/60, 0, Long.MIN_VALUE/60}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/60, 1, Long.MAX_VALUE/60 - 1}, + {Long.MIN_VALUE/60, -1, Long.MIN_VALUE/60 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusMinutes") + public void minusMinutes_long(long minutes, long amount, long expectedMinutes) { + Duration t = Duration.ofMinutes(minutes); + t = t.minusMinutes(amount); + assertEquals(t.toMinutes(), expectedMinutes); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusMinutes_long_overflowTooBig() { + Duration t = Duration.ofMinutes(Long.MAX_VALUE/60); + t.minusMinutes(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusMinutes_long_overflowTooSmall() { + Duration t = Duration.ofMinutes(Long.MIN_VALUE/60); + t.minusMinutes(1); + } + + //----------------------------------------------------------------------- @DataProvider(name="MinusSeconds") Object[][] provider_minusSeconds_long() { return new Object[][] { @@ -1555,7 +1927,7 @@ }; } - @Test(dataProvider="MinusSeconds", groups={"tck"}) + @Test(dataProvider="MinusSeconds") public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusSeconds(amount); @@ -1563,13 +1935,13 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusSeconds_long_overflowTooBig() { Duration t = Duration.ofSeconds(1, 0); t.minusSeconds(Long.MIN_VALUE + 1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusSeconds_long_overflowTooSmall() { Duration t = Duration.ofSeconds(-2, 0); t.minusSeconds(Long.MAX_VALUE); @@ -1631,21 +2003,21 @@ }; } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds + 1, nanos); t = t.minusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds + 1); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds - 1, nanos); t = t.minusMillis(amount); @@ -1653,7 +2025,7 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(groups={"tck"}) + @Test public void minusMillis_long_max() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 998999999); t = t.minusMillis(-1); @@ -1661,13 +2033,13 @@ assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusMillis_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999000000); t.minusMillis(-1); } - @Test(groups={"tck"}) + @Test public void minusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.minusMillis(1); @@ -1675,7 +2047,7 @@ assertEquals(t.getNano(), 0); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusMillis_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.minusMillis(1); @@ -1757,7 +2129,7 @@ }; } - @Test(dataProvider="MinusNanos", groups={"tck"}) + @Test(dataProvider="MinusNanos") public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusNanos(amount); @@ -1765,13 +2137,13 @@ assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusNanos_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.minusNanos(-1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusNanos_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.minusNanos(1); @@ -1873,7 +2245,7 @@ }; } - @Test(dataProvider="MultipliedBy", groups={"tck"}) + @Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); @@ -1881,25 +2253,25 @@ assertEquals(t.getNano(), expectedNanos); } - @Test(groups={"tck"}) + @Test public void multipliedBy_max() { Duration test = Duration.ofSeconds(1); assertEquals(test.multipliedBy(Long.MAX_VALUE), Duration.ofSeconds(Long.MAX_VALUE)); } - @Test(groups={"tck"}) + @Test public void multipliedBy_min() { Duration test = Duration.ofSeconds(1); assertEquals(test.multipliedBy(Long.MIN_VALUE), Duration.ofSeconds(Long.MIN_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); @@ -1990,7 +2362,7 @@ }; } - @Test(dataProvider="DividedBy", groups={"tck"}) + @Test(dataProvider="DividedBy") public void dividedBy(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.dividedBy(divisor); @@ -1998,14 +2370,14 @@ assertEquals(t.getNano(), expectedNanos); } - @Test(dataProvider="DividedBy", expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(dataProvider="DividedBy", expectedExceptions=ArithmeticException.class) public void dividedByZero(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t.dividedBy(0); fail(t + " divided by zero did not throw ArithmeticException"); } - @Test(groups={"tck"}) + @Test public void dividedBy_max() { Duration test = Duration.ofSeconds(Long.MAX_VALUE); assertEquals(test.dividedBy(Long.MAX_VALUE), Duration.ofSeconds(1)); @@ -2014,7 +2386,7 @@ //----------------------------------------------------------------------- // negated() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_negated() { assertEquals(Duration.ofSeconds(0).negated(), Duration.ofSeconds(0)); assertEquals(Duration.ofSeconds(12).negated(), Duration.ofSeconds(-12)); @@ -2026,7 +2398,7 @@ assertEquals(Duration.ofSeconds(Long.MAX_VALUE).negated(), Duration.ofSeconds(-Long.MAX_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_negated_overflow() { Duration.ofSeconds(Long.MIN_VALUE).negated(); } @@ -2034,7 +2406,7 @@ //----------------------------------------------------------------------- // abs() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_abs() { assertEquals(Duration.ofSeconds(0).abs(), Duration.ofSeconds(0)); assertEquals(Duration.ofSeconds(12).abs(), Duration.ofSeconds(12)); @@ -2046,7 +2418,7 @@ assertEquals(Duration.ofSeconds(Long.MAX_VALUE).abs(), Duration.ofSeconds(Long.MAX_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_abs_overflow() { Duration.ofSeconds(Long.MIN_VALUE).abs(); } @@ -2054,19 +2426,19 @@ //----------------------------------------------------------------------- // toNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toNanos() { Duration test = Duration.ofSeconds(321, 123456789); assertEquals(test.toNanos(), 321123456789L); } - @Test(groups={"tck"}) + @Test public void test_toNanos_max() { Duration test = Duration.ofSeconds(0, Long.MAX_VALUE); assertEquals(test.toNanos(), Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_toNanos_tooBig() { Duration test = Duration.ofSeconds(0, Long.MAX_VALUE).plusNanos(1); test.toNanos(); @@ -2075,19 +2447,19 @@ //----------------------------------------------------------------------- // toMillis() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toMillis() { Duration test = Duration.ofSeconds(321, 123456789); assertEquals(test.toMillis(), 321000 + 123); } - @Test(groups={"tck"}) + @Test public void test_toMillis_max() { Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, (Long.MAX_VALUE % 1000) * 1000000); assertEquals(test.toMillis(), Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_toMillis_tooBig() { Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, ((Long.MAX_VALUE % 1000) + 1) * 1000000); test.toMillis(); @@ -2096,7 +2468,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_Duration( Duration.ofSeconds(-2L, 0), @@ -2134,13 +2506,13 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { Duration a = Duration.ofSeconds(0L, 0); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({ "unchecked", "rawtypes" }) public void compareToNonDuration() { Comparable c = Duration.ofSeconds(0L); @@ -2150,7 +2522,7 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { Duration test5a = Duration.ofSeconds(5L, 20); Duration test5b = Duration.ofSeconds(5L, 20); @@ -2178,13 +2550,13 @@ assertEquals(test6.equals(test6), true); } - @Test(groups={"tck"}) + @Test public void test_equals_null() { Duration test5 = Duration.ofSeconds(5L, 20); assertEquals(test5.equals(null), false); } - @Test(groups={"tck"}) + @Test public void test_equals_otherClass() { Duration test5 = Duration.ofSeconds(5L, 20); assertEquals(test5.equals(""), false); @@ -2193,7 +2565,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode() { Duration test5a = Duration.ofSeconds(5L, 20); Duration test5b = Duration.ofSeconds(5L, 20); @@ -2209,6 +2581,71 @@ } //----------------------------------------------------------------------- + @DataProvider(name="withNanos") + Object[][] provider_withNanos_int() { + return new Object[][] { + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1}, + {0, 0, 999999999, 0, 999999999}, + + {1, 0, 0, 1, 0}, + {1, 0, 1, 1, 1}, + {1, 0, 999999999, 1, 999999999}, + + {-1, 0, 0, -1, 0}, + {-1, 0, 1, -1, 1}, + {-1, 0, 999999999, -1, 999999999}, + + {1, 999999999, 0, 1, 0}, + {1, 999999999, 1, 1, 1}, + {1, 999999998, 2, 1, 2}, + + {Long.MAX_VALUE, 0, 999999999, Long.MAX_VALUE, 999999999}, + {Long.MIN_VALUE, 0, 999999999, Long.MIN_VALUE, 999999999}, + }; + } + + @Test(dataProvider="withNanos") + public void withNanos_long(long seconds, int nanos, int amount, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.ofSeconds(seconds, nanos); + t = t.withNanos(amount); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + //----------------------------------------------------------------------- + @DataProvider(name="withSeconds") + Object[][] provider_withSeconds_long() { + return new Object[][] { + {0, 0, 0, 0, 0}, + {0, 0, 1, 1, 0}, + {0, 0, -1, -1, 0}, + {0, 0, Long.MAX_VALUE, Long.MAX_VALUE, 0}, + {0, 0, Long.MIN_VALUE, Long.MIN_VALUE, 0}, + + {1, 0, 0, 0, 0}, + {1, 0, 2, 2, 0}, + {1, 0, -1, -1, 0}, + {1, 0, Long.MAX_VALUE, Long.MAX_VALUE, 0}, + {1, 0, Long.MIN_VALUE, Long.MIN_VALUE, 0}, + + {-1, 1, 0, 0, 1}, + {-1, 1, 1, 1, 1}, + {-1, 1, -1, -1, 1}, + {-1, 1, Long.MAX_VALUE, Long.MAX_VALUE, 1}, + {-1, 1, Long.MIN_VALUE, Long.MIN_VALUE, 1}, + }; + } + + @Test(dataProvider="withSeconds") + public void withSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.ofSeconds(seconds, nanos); + t = t.withSeconds(amount); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- @DataProvider(name="toString") @@ -2299,6 +2736,6 @@ @Test(dataProvider="BadTemporalUnit", expectedExceptions=DateTimeException.class) public void test_bad_getUnit(long amount, TemporalUnit unit) { Duration t = Duration.of(amount, unit); - long actual = t.get(unit); + t.get(unit); } } --- old/test/java/time/tck/java/time/TCKInstant.java 2013-04-11 23:17:26.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKInstant.java 2013-04-11 23:17:26.000000000 -0700 @@ -75,6 +75,7 @@ import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -84,18 +85,20 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -113,6 +116,8 @@ private static final long MIN_SECOND = Instant.MIN.getEpochSecond(); private static final long MAX_SECOND = Instant.MAX.getEpochSecond(); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); + private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private Instant TEST_12345_123456789; @@ -411,13 +416,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12345_123456789, Queries.chronology(), null}, - {TEST_12345_123456789, Queries.zoneId(), null}, - {TEST_12345_123456789, Queries.precision(), NANOS}, - {TEST_12345_123456789, Queries.zone(), null}, - {TEST_12345_123456789, Queries.offset(), null}, - {TEST_12345_123456789, Queries.localDate(), null}, - {TEST_12345_123456789, Queries.localTime(), null}, + {TEST_12345_123456789, TemporalQuery.chronology(), null}, + {TEST_12345_123456789, TemporalQuery.zoneId(), null}, + {TEST_12345_123456789, TemporalQuery.precision(), NANOS}, + {TEST_12345_123456789, TemporalQuery.zone(), null}, + {TEST_12345_123456789, TemporalQuery.offset(), null}, + {TEST_12345_123456789, TemporalQuery.localDate(), null}, + {TEST_12345_123456789, TemporalQuery.localTime(), null}, }; } @@ -437,6 +442,128 @@ } //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null}, + {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null}, + {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null}, + {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null}, + {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null}, + {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null}, + {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(Instant test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // with(TemporalAdjuster) + //----------------------------------------------------------------------- + @DataProvider(name="with") + Object[][] data_with() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null}, + {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null}, + {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null}, + {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null}, + {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class}, + + }; + } + + + @Test(dataProvider="with") + public void test_with_temporalAdjuster(Instant test, TemporalAdjuster adjuster, Instant expected, Class expectedEx) { + if (expectedEx == null) { + Instant result = test.with(adjuster); + assertEquals(result, expected); + } else { + try { + Instant result = test.with(adjuster); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // with(TemporalField, long) + //----------------------------------------------------------------------- + @DataProvider(name="with_longTemporalField") + Object[][] data_with_longTemporalField() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 100, Instant.ofEpochSecond(100, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 0, Instant.ofEpochSecond(0, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, -100, Instant.ofEpochSecond(-100, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000*1000), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 1000000000L, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 1000000, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 1000, null, DateTimeException.class}, + + {Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_MINUTE, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.OFFSET_SECONDS, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_HOUR, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_DAY, 1, null, DateTimeException.class}, + + + }; + } + + @Test(dataProvider="with_longTemporalField") + public void test_with_longTemporalField(Instant test, TemporalField field, long value, Instant expected, Class expectedEx) { + if (expectedEx == null) { + Instant result = test.with(field, value); + assertEquals(result, expected); + } else { + try { + Instant result = test.with(field, value); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- // truncated(TemporalUnit) //----------------------------------------------------------------------- TemporalUnit NINETY_MINS = new TemporalUnit() { @@ -509,7 +636,7 @@ {Instant.ofEpochSecond(86400 + 10800 + 60 + 1, 123_456_789), NINETY_MINS, Instant.ofEpochSecond(86400 + 10800, 0)}, }; } - @Test(groups={"tck"}, dataProvider="truncatedToValid") + @Test(dataProvider="truncatedToValid") public void test_truncatedTo_valid(Instant input, TemporalUnit unit, Instant expected) { assertEquals(input.truncatedTo(unit), expected); } @@ -524,12 +651,12 @@ }; } - @Test(groups={"tck"}, dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) public void test_truncatedTo_invalid(Instant input, TemporalUnit unit) { input.truncatedTo(unit); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_12345_123456789.truncatedTo(null); } @@ -1580,6 +1707,130 @@ } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {5, 650, -1, 650, SECONDS, -6}, + {5, 650, 0, 650, SECONDS, -5}, + {5, 650, 3, 650, SECONDS, -2}, + {5, 650, 4, 650, SECONDS, -1}, + {5, 650, 5, 650, SECONDS, 0}, + {5, 650, 6, 650, SECONDS, 1}, + {5, 650, 7, 650, SECONDS, 2}, + + {5, 650, -1, 0, SECONDS, -6}, + {5, 650, 0, 0, SECONDS, -5}, + {5, 650, 3, 0, SECONDS, -2}, + {5, 650, 4, 0, SECONDS, -1}, + {5, 650, 5, 0, SECONDS, 0}, + {5, 650, 6, 0, SECONDS, 0}, + {5, 650, 7, 0, SECONDS, 1}, + + {5, 650, -1, 950, SECONDS, -5}, + {5, 650, 0, 950, SECONDS, -4}, + {5, 650, 3, 950, SECONDS, -1}, + {5, 650, 4, 950, SECONDS, 0}, + {5, 650, 5, 950, SECONDS, 0}, + {5, 650, 6, 950, SECONDS, 1}, + {5, 650, 7, 950, SECONDS, 2}, + + {5, 650, -1, 50, SECONDS, -6}, + {5, 650, 0, 50, SECONDS, -5}, + {5, 650, 4, 50, SECONDS, -1}, + {5, 650, 5, 50, SECONDS, 0}, + {5, 650, 6, 50, SECONDS, 0}, + {5, 650, 7, 50, SECONDS, 1}, + {5, 650, 8, 50, SECONDS, 2}, + + {5, 650_000_000, -1, 650_000_000, NANOS, -6_000_000_000L}, + {5, 650_000_000, 0, 650_000_000, NANOS, -5_000_000_000L}, + {5, 650_000_000, 3, 650_000_000, NANOS, -2_000_000_000L}, + {5, 650_000_000, 4, 650_000_000, NANOS, -1_000_000_000L}, + {5, 650_000_000, 5, 650_000_000, NANOS, 0}, + {5, 650_000_000, 6, 650_000_000, NANOS, 1_000_000_000L}, + {5, 650_000_000, 7, 650_000_000, NANOS, 2_000_000_000L}, + + {5, 650_000_000, -1, 0, NANOS, -6_650_000_000L}, + {5, 650_000_000, 0, 0, NANOS, -5_650_000_000L}, + {5, 650_000_000, 3, 0, NANOS, -2_650_000_000L}, + {5, 650_000_000, 4, 0, NANOS, -1_650_000_000L}, + {5, 650_000_000, 5, 0, NANOS, -650_000_000L}, + {5, 650_000_000, 6, 0, NANOS, 350_000_000L}, + {5, 650_000_000, 7, 0, NANOS, 1_350_000_000L}, + + {5, 650_000_000, -1, 950_000_000, NANOS, -5_700_000_000L}, + {5, 650_000_000, 0, 950_000_000, NANOS, -4_700_000_000L}, + {5, 650_000_000, 3, 950_000_000, NANOS, -1_700_000_000L}, + {5, 650_000_000, 4, 950_000_000, NANOS, -700_000_000L}, + {5, 650_000_000, 5, 950_000_000, NANOS, 300_000_000L}, + {5, 650_000_000, 6, 950_000_000, NANOS, 1_300_000_000L}, + {5, 650_000_000, 7, 950_000_000, NANOS, 2_300_000_000L}, + + {5, 650_000_000, -1, 50_000_000, NANOS, -6_600_000_000L}, + {5, 650_000_000, 0, 50_000_000, NANOS, -5_600_000_000L}, + {5, 650_000_000, 4, 50_000_000, NANOS, -1_600_000_000L}, + {5, 650_000_000, 5, 50_000_000, NANOS, -600_000_000L}, + {5, 650_000_000, 6, 50_000_000, NANOS, 400_000_000L}, + {5, 650_000_000, 7, 50_000_000, NANOS, 1_400_000_000L}, + {5, 650_000_000, 8, 50_000_000, NANOS, 2_400_000_000L}, + + {0, 0, -60, 0, MINUTES, -1L}, + {0, 0, -1, 999_999_999, MINUTES, 0L}, + {0, 0, 59, 0, MINUTES, 0L}, + {0, 0, 59, 999_999_999, MINUTES, 0L}, + {0, 0, 60, 0, MINUTES, 1L}, + {0, 0, 61, 0, MINUTES, 1L}, + + {0, 0, -3600, 0, HOURS, -1L}, + {0, 0, -1, 999_999_999, HOURS, 0L}, + {0, 0, 3599, 0, HOURS, 0L}, + {0, 0, 3599, 999_999_999, HOURS, 0L}, + {0, 0, 3600, 0, HOURS, 1L}, + {0, 0, 3601, 0, HOURS, 1L}, + + {0, 0, -86400, 0, DAYS, -1L}, + {0, 0, -1, 999_999_999, DAYS, 0L}, + {0, 0, 86399, 0, DAYS, 0L}, + {0, 0, 86399, 999_999_999, DAYS, 0L}, + {0, 0, 86400, 0, DAYS, 1L}, + {0, 0, 86401, 0, DAYS, 1L}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) { + Instant i1 = Instant.ofEpochSecond(seconds1, nanos1); + Instant i2 = Instant.ofEpochSecond(seconds2, nanos2); + long amount = i1.periodUntil(i2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) { + Instant i1 = Instant.ofEpochSecond(seconds1, nanos1); + Instant i2 = Instant.ofEpochSecond(seconds2, nanos2); + long amount = i2.periodUntil(i1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_12345_123456789.periodUntil(TEST_12345_123456789, MONTHS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_12345_123456789.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_12345_123456789.periodUntil(TEST_12345_123456789, null); + } + + //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- @Test --- old/test/java/time/tck/java/time/TCKLocalDate.java 2013-04-11 23:17:27.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKLocalDate.java 2013-04-11 23:17:27.000000000 -0700 @@ -67,11 +67,19 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; @@ -101,13 +109,13 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -137,7 +145,7 @@ private Instant MAX_INSTANT; private Instant MIN_INSTANT; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); @@ -170,7 +178,7 @@ ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -236,7 +244,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { LocalDate expected = LocalDate.now(Clock.systemDefaultZone()); LocalDate test = LocalDate.now(); @@ -253,12 +261,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalDate.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); @@ -276,12 +284,12 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalDate.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -293,7 +301,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -305,7 +313,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { for (int i =-1; i >= -(2 * 24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i); @@ -318,27 +326,27 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_maxYear() { Clock clock = Clock.fixed(MAX_INSTANT, ZoneOffset.UTC); LocalDate test = LocalDate.now(clock); assertEquals(test, MAX_DATE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooBig() { Clock clock = Clock.fixed(MAX_INSTANT.plusSeconds(24 * 60 * 60), ZoneOffset.UTC); LocalDate.now(clock); } - @Test(groups={"tck"}) + @Test public void now_Clock_minYear() { Clock clock = Clock.fixed(MIN_INSTANT, ZoneOffset.UTC); LocalDate test = LocalDate.now(clock); assertEquals(test, MIN_DATE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooLow() { Clock clock = Clock.fixed(MIN_INSTANT.minusNanos(1), ZoneOffset.UTC); LocalDate.now(clock); @@ -347,84 +355,84 @@ //----------------------------------------------------------------------- // of() factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_intsMonth() { assertEquals(TEST_2007_07_15, LocalDate.of(2007, Month.JULY, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_29febNonLeap() { LocalDate.of(2007, Month.FEBRUARY, 29); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_31apr() { LocalDate.of(2007, Month.APRIL, 31); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_dayTooLow() { LocalDate.of(2007, Month.JANUARY, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_dayTooHigh() { LocalDate.of(2007, Month.JANUARY, 32); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_intsMonth_nullMonth() { LocalDate.of(2007, null, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_yearTooLow() { LocalDate.of(Integer.MIN_VALUE, Month.JANUARY, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_ints() { check(TEST_2007_07_15, 2007, 7, 15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_29febNonLeap() { LocalDate.of(2007, 2, 29); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_31apr() { LocalDate.of(2007, 4, 31); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_dayTooLow() { LocalDate.of(2007, 1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_dayTooHigh() { LocalDate.of(2007, 1, 32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_monthTooLow() { LocalDate.of(2007, 0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_monthTooHigh() { LocalDate.of(2007, 13, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_yearTooLow() { LocalDate.of(Integer.MIN_VALUE, 1, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofYearDay_ints_nonLeap() { LocalDate date = LocalDate.of(2007, 1, 1); for (int i = 1; i < 365; i++) { @@ -433,7 +441,7 @@ } } - @Test(groups={"tck"}) + @Test public void factory_ofYearDay_ints_leap() { LocalDate date = LocalDate.of(2008, 1, 1); for (int i = 1; i < 366; i++) { @@ -442,22 +450,22 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_366nonLeap() { LocalDate.ofYearDay(2007, 366); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooLow() { LocalDate.ofYearDay(2007, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooHigh() { LocalDate.ofYearDay(2007, 367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); } @@ -491,7 +499,7 @@ //----------------------------------------------------------------------- // ofEpochDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofEpochDay() { long date_0000_01_01 = -678941 - 40587; assertEquals(LocalDate.ofEpochDay(0), LocalDate.of(1970, 1, 1)); @@ -512,12 +520,12 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochDay_aboveMax() { LocalDate.ofEpochDay(MAX_VALID_EPOCHDAYS + 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochDay_belowMin() { LocalDate.ofEpochDay(MIN_VALID_EPOCHDAYS - 1); } @@ -525,18 +533,18 @@ //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor() { assertEquals(LocalDate.from(LocalDate.of(2007, 7, 15)), LocalDate.of(2007, 7, 15)); assertEquals(LocalDate.from(LocalDateTime.of(2007, 7, 15, 12, 30)), LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { LocalDate.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { LocalDate.from((TemporalAccessor) null); } @@ -544,7 +552,7 @@ //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void factory_parse_validText(int y, int m, int d, String parsable) { LocalDate t = LocalDate.parse(parsable); assertNotNull(t, parsable); @@ -570,22 +578,22 @@ }; } - @Test(dataProvider="sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider="sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { LocalDate.parse(unparsable); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { LocalDate.parse("2008-06-32"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { LocalDate.parse("2008-06-31"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { LocalDate.parse((String) null); } @@ -593,20 +601,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); LocalDate test = LocalDate.parse("2010 12 3", f); assertEquals(test, LocalDate.of(2010, 12, 3)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); LocalDate.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalDate.parse("ANY", null); } @@ -617,21 +625,26 @@ @Test public void test_get_TemporalField() { LocalDate test = LocalDate.of(2008, 6, 30); - assertEquals(test.get(ChronoField.YEAR), 2008); - assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30); - assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1); - assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182); + assertEquals(test.get(YEAR), 2008); + assertEquals(test.get(MONTH_OF_YEAR), 6); + assertEquals(test.get(YEAR_OF_ERA), 2008); + assertEquals(test.get(ERA), 1); + assertEquals(test.get(DAY_OF_MONTH), 30); + assertEquals(test.get(DAY_OF_WEEK), 1); + assertEquals(test.get(DAY_OF_YEAR), 182); } @Test public void test_getLong_TemporalField() { LocalDate test = LocalDate.of(2008, 6, 30); - assertEquals(test.getLong(ChronoField.YEAR), 2008); - assertEquals(test.getLong(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(test.getLong(ChronoField.DAY_OF_MONTH), 30); - assertEquals(test.getLong(ChronoField.DAY_OF_WEEK), 1); - assertEquals(test.getLong(ChronoField.DAY_OF_YEAR), 182); + assertEquals(test.getLong(YEAR), 2008); + assertEquals(test.getLong(MONTH_OF_YEAR), 6); + assertEquals(test.getLong(YEAR_OF_ERA), 2008); + assertEquals(test.getLong(ERA), 1); + assertEquals(test.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 - 1); + assertEquals(test.getLong(DAY_OF_MONTH), 30); + assertEquals(test.getLong(DAY_OF_WEEK), 1); + assertEquals(test.getLong(DAY_OF_YEAR), 182); } //----------------------------------------------------------------------- @@ -640,13 +653,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15, Queries.zoneId(), null}, - {TEST_2007_07_15, Queries.precision(), ChronoUnit.DAYS}, - {TEST_2007_07_15, Queries.zone(), null}, - {TEST_2007_07_15, Queries.offset(), null}, - {TEST_2007_07_15, Queries.localDate(), TEST_2007_07_15}, - {TEST_2007_07_15, Queries.localTime(), null}, + {TEST_2007_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15, TemporalQuery.zoneId(), null}, + {TEST_2007_07_15, TemporalQuery.precision(), ChronoUnit.DAYS}, + {TEST_2007_07_15, TemporalQuery.zone(), null}, + {TEST_2007_07_15, TemporalQuery.offset(), null}, + {TEST_2007_07_15, TemporalQuery.localDate(), TEST_2007_07_15}, + {TEST_2007_07_15, TemporalQuery.localTime(), null}, }; } @@ -681,7 +694,7 @@ } //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_get(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); assertEquals(a.getYear(), y); @@ -689,7 +702,7 @@ assertEquals(a.getDayOfMonth(), d); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_getDOY(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); int total = 0; @@ -700,7 +713,7 @@ assertEquals(a.getDayOfYear(), doy); } - @Test(groups={"tck"}) + @Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { @@ -716,7 +729,7 @@ //----------------------------------------------------------------------- // isLeapYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeapYear() { assertEquals(LocalDate.of(1999, 1, 1).isLeapYear(), false); assertEquals(LocalDate.of(2000, 1, 1).isLeapYear(), true); @@ -736,7 +749,7 @@ //----------------------------------------------------------------------- // lengthOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_notLeapYear() { assertEquals(LocalDate.of(2007, 1, 1).lengthOfMonth(), 31); assertEquals(LocalDate.of(2007, 2, 1).lengthOfMonth(), 28); @@ -752,7 +765,7 @@ assertEquals(LocalDate.of(2007, 12, 1).lengthOfMonth(), 31); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_leapYear() { assertEquals(LocalDate.of(2008, 1, 1).lengthOfMonth(), 31); assertEquals(LocalDate.of(2008, 2, 1).lengthOfMonth(), 29); @@ -771,7 +784,7 @@ //----------------------------------------------------------------------- // lengthOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfYear() { assertEquals(LocalDate.of(2007, 1, 1).lengthOfYear(), 365); assertEquals(LocalDate.of(2008, 1, 1).lengthOfYear(), 366); @@ -780,7 +793,7 @@ //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalDate sample = LocalDate.of(2012, 3, 4); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -792,7 +805,7 @@ assertEquals(TEST_2007_07_15.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2007_07_15.with((TemporalAdjuster) null); } @@ -800,28 +813,28 @@ //----------------------------------------------------------------------- // with(TemporalField,long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_TemporalField_long_normal() { LocalDate t = TEST_2007_07_15.with(YEAR, 2008); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"} ) + @Test(expectedExceptions=NullPointerException.class ) public void test_with_TemporalField_long_null() { TEST_2007_07_15.with((TemporalField) null, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_invalidField() { TEST_2007_07_15.with(MockFieldNoValue.INSTANCE, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_timeField() { TEST_2007_07_15.with(ChronoField.AMPM_OF_DAY, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_invalidValue() { TEST_2007_07_15.with(ChronoField.DAY_OF_WEEK, -1); } @@ -829,18 +842,18 @@ //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_int_normal() { LocalDate t = TEST_2007_07_15.withYear(2008); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_int_invalid() { TEST_2007_07_15.withYear(Year.MIN_VALUE - 1); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).withYear(2007); LocalDate expected = LocalDate.of(2007, 2, 28); @@ -850,18 +863,18 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_int_normal() { LocalDate t = TEST_2007_07_15.withMonth(1); assertEquals(t, LocalDate.of(2007, 1, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_int_invalid() { TEST_2007_07_15.withMonth(13); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_adjustDay() { LocalDate t = LocalDate.of(2007, 12, 31).withMonth(11); LocalDate expected = LocalDate.of(2007, 11, 30); @@ -871,18 +884,18 @@ //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { LocalDate t = TEST_2007_07_15.withDayOfMonth(1); assertEquals(t, LocalDate.of(2007, 7, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_illegal() { TEST_2007_07_15.withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { LocalDate.of(2007, 11, 30).withDayOfMonth(31); } @@ -890,18 +903,18 @@ //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { LocalDate t = TEST_2007_07_15.withDayOfYear(33); assertEquals(t, LocalDate.of(2007, 2, 2)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2007_07_15.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { TEST_2007_07_15.withDayOfYear(366); } @@ -909,38 +922,38 @@ //----------------------------------------------------------------------- // plus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Period_positiveMonths() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); LocalDate t = TEST_2007_07_15.plus(period); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_plus_Period_negativeDays() { MockSimplePeriod period = MockSimplePeriod.of(-25, ChronoUnit.DAYS); LocalDate t = TEST_2007_07_15.plus(period); assertEquals(t, LocalDate.of(2007, 6, 20)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_timeNotAllowed() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.HOURS); TEST_2007_07_15.plus(period); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_Period_null() { TEST_2007_07_15.plus((MockSimplePeriod) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_invalidTooLarge() { MockSimplePeriod period = MockSimplePeriod.of(1, ChronoUnit.YEARS); LocalDate.of(Year.MAX_VALUE, 1, 1).plus(period); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_invalidTooSmall() { MockSimplePeriod period = MockSimplePeriod.of(-1, ChronoUnit.YEARS); LocalDate.of(Year.MIN_VALUE, 1, 1).plus(period); @@ -949,34 +962,34 @@ //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveMonths() { LocalDate t = TEST_2007_07_15.plus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeDays() { LocalDate t = TEST_2007_07_15.plus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDate.of(2007, 6, 20)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_timeNotAllowed() { TEST_2007_07_15.plus(7, ChronoUnit.HOURS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_2007_07_15.plus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 1, 1).plus(1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plus(-1, ChronoUnit.YEARS); } @@ -984,56 +997,56 @@ //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_long_normal() { LocalDate t = TEST_2007_07_15.plusYears(1); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_negative() { LocalDate t = TEST_2007_07_15.plusYears(-1); assertEquals(t, LocalDate.of(2006, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).plusYears(1); LocalDate expected = LocalDate.of(2009, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_big() { long years = 20L + Year.MAX_VALUE; LocalDate test = LocalDate.of(-40, 6, 1).plusYears(years); assertEquals(test, LocalDate.of((int) (-40L + years), 6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLarge() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 6, 1); test.plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall_validInt() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall_invalidInt() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-10); } @@ -1041,227 +1054,227 @@ //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_normal() { LocalDate t = TEST_2007_07_15.plusMonths(1); assertEquals(t, LocalDate.of(2007, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_overYears() { LocalDate t = TEST_2007_07_15.plusMonths(25); assertEquals(t, LocalDate.of(2009, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negative() { LocalDate t = TEST_2007_07_15.plusMonths(-1); assertEquals(t, LocalDate.of(2007, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusMonths(-7); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusMonths(-31); assertEquals(t, LocalDate.of(2004, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_adjustDayFromLeapYear() { LocalDate t = LocalDate.of(2008, 2, 29).plusMonths(12); LocalDate expected = LocalDate.of(2009, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_adjustDayFromMonthLength() { LocalDate t = LocalDate.of(2007, 3, 31).plusMonths(1); LocalDate expected = LocalDate.of(2007, 4, 30); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_big() { long months = 20L + Integer.MAX_VALUE; LocalDate test = LocalDate.of(-40, 6, 1).plusMonths(months); assertEquals(test, LocalDate.of((int) (-40L + months / 12), 6 + (int) (months % 12), 1)); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 1).plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusMonths(-1); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_normal() { LocalDate t = TEST_2007_07_15.plusWeeks(1); assertEquals(t, LocalDate.of(2007, 7, 22)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overMonths() { LocalDate t = TEST_2007_07_15.plusWeeks(9); assertEquals(t, LocalDate.of(2007, 9, 16)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overYears() { LocalDate t = LocalDate.of(2006, 7, 16).plusWeeks(52); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(-1).plusWeeks(104); assertEquals(t, LocalDate.of(2008, 7, 12)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negative() { LocalDate t = TEST_2007_07_15.plusWeeks(-1); assertEquals(t, LocalDate.of(2007, 7, 8)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusWeeks(-28); assertEquals(t, LocalDate.of(2006, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusWeeks(-104); assertEquals(t, LocalDate.of(2005, 7, 17)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 24).plusWeeks(1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 8).plusWeeks(-1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusWeeks_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusWeeks_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 7).plusWeeks(-1); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_plusWeeks_invalidMaxMinusMax() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(Long.MAX_VALUE); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_plusWeeks_invalidMaxMinusMin() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(Long.MIN_VALUE); } - @Test(groups={"tck"}) + @Test public void test_plusDays_normal() { LocalDate t = TEST_2007_07_15.plusDays(1); assertEquals(t, LocalDate.of(2007, 7, 16)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overMonths() { LocalDate t = TEST_2007_07_15.plusDays(62); assertEquals(t, LocalDate.of(2007, 9, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overYears() { LocalDate t = LocalDate.of(2006, 7, 14).plusDays(366); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(-1).plusDays(365 + 366); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negative() { LocalDate t = TEST_2007_07_15.plusDays(-1); assertEquals(t, LocalDate.of(2007, 7, 14)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusDays(-196); assertEquals(t, LocalDate.of(2006, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusDays(-730); assertEquals(t, LocalDate.of(2005, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 30).plusDays(1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusDays_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 2).plusDays(-1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusDays_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).plusDays(1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusDays_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusDays(-1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).plusDays(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusDays(Long.MIN_VALUE); } @@ -1269,38 +1282,38 @@ //----------------------------------------------------------------------- // minus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Period_positiveMonths() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); LocalDate t = TEST_2007_07_15.minus(period); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_minus_Period_negativeDays() { MockSimplePeriod period = MockSimplePeriod.of(-25, ChronoUnit.DAYS); LocalDate t = TEST_2007_07_15.minus(period); assertEquals(t, LocalDate.of(2007, 8, 9)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_timeNotAllowed() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.HOURS); TEST_2007_07_15.minus(period); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_Period_null() { TEST_2007_07_15.minus((MockSimplePeriod) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_invalidTooLarge() { MockSimplePeriod period = MockSimplePeriod.of(-1, ChronoUnit.YEARS); LocalDate.of(Year.MAX_VALUE, 1, 1).minus(period); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_invalidTooSmall() { MockSimplePeriod period = MockSimplePeriod.of(1, ChronoUnit.YEARS); LocalDate.of(Year.MIN_VALUE, 1, 1).minus(period); @@ -1309,34 +1322,34 @@ //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveMonths() { LocalDate t = TEST_2007_07_15.minus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeDays() { LocalDate t = TEST_2007_07_15.minus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDate.of(2007, 8, 9)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_timeNotAllowed() { TEST_2007_07_15.minus(7, ChronoUnit.HOURS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_2007_07_15.minus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 1, 1).minus(-1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minus(1, ChronoUnit.YEARS); } @@ -1344,51 +1357,51 @@ //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_long_normal() { LocalDate t = TEST_2007_07_15.minusYears(1); assertEquals(t, LocalDate.of(2006, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_negative() { LocalDate t = TEST_2007_07_15.minusYears(-1); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).minusYears(1); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_big() { long years = 20L + Year.MAX_VALUE; LocalDate test = LocalDate.of(40, 6, 1).minusYears(years); assertEquals(test, LocalDate.of((int) (40L - years), 6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLarge() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 6, 1); test.minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusYears(1); } @@ -1396,232 +1409,307 @@ //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_normal() { LocalDate t = TEST_2007_07_15.minusMonths(1); assertEquals(t, LocalDate.of(2007, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_overYears() { LocalDate t = TEST_2007_07_15.minusMonths(25); assertEquals(t, LocalDate.of(2005, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negative() { LocalDate t = TEST_2007_07_15.minusMonths(-1); assertEquals(t, LocalDate.of(2007, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusMonths(-7); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusMonths(-31); assertEquals(t, LocalDate.of(2010, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_adjustDayFromLeapYear() { LocalDate t = LocalDate.of(2008, 2, 29).minusMonths(12); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_adjustDayFromMonthLength() { LocalDate t = LocalDate.of(2007, 3, 31).minusMonths(1); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_big() { long months = 20L + Integer.MAX_VALUE; LocalDate test = LocalDate.of(40, 6, 1).minusMonths(months); assertEquals(test, LocalDate.of((int) (40L - months / 12), 6 - (int) (months % 12), 1)); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 1).minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusMonths(1); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_normal() { LocalDate t = TEST_2007_07_15.minusWeeks(1); assertEquals(t, LocalDate.of(2007, 7, 8)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overMonths() { LocalDate t = TEST_2007_07_15.minusWeeks(9); assertEquals(t, LocalDate.of(2007, 5, 13)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overYears() { LocalDate t = LocalDate.of(2008, 7, 13).minusWeeks(52); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overLeapYears() { LocalDate t = TEST_2007_07_15.minusYears(-1).minusWeeks(104); assertEquals(t, LocalDate.of(2006, 7, 18)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negative() { LocalDate t = TEST_2007_07_15.minusWeeks(-1); assertEquals(t, LocalDate.of(2007, 7, 22)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusWeeks(-28); assertEquals(t, LocalDate.of(2008, 1, 27)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusWeeks(-104); assertEquals(t, LocalDate.of(2009, 7, 12)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 24).minusWeeks(-1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 8).minusWeeks(1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusWeeks_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(-1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusWeeks_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 7).minusWeeks(1); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_minusWeeks_invalidMaxMinusMax() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(Long.MAX_VALUE); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_minusWeeks_invalidMaxMinusMin() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(Long.MIN_VALUE); } - @Test(groups={"tck"}) + @Test public void test_minusDays_normal() { LocalDate t = TEST_2007_07_15.minusDays(1); assertEquals(t, LocalDate.of(2007, 7, 14)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overMonths() { LocalDate t = TEST_2007_07_15.minusDays(62); assertEquals(t, LocalDate.of(2007, 5, 14)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overYears() { LocalDate t = LocalDate.of(2008, 7, 16).minusDays(367); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(2).minusDays(365 + 366); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negative() { LocalDate t = TEST_2007_07_15.minusDays(-1); assertEquals(t, LocalDate.of(2007, 7, 16)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusDays(-169); assertEquals(t, LocalDate.of(2007, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusDays(-731); assertEquals(t, LocalDate.of(2009, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 30).minusDays(-1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusDays_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 2).minusDays(1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusDays_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(-1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusDays_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE); } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {date(2000, 1, 1), date(2000, 1, 1), DAYS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), WEEKS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), MONTHS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), YEARS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), DECADES, 0}, + {date(2000, 1, 1), date(2000, 1, 1), CENTURIES, 0}, + {date(2000, 1, 1), date(2000, 1, 1), MILLENNIA, 0}, + + {date(2000, 1, 15), date(2000, 2, 14), DAYS, 30}, + {date(2000, 1, 15), date(2000, 2, 15), DAYS, 31}, + {date(2000, 1, 15), date(2000, 2, 16), DAYS, 32}, + + {date(2000, 1, 15), date(2000, 2, 17), WEEKS, 4}, + {date(2000, 1, 15), date(2000, 2, 18), WEEKS, 4}, + {date(2000, 1, 15), date(2000, 2, 19), WEEKS, 5}, + {date(2000, 1, 15), date(2000, 2, 20), WEEKS, 5}, + + {date(2000, 1, 15), date(2000, 2, 14), MONTHS, 0}, + {date(2000, 1, 15), date(2000, 2, 15), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 2, 16), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 3, 14), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 3, 15), MONTHS, 2}, + {date(2000, 1, 15), date(2000, 3, 16), MONTHS, 2}, + + {date(2000, 1, 15), date(2001, 1, 14), YEARS, 0}, + {date(2000, 1, 15), date(2001, 1, 15), YEARS, 1}, + {date(2000, 1, 15), date(2001, 1, 16), YEARS, 1}, + {date(2000, 1, 15), date(2004, 1, 14), YEARS, 3}, + {date(2000, 1, 15), date(2004, 1, 15), YEARS, 4}, + {date(2000, 1, 15), date(2004, 1, 16), YEARS, 4}, + + {date(2000, 1, 15), date(2010, 1, 14), DECADES, 0}, + {date(2000, 1, 15), date(2010, 1, 15), DECADES, 1}, + + {date(2000, 1, 15), date(2100, 1, 14), CENTURIES, 0}, + {date(2000, 1, 15), date(2100, 1, 15), CENTURIES, 1}, + + {date(2000, 1, 15), date(3000, 1, 14), MILLENNIA, 0}, + {date(2000, 1, 15), date(3000, 1, 15), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { + long amount = date1.periodUntil(date2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { + long amount = date2.periodUntil(date1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2007_07_15.periodUntil(TEST_2007_07_15, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2007_07_15.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2007_07_15.periodUntil(TEST_2007_07_15, null); + } + + //----------------------------------------------------------------------- // periodUntil(ChronoLocalDate) //----------------------------------------------------------------------- @DataProvider(name="periodUntil") @@ -1733,155 +1821,170 @@ } //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); + String t = LocalDate.of(2010, 12, 3).format(f); + assertEquals(t, "2010 12 3"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalDate.of(2010, 12, 3).format(null); + } + + //----------------------------------------------------------------------- // atTime() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_LocalTime() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(LocalTime.of(11, 30)), LocalDateTime.of(2008, 6, 30, 11, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atTime_LocalTime_null() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime((LocalTime) null); } //------------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30), LocalDateTime.of(2008, 6, 30, 11, 30)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60); } - @Test(groups={"tck"}) + @Test public void test_atTime_int_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30, 40), LocalDateTime.of(2008, 6, 30, 11, 30, 40)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_secondTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_secondTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 60); } - @Test(groups={"tck"}) + @Test public void test_atTime_int_int_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30, 40, 50), LocalDateTime.of(2008, 6, 30, 11, 30, 40, 50)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_secondTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, -1, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_secondTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 60, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_nanoTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_nanoTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_OffsetTime() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(OffsetTime.of(11, 30, 0, 0, OFFSET_PONE)), OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atTime_OffsetTime_null() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime((OffsetTime) null); @@ -1929,7 +2032,7 @@ //----------------------------------------------------------------------- // toEpochDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochDay() { long date_0000_01_01 = -678941 - 40587; @@ -1954,7 +2057,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_LocalDate( LocalDate.of(Year.MIN_VALUE, 1, 1), @@ -2002,36 +2105,36 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2007_07_15.compareTo(null); } - @Test(groups={"tck"}) + @Test public void test_isBefore() { assertTrue(TEST_2007_07_15.isBefore(LocalDate.of(2007, 07, 16))); assertFalse(TEST_2007_07_15.isBefore(LocalDate.of(2007, 07, 14))); assertFalse(TEST_2007_07_15.isBefore(TEST_2007_07_15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2007_07_15.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2007_07_15.isAfter(null); } - @Test(groups={"tck"}) + @Test public void test_isAfter() { assertTrue(TEST_2007_07_15.isAfter(LocalDate.of(2007, 07, 14))); assertFalse(TEST_2007_07_15.isAfter(LocalDate.of(2007, 07, 16))); assertFalse(TEST_2007_07_15.isAfter(TEST_2007_07_15)); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalDate() { Comparable c = TEST_2007_07_15; @@ -2041,42 +2144,42 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates" , groups={"tck"}) + @Test(dataProvider="sampleDates" ) public void test_equals_true(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m, d); assertEquals(a.equals(b), true); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_year_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y + 1, m, d); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_month_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m + 1, d); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_day_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m, d + 1); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2007_07_15.equals(TEST_2007_07_15), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2007_07_15.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2007_07_15.equals(null), false); } @@ -2084,7 +2187,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); assertEquals(a.hashCode(), a.hashCode()); @@ -2111,26 +2214,15 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, int d, String expected) { LocalDate t = LocalDate.of(y, m, d); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); - String t = LocalDate.of(2010, 12, 3).toString(f); - assertEquals(t, "2010 12 3"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalDate.of(2010, 12, 3).toString(null); + private LocalDate date(int year, int month, int day) { + return LocalDate.of(year, month, day); } } --- old/test/java/time/tck/java/time/TCKLocalDateTime.java 2013-04-11 23:17:28.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKLocalDateTime.java 2013-04-11 23:17:27.000000000 -0700 @@ -70,7 +70,6 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -83,19 +82,30 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HALF_DAYS; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MICROS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MILLIS; +import static java.time.temporal.ChronoUnit.MINUTES; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.NANOS; import static java.time.temporal.ChronoUnit.SECONDS; +import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -108,6 +118,7 @@ import java.time.LocalTime; import java.time.Month; import java.time.OffsetDateTime; +import java.time.OffsetTime; import java.time.Year; import java.time.ZoneId; import java.time.ZoneOffset; @@ -118,7 +129,6 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -153,7 +163,7 @@ private Instant MAX_INSTANT; private Instant MIN_INSTANT; - @BeforeMethod(groups={"implementation","tck"}) + @BeforeMethod public void setUp() { MAX_DATE_TIME = LocalDateTime.MAX; MIN_DATE_TIME = LocalDateTime.MIN; @@ -195,7 +205,7 @@ ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -272,7 +282,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(timeOut=30000, groups={"tck"}) // TODO: remove when time zone loading is faster + @Test(timeOut=30000) // TODO: remove when time zone loading is faster public void now() { LocalDateTime expected = LocalDateTime.now(Clock.systemDefaultZone()); LocalDateTime test = LocalDateTime.now(); @@ -289,12 +299,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalDateTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDateTime expected = LocalDateTime.now(Clock.system(zone)); @@ -312,12 +322,12 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalDateTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -333,7 +343,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -349,7 +359,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -365,27 +375,27 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_maxYear() { Clock clock = Clock.fixed(MAX_INSTANT, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test, MAX_DATE_TIME); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooBig() { Clock clock = Clock.fixed(MAX_INSTANT.plusSeconds(24 * 60 * 60), ZoneOffset.UTC); LocalDateTime.now(clock); } - @Test(groups={"tck"}) + @Test public void now_Clock_minYear() { Clock clock = Clock.fixed(MIN_INSTANT, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test, MIN_DATE_TIME); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooLow() { Clock clock = Clock.fixed(MIN_INSTANT.minusNanos(1), ZoneOffset.UTC); LocalDateTime.now(clock); @@ -395,375 +405,375 @@ // of() factories //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_4intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30); check(dateTime, 2007, 7, 15, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_4intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_5intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40); check(dateTime, 2007, 7, 15, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30, 40); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_5intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_secondTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_secondTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_6intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, 987654321); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_6intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_secondTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, -1, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_secondTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 60, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_nanoTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_nanoTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_5ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30); check(dateTime, 2007, 7, 15, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_6ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30, 40); check(dateTime, 2007, 7, 15, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_secondTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_secondTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_7ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_secondTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, -1, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_secondTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 60, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_nanoTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_nanoTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDate_LocalTime() { LocalDateTime dateTime = LocalDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(12, 30, 40, 987654321)); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDate_LocalTime_nullLocalDate() { LocalDateTime.of(null, LocalTime.of(12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDate_LocalTime_nullLocalTime() { LocalDateTime.of(LocalDate.of(2007, 7, 15), null); } @@ -790,22 +800,22 @@ assertEquals(test, expected); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_instantTooBig() { LocalDateTime.ofInstant(Instant.MAX, OFFSET_PONE) ; } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_instantTooSmall() { LocalDateTime.ofInstant(Instant.MIN, OFFSET_PONE) ; } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullInstant() { LocalDateTime.ofInstant((Instant) null, ZONE_GAZA); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullZone() { LocalDateTime.ofInstant(Instant.EPOCH, (ZoneId) null); } @@ -813,7 +823,7 @@ //----------------------------------------------------------------------- // ofEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofEpochSecond_longOffset_afterEpoch() { LocalDateTime base = LocalDateTime.of(1970, 1, 1, 2, 0, 0, 500); for (int i = 0; i < 100000; i++) { @@ -822,7 +832,7 @@ } } - @Test(groups={"tck"}) + @Test public void factory_ofEpochSecond_longOffset_beforeEpoch() { LocalDateTime base = LocalDateTime.of(1970, 1, 1, 2, 0, 0, 500); for (int i = 0; i < 100000; i++) { @@ -831,27 +841,27 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_longOffset_tooBig() { LocalDateTime.ofEpochSecond(Long.MAX_VALUE, 500, OFFSET_PONE); // TODO: better test } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_longOffset_tooSmall() { LocalDateTime.ofEpochSecond(Long.MIN_VALUE, 500, OFFSET_PONE); // TODO: better test } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_badNanos_toBig() { LocalDateTime.ofEpochSecond(0, 1_000_000_000, OFFSET_PONE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_badNanos_toSmall() { LocalDateTime.ofEpochSecond(0, -1, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofEpochSecond_longOffset_nullOffset() { LocalDateTime.ofEpochSecond(0L, 500, null); } @@ -859,19 +869,19 @@ //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor() { LocalDateTime base = LocalDateTime.of(2007, 7, 15, 17, 30); assertEquals(LocalDateTime.from(base), base); assertEquals(LocalDateTime.from(ZonedDateTime.of(base, ZoneOffset.ofHours(2))), base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { LocalDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { LocalDateTime.from((TemporalAccessor) null); } @@ -879,7 +889,7 @@ //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_parse(int y, int month, int d, int h, int m, int s, int n, String text) { LocalDateTime t = LocalDateTime.parse(text); assertEquals(t.getYear(), y); @@ -891,17 +901,17 @@ assertEquals(t.getNano(), n); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { LocalDateTime.parse("2008-06-32T11:15"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { LocalDateTime.parse("2008-06-31T11:15"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { LocalDateTime.parse((String) null); } @@ -909,20 +919,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); LocalDateTime test = LocalDateTime.parse("2010 12 3 11 30 45", f); assertEquals(test, LocalDateTime.of(2010, 12, 3, 11, 30, 45)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); LocalDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalDateTime.parse("ANY", null); } @@ -970,13 +980,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15_12_30_40_987654321, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15_12_30_40_987654321, Queries.zoneId(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.precision(), ChronoUnit.NANOS}, - {TEST_2007_07_15_12_30_40_987654321, Queries.zone(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.offset(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.localDate(), LocalDate.of(2007, 7, 15)}, - {TEST_2007_07_15_12_30_40_987654321, Queries.localTime(), LocalTime.of(12, 30, 40, 987654321)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zoneId(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zone(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.offset(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localDate(), LocalDate.of(2007, 7, 15)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localTime(), LocalTime.of(12, 30, 40, 987654321)}, }; } @@ -1033,7 +1043,7 @@ //----------------------------------------------------------------------- // get*() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_get_dates(int y, int m, int d) { LocalDateTime a = LocalDateTime.of(y, m, d, 12, 30); assertEquals(a.getYear(), y); @@ -1041,7 +1051,7 @@ assertEquals(a.getDayOfMonth(), d); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_getDOY(int y, int m, int d) { LocalDateTime a = LocalDateTime.of(y, m, d, 12 ,30); int total = 0; @@ -1052,7 +1062,7 @@ assertEquals(a.getDayOfYear(), doy); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get_times(int h, int m, int s, int ns) { LocalDateTime a = LocalDateTime.of(TEST_2007_07_15_12_30_40_987654321.toLocalDate(), LocalTime.of(h, m, s, ns)); assertEquals(a.getHour(), h); @@ -1064,7 +1074,7 @@ //----------------------------------------------------------------------- // getDayOfWeek() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { @@ -1079,9 +1089,49 @@ } //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 23, 5, 0, 0), null}, + {LocalDateTime.of(2012, Month.MARCH, 4, 0, 0), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 0, 0), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), null}, + {LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, null}, + {LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, null}, + + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset.UTC), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), ZonedDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZONE_PARIS), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_PARIS), null}, + + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(LocalDateTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalDateTime sample = LocalDateTime.of(2012, 3, 4, 23, 5); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -1093,7 +1143,7 @@ assertEquals(TEST_2007_07_15_12_30_40_987654321.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2007_07_15_12_30_40_987654321.with((TemporalAdjuster) null); } @@ -1101,18 +1151,18 @@ //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withYear(2008); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_int_invalid() { TEST_2007_07_15_12_30_40_987654321.withYear(Year.MIN_VALUE - 1); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_adjustDay() { LocalDateTime t = LocalDateTime.of(2008, 2, 29, 12, 30).withYear(2007); LocalDateTime expected = LocalDateTime.of(2007, 2, 28, 12, 30); @@ -1122,18 +1172,18 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMonth(1); check(t, 2007, 1, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_int_invalid() { TEST_2007_07_15_12_30_40_987654321.withMonth(13); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_adjustDay() { LocalDateTime t = LocalDateTime.of(2007, 12, 31, 12, 30).withMonth(11); LocalDateTime expected = LocalDateTime.of(2007, 11, 30, 12, 30); @@ -1143,18 +1193,18 @@ //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfMonth(1); check(t, 2007, 7, 1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { LocalDateTime.of(2007, 11, 30, 12, 30).withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalidCombination() { LocalDateTime.of(2007, 11, 30, 12, 30).withDayOfMonth(31); } @@ -1162,18 +1212,18 @@ //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfYear(33); assertEquals(t, LocalDateTime.of(2007, 2, 2, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2007_07_15_12_30_40_987654321.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { TEST_2007_07_15_12_30_40_987654321.withDayOfYear(366); } @@ -1181,7 +1231,7 @@ //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 24; i++) { @@ -1190,12 +1240,12 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooLow() { TEST_2007_07_15_12_30_40_987654321.withHour(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooHigh() { TEST_2007_07_15_12_30_40_987654321.withHour(24); } @@ -1203,7 +1253,7 @@ //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -1212,12 +1262,12 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooLow() { TEST_2007_07_15_12_30_40_987654321.withMinute(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooHigh() { TEST_2007_07_15_12_30_40_987654321.withMinute(60); } @@ -1225,7 +1275,7 @@ //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -1234,12 +1284,12 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooLow() { TEST_2007_07_15_12_30_40_987654321.withSecond(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooHigh() { TEST_2007_07_15_12_30_40_987654321.withSecond(60); } @@ -1247,7 +1297,7 @@ //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; t = t.withNano(1); @@ -1260,12 +1310,12 @@ assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooLow() { TEST_2007_07_15_12_30_40_987654321.withNano(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooHigh() { TEST_2007_07_15_12_30_40_987654321.withNano(1000000000); } @@ -1273,14 +1323,14 @@ //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(NANOS), TEST_2007_07_15_12_30_40_987654321); assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(SECONDS), TEST_2007_07_15_12_30_40_987654321.withNano(0)); assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(DAYS), TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_2007_07_15_12_30_40_987654321.truncatedTo(null); } @@ -1322,29 +1372,29 @@ //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDateTime.of(2008, 2, 15, 12, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeDays() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDateTime.of(2007, 6, 20, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_2007_07_15_12_30_40_987654321.plus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooLarge() { LocalDateTime.of(Year.MAX_VALUE, 1, 1, 0, 0).plus(1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooSmall() { LocalDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0).plus(-1, ChronoUnit.YEARS); } @@ -1352,30 +1402,30 @@ //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(1); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusYears_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1); check(t, 2006, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusYears_int_adjustDay() { LocalDateTime t = createDateMidnight(2008, 2, 29).plusYears(1); check(t, 2009, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 1, 1).plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_int_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-1); } @@ -1383,54 +1433,54 @@ //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(1); check(t, 2007, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_overYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(25); check(t, 2009, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-1); check(t, 2007, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-7); check(t, 2006, 12, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-31); check(t, 2004, 12, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_adjustDayFromLeapYear() { LocalDateTime t = createDateMidnight(2008, 2, 29).plusMonths(12); check(t, 2009, 2, 28, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_adjustDayFromMonthLength() { LocalDateTime t = createDateMidnight(2007, 3, 31).plusMonths(1); check(t, 2007, 4, 30, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 1).plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusMonths(-1); } @@ -1470,7 +1520,7 @@ }; } - @Test(dataProvider="samplePlusWeeksSymmetry", groups={"tck"}) + @Test(dataProvider="samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDateTime reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDateTime t = reference.plusWeeks(weeks).plusWeeks(-weeks); @@ -1481,66 +1531,66 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(1); check(t, 2007, 7, 22, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(9); check(t, 2007, 9, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overYears() { LocalDateTime t = LocalDateTime.of(2006, 7, 16, 12, 30, 40, 987654321).plusWeeks(52); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1).plusWeeks(104); check(t, 2008, 7, 12, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-1); check(t, 2007, 7, 8, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-28); check(t, 2006, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-104); check(t, 2005, 7, 17, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 24).plusWeeks(1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 8).plusWeeks(-1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusWeeks_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 25).plusWeeks(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusWeeks_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 7).plusWeeks(-1); } @@ -1580,7 +1630,7 @@ }; } - @Test(dataProvider="samplePlusDaysSymmetry", groups={"tck"}) + @Test(dataProvider="samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDateTime reference) { for (int days = 0; days < 365 * 8; days++) { LocalDateTime t = reference.plusDays(days).plusDays(-days); @@ -1591,76 +1641,76 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusDays_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(1); check(t, 2007, 7, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(62); check(t, 2007, 9, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overYears() { LocalDateTime t = LocalDateTime.of(2006, 7, 14, 12, 30, 40, 987654321).plusDays(366); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1).plusDays(365 + 366); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-1); check(t, 2007, 7, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-196); check(t, 2006, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-730); check(t, 2005, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 30).plusDays(1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusDays_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 2).plusDays(-1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusDays_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).plusDays(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusDays_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusDays(-1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).plusDays(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusDays(Long.MIN_VALUE); } @@ -1668,7 +1718,7 @@ //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1685,7 +1735,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(3); @@ -1704,7 +1754,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromOne() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)); LocalDate d = base.toLocalDate().minusDays(3); @@ -1727,7 +1777,7 @@ //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1749,7 +1799,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(1); @@ -1768,7 +1818,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(24 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -1777,7 +1827,7 @@ //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1852,7 +1902,7 @@ }; } - @Test(dataProvider="plusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="plusSeconds_fromZero") public void test_plusSeconds_fromZero(int seconds, LocalDate date, int hour, int min, int sec) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.plusSeconds(seconds); @@ -1863,7 +1913,7 @@ assertEquals(sec, t.getSecond()); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -1872,7 +1922,7 @@ //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1956,7 +2006,7 @@ }; } - @Test(dataProvider="plusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="plusNanos_fromZero") public void test_plusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.plusNanos(nanoseconds); @@ -1968,7 +2018,7 @@ assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -2011,29 +2061,29 @@ //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDateTime.of(2006, 12, 15, 12, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeDays() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDateTime.of(2007, 8, 9, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_2007_07_15_12_30_40_987654321.minus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooLarge() { LocalDateTime.of(Year.MAX_VALUE, 1, 1, 0, 0).minus(-1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooSmall() { LocalDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0).minus(1, ChronoUnit.YEARS); } @@ -2041,30 +2091,30 @@ //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(1); check(t, 2006, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusYears_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(-1); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusYears_int_adjustDay() { LocalDateTime t = createDateMidnight(2008, 2, 29).minusYears(1); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 1, 1).minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusYears(1); } @@ -2072,54 +2122,54 @@ //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(1); check(t, 2007, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_overYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(25); check(t, 2005, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-1); check(t, 2007, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-7); check(t, 2008, 2, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-31); check(t, 2010, 2, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_adjustDayFromLeapYear() { LocalDateTime t = createDateMidnight(2008, 2, 29).minusMonths(12); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_adjustDayFromMonthLength() { LocalDateTime t = createDateMidnight(2007, 3, 31).minusMonths(1); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 1).minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusMonths(1); } @@ -2159,7 +2209,7 @@ }; } - @Test(dataProvider="sampleMinusWeeksSymmetry", groups={"tck"}) + @Test(dataProvider="sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDateTime reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDateTime t = reference.minusWeeks(weeks).minusWeeks(-weeks); @@ -2170,66 +2220,66 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(1); check(t, 2007, 7, 8, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(9); check(t, 2007, 5, 13, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overYears() { LocalDateTime t = LocalDateTime.of(2008, 7, 13, 12, 30, 40, 987654321).minusWeeks(52); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(-1).minusWeeks(104); check(t, 2006, 7, 18, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-1); check(t, 2007, 7, 22, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-28); check(t, 2008, 1, 27, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-104); check(t, 2009, 7, 12, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 24).minusWeeks(-1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 8).minusWeeks(1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusWeeks_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 25).minusWeeks(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusWeeks_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 7).minusWeeks(1); } @@ -2269,7 +2319,7 @@ }; } - @Test(dataProvider="sampleMinusDaysSymmetry", groups={"tck"}) + @Test(dataProvider="sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDateTime reference) { for (int days = 0; days < 365 * 8; days++) { LocalDateTime t = reference.minusDays(days).minusDays(-days); @@ -2280,76 +2330,76 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusDays_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(1); check(t, 2007, 7, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(62); check(t, 2007, 5, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overYears() { LocalDateTime t = LocalDateTime.of(2008, 7, 16, 12, 30, 40, 987654321).minusDays(367); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(2).minusDays(365 + 366); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-1); check(t, 2007, 7, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-169); check(t, 2007, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-731); check(t, 2009, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 30).minusDays(-1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusDays_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 2).minusDays(1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusDays_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).minusDays(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusDays_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusDays(1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE); } @@ -2357,7 +2407,7 @@ //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours_one() { LocalDateTime t =TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -2374,7 +2424,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().plusDays(2); @@ -2393,7 +2443,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromOne() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)); LocalDate d = base.toLocalDate().plusDays(2); @@ -2416,7 +2466,7 @@ //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2441,7 +2491,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(1); @@ -2460,7 +2510,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(24 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); @@ -2469,7 +2519,7 @@ //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2549,7 +2599,7 @@ }; } - @Test(dataProvider="minusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, LocalDate date, int hour, int min, int sec) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusSeconds(seconds); @@ -2563,7 +2613,7 @@ //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2654,7 +2704,7 @@ }; } - @Test(dataProvider="minusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); @@ -2667,15 +2717,193 @@ } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + // date only + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), DAYS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), WEEKS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), MONTHS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), YEARS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), DECADES, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), CENTURIES, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), MILLENNIA, 0}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 14), DAYS, 30}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 15), DAYS, 31}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 16), DAYS, 32}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 17), WEEKS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 18), WEEKS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 19), WEEKS, 5}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 20), WEEKS, 5}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 14), MONTHS, 0}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 15), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 16), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 14), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 15), MONTHS, 2}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 16), MONTHS, 2}, + + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 14), YEARS, 0}, + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 15), YEARS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 16), YEARS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 14), YEARS, 3}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 15), YEARS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 16), YEARS, 4}, + + {dtNoon(2000, 1, 15), dtNoon(2010, 1, 14), DECADES, 0}, + {dtNoon(2000, 1, 15), dtNoon(2010, 1, 15), DECADES, 1}, + + {dtNoon(2000, 1, 15), dtNoon(2100, 1, 14), CENTURIES, 0}, + {dtNoon(2000, 1, 15), dtNoon(2100, 1, 15), CENTURIES, 1}, + + {dtNoon(2000, 1, 15), dtNoon(3000, 1, 14), MILLENNIA, 0}, + {dtNoon(2000, 1, 15), dtNoon(3000, 1, 15), MILLENNIA, 1}, + + // time only + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), NANOS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MICROS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MILLIS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), SECONDS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MINUTES, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), HOURS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), HALF_DAYS, 0}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), NANOS, 2 * 3600 * 1_000_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MICROS, 2 * 3600 * 1_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MILLIS, 2 * 3600 * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), SECONDS, 2 * 3600}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MINUTES, 2 * 60}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), HOURS, 2}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), HALF_DAYS, 0}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), NANOS, 14 * 3600 * 1_000_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MICROS, 14 * 3600 * 1_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MILLIS, 14 * 3600 * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), SECONDS, 14 * 3600}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MINUTES, 14 * 60}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), HOURS, 14}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), HALF_DAYS, 1}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), NANOS, (2 * 3600 + 30 * 60 + 40) * 1_000_000_000L + 1500}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MICROS, (2 * 3600 + 30 * 60 + 40) * 1_000_000L + 1}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MILLIS, (2 * 3600 + 30 * 60 + 40) * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), SECONDS, 2 * 3600 + 30 * 60 + 40}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MINUTES, 2 * 60 + 30}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), HOURS, 2}, + + // combinations + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), NANOS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), NANOS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), NANOS, 1}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 39, 500), SECONDS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 39, 501), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 41, 499), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 41, 500), SECONDS, 1}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), NANOS, -1 + 86400_000_000_000L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), NANOS, 0 + 86400_000_000_000L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), NANOS, 1 + 86400_000_000_000L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 499), SECONDS, -2 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 500), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 501), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 41, 499), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 41, 500), SECONDS, 1 + 86400L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 499), MINUTES, -2 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 500), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 501), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 31, 40, 499), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 31, 40, 500), MINUTES, 1 + 24 * 60L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 499), HOURS, -2 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 500), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 501), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 13, 30, 40, 499), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 13, 30, 40, 500), HOURS, 1 + 24L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 499), DAYS, -2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 500), DAYS, -2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 501), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 499), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 500), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 501), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 499), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 500), DAYS, 2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 501), DAYS, 2}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) { + long amount = dt1.periodUntil(dt2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) { + long amount = dt2.periodUntil(dt1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2007_07_15_12_30_40_987654321.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2007_07_15_12_30_40_987654321.periodUntil(TEST_2007_07_15_12_30_40_987654321, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = LocalDateTime.of(2010, 12, 3, 11, 30, 45).format(f); + assertEquals(t, "2010 12 3 11 30 45"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalDateTime.of(2010, 12, 3, 11, 30, 45).format(null); + } + + //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atOffset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atOffset(OFFSET_PTWO), OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atOffset_nullZoneOffset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); t.atOffset((ZoneOffset) null); @@ -2684,34 +2912,34 @@ //----------------------------------------------------------------------- // atZone() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZone() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atZone(ZONE_PARIS), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS)); } - @Test(groups={"tck"}) + @Test public void test_atZone_Offset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atZone(OFFSET_PTWO), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstGap() { LocalDateTime t = LocalDateTime.of(2007, 4, 1, 0, 0); assertEquals(t.atZone(ZONE_GAZA), ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlap() { LocalDateTime t = LocalDateTime.of(2007, 10, 28, 2, 30); assertEquals(t.atZone(ZONE_PARIS), ZonedDateTime.ofStrict(LocalDateTime.of(2007, 10, 28, 2, 30), OFFSET_PTWO, ZONE_PARIS)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZone_nullTimeZone() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); t.atZone((ZoneId) null); @@ -2720,7 +2948,7 @@ //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { for (int i = -5; i < 5; i++) { ZoneOffset offset = ZoneOffset.ofHours(i); @@ -2731,7 +2959,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { for (int i = 0; i < 100000; i++) { LocalDateTime a = LocalDateTime.of(1970, 1, 1, 0, 0).minusSeconds(i); @@ -2742,22 +2970,22 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { test_comparisons_LocalDateTime( - LocalDate.of(Year.MIN_VALUE, 1, 1), - LocalDate.of(Year.MIN_VALUE, 12, 31), - LocalDate.of(-1, 1, 1), - LocalDate.of(-1, 12, 31), - LocalDate.of(0, 1, 1), - LocalDate.of(0, 12, 31), - LocalDate.of(1, 1, 1), - LocalDate.of(1, 12, 31), - LocalDate.of(2008, 1, 1), - LocalDate.of(2008, 2, 29), - LocalDate.of(2008, 12, 31), - LocalDate.of(Year.MAX_VALUE, 1, 1), - LocalDate.of(Year.MAX_VALUE, 12, 31) + LocalDate.of(Year.MIN_VALUE, 1, 1), + LocalDate.of(Year.MIN_VALUE, 12, 31), + LocalDate.of(-1, 1, 1), + LocalDate.of(-1, 12, 31), + LocalDate.of(0, 1, 1), + LocalDate.of(0, 12, 31), + LocalDate.of(1, 1, 1), + LocalDate.of(1, 12, 31), + LocalDate.of(2008, 1, 1), + LocalDate.of(2008, 2, 29), + LocalDate.of(2008, 12, 31), + LocalDate.of(Year.MAX_VALUE, 1, 1), + LocalDate.of(Year.MAX_VALUE, 12, 31) ); } @@ -2823,22 +3051,22 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.isAfter(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalDateTime() { Comparable c = TEST_2007_07_15_12_30_40_987654321; @@ -2883,73 +3111,73 @@ }; } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_true(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s, n); assertTrue(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_year_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y + 1, m, d, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_month_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m + 1, d, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_day_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d + 1, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_hour_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h + 1, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_minute_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi + 1, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_second_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s + 1, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_nano_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s, n + 1); assertFalse(a.equals(b)); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals(TEST_2007_07_15_12_30_40_987654321), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals("2007-07-15T12:30:40.987654321"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals(null), false); } @@ -2957,7 +3185,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_hashCode(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); assertEquals(a.hashCode(), a.hashCode()); @@ -2979,26 +3207,23 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, int d, int h, int mi, int s, int n, String expected) { LocalDateTime t = LocalDateTime.of(y, m, d, h, mi, s, n); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = LocalDateTime.of(2010, 12, 3, 11, 30, 45).toString(f); - assertEquals(t, "2010 12 3 11 30 45"); + private LocalDateTime dtNoon(int year, int month, int day) { + return LocalDateTime.of(year, month, day, 12, 0); + } + + private LocalDateTime dtEpoch(int hour, int min, int sec, int nano) { + return LocalDateTime.of(1970, 1, 1, hour, min, sec, nano); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalDateTime.of(2010, 12, 3, 11, 30, 45).toString(null); + private LocalDateTime dt(int year, int month, int day, int hour, int min, int sec, int nano) { + return LocalDateTime.of(year, month, day, hour, min, sec, nano); } } --- old/test/java/time/tck/java/time/TCKLocalTime.java 2013-04-11 23:17:28.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKLocalTime.java 2013-04-11 23:17:28.000000000 -0700 @@ -76,6 +76,7 @@ import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.FOREVER; +import static java.time.temporal.ChronoUnit.HALF_DAYS; import static java.time.temporal.ChronoUnit.HOURS; import static java.time.temporal.ChronoUnit.MICROS; import static java.time.temporal.ChronoUnit.MILLIS; @@ -99,16 +100,17 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.Period; import java.time.ZoneId; import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -116,6 +118,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; @@ -133,6 +136,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); private LocalTime TEST_12_30_40_987654321; @@ -142,7 +146,7 @@ INVALID_UNITS = (TemporalUnit[]) set.toArray(new TemporalUnit[set.size()]); } - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_12_30_40_987654321 = LocalTime.of(12, 30, 40, 987654321); } @@ -258,7 +262,7 @@ //----------------------------------------------------------------------- // constants //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDNIGHT() { check(LocalTime.MIDNIGHT, 0, 0, 0, 0); } @@ -281,7 +285,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { LocalTime expected = LocalTime.now(Clock.systemDefaultZone()); LocalTime test = LocalTime.now(); @@ -292,12 +296,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalTime expected = LocalTime.now(Clock.system(zone)); @@ -315,12 +319,12 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -333,7 +337,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -347,7 +351,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_max() { Clock clock = Clock.fixed(Instant.MAX, ZoneOffset.UTC); LocalTime test = LocalTime.now(clock); @@ -357,7 +361,7 @@ assertEquals(test.getNano(), 999_999_999); } - @Test(groups={"tck"}) + @Test public void now_Clock_min() { Clock clock = Clock.fixed(Instant.MIN, ZoneOffset.UTC); LocalTime test = LocalTime.now(clock); @@ -370,71 +374,71 @@ //----------------------------------------------------------------------- // of() factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_2ints() { LocalTime test = LocalTime.of(12, 30); check(test, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_hourTooLow() { LocalTime.of(-1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_hourTooHigh() { LocalTime.of(24, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_minuteTooLow() { LocalTime.of(0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_minuteTooHigh() { LocalTime.of(0, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_3ints() { LocalTime test = LocalTime.of(12, 30, 40); check(test, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_hourTooLow() { LocalTime.of(-1, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_hourTooHigh() { LocalTime.of(24, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_minuteTooLow() { LocalTime.of(0, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_minuteTooHigh() { LocalTime.of(0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_secondTooLow() { LocalTime.of(0, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_secondTooHigh() { LocalTime.of(0, 0, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_4ints() { LocalTime test = LocalTime.of(12, 30, 40, 987654321); check(test, 12, 30, 40, 987654321); @@ -442,42 +446,42 @@ check(test, 12, 0, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_hourTooLow() { LocalTime.of(-1, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_hourTooHigh() { LocalTime.of(24, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_minuteTooLow() { LocalTime.of(0, -1, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_minuteTooHigh() { LocalTime.of(0, 60, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_secondTooLow() { LocalTime.of(0, 0, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_secondTooHigh() { LocalTime.of(0, 0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_nanoTooLow() { LocalTime.of(0, 0, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_nanoTooHigh() { LocalTime.of(0, 0, 0, 1000000000); } @@ -485,18 +489,18 @@ //----------------------------------------------------------------------- // ofSecondOfDay(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofSecondOfDay() { LocalTime localTime = LocalTime.ofSecondOfDay(2 * 60 * 60 + 17 * 60 + 23); check(localTime, 2, 17, 23, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofSecondOfDay_tooLow() { LocalTime.ofSecondOfDay(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofSecondOfDay_tooHigh() { LocalTime.ofSecondOfDay(24 * 60 * 60); } @@ -504,18 +508,18 @@ //----------------------------------------------------------------------- // ofNanoOfDay(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofNanoOfDay() { LocalTime localTime = LocalTime.ofNanoOfDay(60 * 60 * 1000000000L + 17); check(localTime, 1, 0, 0, 17); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofNanoOfDay_tooLow() { LocalTime.ofNanoOfDay(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofNanoOfDay_tooHigh() { LocalTime.ofNanoOfDay(24 * 60 * 60 * 1000000000L); } @@ -523,18 +527,18 @@ //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor() { assertEquals(LocalTime.from(LocalTime.of(17, 30)), LocalTime.of(17, 30)); assertEquals(LocalTime.from(LocalDateTime.of(2012, 5, 1, 17, 30)), LocalTime.of(17, 30)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { LocalTime.from(LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { LocalTime.from((TemporalAccessor) null); } @@ -542,7 +546,7 @@ //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider = "sampleToString", groups={"tck"}) + @Test(dataProvider = "sampleToString") public void factory_parse_validText(int h, int m, int s, int n, String parsable) { LocalTime t = LocalTime.parse(parsable); assertNotNull(t, parsable); @@ -567,29 +571,29 @@ }; } - @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { LocalTime.parse(unparsable); } //-----------------------------------------------------------------------s - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalHour() { LocalTime.parse("25:00"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalMinute() { LocalTime.parse("12:60"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalSecond() { LocalTime.parse("12:12:60"); } //-----------------------------------------------------------------------s - @Test(expectedExceptions = {NullPointerException.class}, groups={"tck"}) + @Test(expectedExceptions = {NullPointerException.class}) public void factory_parse_nullTest() { LocalTime.parse((String) null); } @@ -597,20 +601,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); LocalTime test = LocalTime.parse("14 30 40", f); assertEquals(test, LocalTime.of(14, 30, 40)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); LocalTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalTime.parse("ANY", null); } @@ -656,13 +660,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12_30_40_987654321, Queries.chronology(), null}, - {TEST_12_30_40_987654321, Queries.zoneId(), null}, - {TEST_12_30_40_987654321, Queries.precision(), ChronoUnit.NANOS}, - {TEST_12_30_40_987654321, Queries.zone(), null}, - {TEST_12_30_40_987654321, Queries.offset(), null}, - {TEST_12_30_40_987654321, Queries.localDate(), null}, - {TEST_12_30_40_987654321, Queries.localTime(), TEST_12_30_40_987654321}, + {TEST_12_30_40_987654321, TemporalQuery.chronology(), null}, + {TEST_12_30_40_987654321, TemporalQuery.zoneId(), null}, + {TEST_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_12_30_40_987654321, TemporalQuery.zone(), null}, + {TEST_12_30_40_987654321, TemporalQuery.offset(), null}, + {TEST_12_30_40_987654321, TemporalQuery.localDate(), null}, + {TEST_12_30_40_987654321, TemporalQuery.localTime(), TEST_12_30_40_987654321}, }; } @@ -707,7 +711,7 @@ } //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int h, int m, int s, int ns) { LocalTime a = LocalTime.of(h, m, s, ns); assertEquals(a.getHour(), h); @@ -717,9 +721,53 @@ } //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {LocalTime.of(23, 5), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 0, 0), null}, + {LocalTime.of(23, 5, 20), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 0), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), LocalTime.of(23, 59, 59, 999999999), null}, + {LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null}, + {LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), LocalTime.of(12, 0, 0), null}, + {LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null}, + + {LocalTime.of(23, 5), LocalDateTime.of(2210, 2, 2, 1, 1), LocalDateTime.of(2210, 2, 2, 23, 5), null}, + {LocalTime.of(23, 5), OffsetTime.of(1, 1, 0, 0, OFFSET_PTWO), OffsetTime.of(23, 5, 0, 0, OFFSET_PTWO), null}, + {LocalTime.of(23, 5), OffsetDateTime.of(2210, 2, 2, 1, 1, 0, 0, OFFSET_PTWO), OffsetDateTime.of(2210, 2, 2, 23, 5, 0, 0, OFFSET_PTWO), null}, + {LocalTime.of(23, 5), ZonedDateTime.of(2210, 2, 2, 1, 1, 0, 0, ZONE_PARIS), ZonedDateTime.of(2210, 2, 2, 23, 5, 0, 0, ZONE_PARIS), null}, + + {LocalTime.of(23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {LocalTime.of(23, 5), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(LocalTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalTime sample = LocalTime.of(23, 5); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -731,7 +779,7 @@ assertEquals(TEST_12_30_40_987654321.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_12_30_40_987654321.with((TemporalAdjuster) null); } @@ -739,7 +787,7 @@ //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 24; i++) { @@ -748,30 +796,30 @@ } } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withHour(12); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withHour_toMidnight_equal() { LocalTime t = LocalTime.of(1, 0).withHour(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withHour_toMidday_equal() { LocalTime t = LocalTime.of(1, 0).withHour(12); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooLow() { TEST_12_30_40_987654321.withHour(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooHigh() { TEST_12_30_40_987654321.withHour(24); } @@ -779,7 +827,7 @@ //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -788,30 +836,30 @@ } } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withMinute(30); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withMinute_toMidnight_equal() { LocalTime t = LocalTime.of(0, 1).withMinute(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withMinute_toMidday_equals() { LocalTime t = LocalTime.of(12, 1).withMinute(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooLow() { TEST_12_30_40_987654321.withMinute(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooHigh() { TEST_12_30_40_987654321.withMinute(60); } @@ -819,7 +867,7 @@ //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -828,30 +876,30 @@ } } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withSecond(40); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withSecond_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 1).withSecond(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withSecond_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 1).withSecond(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooLow() { TEST_12_30_40_987654321.withSecond(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooHigh() { TEST_12_30_40_987654321.withSecond(60); } @@ -859,7 +907,7 @@ //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { LocalTime t = TEST_12_30_40_987654321; t = t.withNano(1); @@ -872,30 +920,30 @@ assertEquals(t.getNano(), 999999999); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withNano(987654321); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 0, 1).withNano(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 0, 1).withNano(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooLow() { TEST_12_30_40_987654321.withNano(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooHigh() { TEST_12_30_40_987654321.withNano(1000000000); } @@ -974,7 +1022,7 @@ }; } - @Test(groups={"tck"}, dataProvider="truncatedToValid") + @Test(dataProvider="truncatedToValid") public void test_truncatedTo_valid(LocalTime input, TemporalUnit unit, LocalTime expected) { assertEquals(input.truncatedTo(unit), expected); } @@ -989,12 +1037,12 @@ }; } - @Test(groups={"tck"}, dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) public void test_truncatedTo_invalid(LocalTime input, TemporalUnit unit) { input.truncatedTo(unit); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_12_30_40_987654321.truncatedTo(null); } @@ -1044,25 +1092,25 @@ //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveHours() { LocalTime t = TEST_12_30_40_987654321.plus(7, ChronoUnit.HOURS); assertEquals(t, LocalTime.of(19, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeMinutes() { LocalTime t = TEST_12_30_40_987654321.plus(-25, ChronoUnit.MINUTES); assertEquals(t, LocalTime.of(12, 5, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_zero() { LocalTime t = TEST_12_30_40_987654321.plus(0, ChronoUnit.MINUTES); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_invalidUnit() { for (TemporalUnit unit : INVALID_UNITS) { try { @@ -1074,7 +1122,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_multiples() { assertEquals(TEST_12_30_40_987654321.plus(0, DAYS), TEST_12_30_40_987654321); assertEquals(TEST_12_30_40_987654321.plus(1, DAYS), TEST_12_30_40_987654321); @@ -1082,7 +1130,7 @@ assertEquals(TEST_12_30_40_987654321.plus(-3, DAYS), TEST_12_30_40_987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_12_30_40_987654321.plus(1, (TemporalUnit) null); } @@ -1090,7 +1138,7 @@ //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours_one() { LocalTime t = LocalTime.MIDNIGHT; for (int i = 0; i < 50; i++) { @@ -1099,7 +1147,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromZero() { LocalTime base = LocalTime.MIDNIGHT; for (int i = -50; i < 50; i++) { @@ -1108,7 +1156,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromOne() { LocalTime base = LocalTime.of(1, 0); for (int i = -50; i < 50; i++) { @@ -1117,25 +1165,25 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusHours_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusHours(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusHours_toMidnight_equal() { LocalTime t = LocalTime.of(23, 0).plusHours(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusHours_toMidday_equal() { LocalTime t = LocalTime.of(11, 0).plusHours(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_plusHours_big() { LocalTime t = LocalTime.of(2, 30).plusHours(Long.MAX_VALUE); int hours = (int) (Long.MAX_VALUE % 24L); @@ -1145,7 +1193,7 @@ //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1162,7 +1210,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_fromZero() { LocalTime base = LocalTime.MIDNIGHT; int hour; @@ -1187,31 +1235,31 @@ } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusMinutes(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusMinutes(24 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59).plusMinutes(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_toMidday_equal() { LocalTime t = LocalTime.of(11, 59).plusMinutes(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_big() { LocalTime t = LocalTime.of(2, 30).plusMinutes(Long.MAX_VALUE); int mins = (int) (Long.MAX_VALUE % (24L * 60L)); @@ -1221,7 +1269,7 @@ //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1285,7 +1333,7 @@ }; } - @Test(dataProvider="plusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="plusSeconds_fromZero") public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.plusSeconds(seconds); @@ -1295,25 +1343,25 @@ assertEquals(sec, t.getSecond()); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusSeconds(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59, 59).plusSeconds(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_toMidday_equal() { LocalTime t = LocalTime.of(11, 59, 59).plusSeconds(1); assertEquals(t, LocalTime.NOON); @@ -1322,7 +1370,7 @@ //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos_halfABillion() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1398,7 +1446,7 @@ }; } - @Test(dataProvider="plusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="plusNanos_fromZero") public void test_plusNanos_fromZero(long nanoseconds, int hour, int min, int sec, int nanos) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.plusNanos(nanoseconds); @@ -1409,25 +1457,25 @@ assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusNanos(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59, 59, 999999999).plusNanos(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_toMidday_equal() { LocalTime t = LocalTime.of(11, 59, 59, 999999999).plusNanos(1); assertEquals(t, LocalTime.NOON); @@ -1478,25 +1526,25 @@ //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveHours() { LocalTime t = TEST_12_30_40_987654321.minus(7, ChronoUnit.HOURS); assertEquals(t, LocalTime.of(5, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeMinutes() { LocalTime t = TEST_12_30_40_987654321.minus(-25, ChronoUnit.MINUTES); assertEquals(t, LocalTime.of(12, 55, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_zero() { LocalTime t = TEST_12_30_40_987654321.minus(0, ChronoUnit.MINUTES); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_invalidUnit() { for (TemporalUnit unit : INVALID_UNITS) { try { @@ -1508,7 +1556,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_long_multiples() { assertEquals(TEST_12_30_40_987654321.minus(0, DAYS), TEST_12_30_40_987654321); assertEquals(TEST_12_30_40_987654321.minus(1, DAYS), TEST_12_30_40_987654321); @@ -1516,7 +1564,7 @@ assertEquals(TEST_12_30_40_987654321.minus(-3, DAYS), TEST_12_30_40_987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_12_30_40_987654321.minus(1, (TemporalUnit) null); } @@ -1524,7 +1572,7 @@ //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours_one() { LocalTime t = LocalTime.MIDNIGHT; for (int i = 0; i < 50; i++) { @@ -1533,7 +1581,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromZero() { LocalTime base = LocalTime.MIDNIGHT; for (int i = -50; i < 50; i++) { @@ -1542,7 +1590,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromOne() { LocalTime base = LocalTime.of(1, 0); for (int i = -50; i < 50; i++) { @@ -1551,25 +1599,25 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusHours_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusHours(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusHours_toMidnight_equal() { LocalTime t = LocalTime.of(1, 0).minusHours(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusHours_toMidday_equal() { LocalTime t = LocalTime.of(13, 0).minusHours(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusHours_big() { LocalTime t = LocalTime.of(2, 30).minusHours(Long.MAX_VALUE); int hours = (int) (Long.MAX_VALUE % 24L); @@ -1579,7 +1627,7 @@ //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1600,7 +1648,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_fromZero() { LocalTime base = LocalTime.MIDNIGHT; int hour = 22; @@ -1623,31 +1671,31 @@ } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusMinutes(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusMinutes(24 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_toMidnight_equal() { LocalTime t = LocalTime.of(0, 1).minusMinutes(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_toMidday_equals() { LocalTime t = LocalTime.of(12, 1).minusMinutes(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_big() { LocalTime t = LocalTime.of(2, 30).minusMinutes(Long.MAX_VALUE); int mins = (int) (Long.MAX_VALUE % (24L * 60L)); @@ -1657,7 +1705,7 @@ //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1726,7 +1774,7 @@ }; } - @Test(dataProvider="minusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusSeconds(seconds); @@ -1736,31 +1784,31 @@ assertEquals(t.getSecond(), sec); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusSeconds(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusSeconds(24 * 60 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 1).minusSeconds(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 1).minusSeconds(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_big() { LocalTime t = LocalTime.of(2, 30).minusSeconds(Long.MAX_VALUE); int secs = (int) (Long.MAX_VALUE % (24L * 60L * 60L)); @@ -1770,7 +1818,7 @@ //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos_halfABillion() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1854,7 +1902,7 @@ }; } - @Test(dataProvider="minusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, int hour, int min, int sec, int nanos) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusNanos(nanoseconds); @@ -1865,40 +1913,121 @@ assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusNanos(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 0, 1).minusNanos(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 0, 1).minusNanos(1); assertEquals(t, LocalTime.NOON); } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {time(0, 0, 0, 0), time(0, 0, 0, 0), NANOS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MICROS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MILLIS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), SECONDS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MINUTES, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), HOURS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), HALF_DAYS, 0}, + + {time(0, 0, 0, 0), time(2, 0, 0, 0), NANOS, 2 * 3600 * 1_000_000_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MICROS, 2 * 3600 * 1_000_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MILLIS, 2 * 3600 * 1_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), SECONDS, 2 * 3600}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MINUTES, 2 * 60}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), HOURS, 2}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), HALF_DAYS, 0}, + + {time(0, 0, 0, 0), time(14, 0, 0, 0), NANOS, 14 * 3600 * 1_000_000_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MICROS, 14 * 3600 * 1_000_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MILLIS, 14 * 3600 * 1_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), SECONDS, 14 * 3600}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MINUTES, 14 * 60}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), HOURS, 14}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), HALF_DAYS, 1}, + + {time(0, 0, 0, 0), time(2, 30, 40, 1500), NANOS, (2 * 3600 + 30 * 60 + 40) * 1_000_000_000L + 1500}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MICROS, (2 * 3600 + 30 * 60 + 40) * 1_000_000L + 1}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MILLIS, (2 * 3600 + 30 * 60 + 40) * 1_000L}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), SECONDS, 2 * 3600 + 30 * 60 + 40}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MINUTES, 2 * 60 + 30}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), HOURS, 2}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalTime time1, LocalTime time2, TemporalUnit unit, long expected) { + long amount = time1.periodUntil(time2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalTime time1, LocalTime time2, TemporalUnit unit, long expected) { + long amount = time2.periodUntil(time1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_12_30_40_987654321.periodUntil(TEST_12_30_40_987654321, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_12_30_40_987654321.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_12_30_40_987654321.periodUntil(TEST_12_30_40_987654321, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); + String t = LocalTime.of(11, 30, 45).format(f); + assertEquals(t, "11 30 45"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalTime.of(11, 30, 45).format(null); + } + + //----------------------------------------------------------------------- // atDate() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atDate() { LocalTime t = LocalTime.of(11, 30); assertEquals(t.atDate(LocalDate.of(2012, 6, 30)), LocalDateTime.of(2012, 6, 30, 11, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atDate_nullDate() { TEST_12_30_40_987654321.atDate((LocalDate) null); } @@ -1906,13 +2035,13 @@ //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atOffset() { LocalTime t = LocalTime.of(11, 30); assertEquals(t.atOffset(OFFSET_PTWO), OffsetTime.of(LocalTime.of(11, 30), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atOffset_nullZoneOffset() { LocalTime t = LocalTime.of(11, 30); t.atOffset((ZoneOffset) null); @@ -1921,7 +2050,7 @@ //----------------------------------------------------------------------- // toSecondOfDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toSecondOfDay() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { @@ -1930,7 +2059,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_toSecondOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { @@ -1942,7 +2071,7 @@ //----------------------------------------------------------------------- // toNanoOfDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toNanoOfDay() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 1000000; i++) { @@ -1956,7 +2085,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_toNanoOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 1000000; i++) { @@ -1973,7 +2102,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_LocalTime( LocalTime.MIDNIGHT, @@ -2028,22 +2157,22 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_12_30_40_987654321.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_12_30_40_987654321.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_12_30_40_987654321.isAfter(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalTime() { Comparable c = TEST_12_30_40_987654321; @@ -2053,48 +2182,48 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n); assertEquals(a.equals(b), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h + 1, m, s, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m + 1, s, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s + 1, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n + 1); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_12_30_40_987654321.equals(TEST_12_30_40_987654321), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_12_30_40_987654321.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_12_30_40_987654321.equals(null), false); } @@ -2102,35 +2231,35 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_same(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n); assertEquals(a.hashCode(), b.hashCode()); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_hour_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h + 1, m, s, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_minute_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m + 1, s, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_second_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s + 1, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_nano_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n + 1); @@ -2172,26 +2301,14 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int h, int m, int s, int n, String expected) { LocalTime t = LocalTime.of(h, m, s, n); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); - String t = LocalTime.of(11, 30, 45).toString(f); - assertEquals(t, "11 30 45"); + private LocalTime time(int hour, int min, int sec, int nano) { + return LocalTime.of(hour, min, sec, nano); } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalTime.of(11, 30, 45).toString(null); - } - } --- old/test/java/time/tck/java/time/TCKMonth.java 2013-04-11 23:17:29.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKMonth.java 2013-04-11 23:17:29.000000000 -0700 @@ -71,7 +71,6 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -117,7 +116,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = 1; i <= MAX_LENGTH; i++) { Month test = Month.of(i); @@ -125,28 +124,28 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooLow() { Month.of(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooHigh() { Month.of(13); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(Month.from(LocalDate.of(2011, 6, 6)), Month.JUNE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { Month.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { Month.from((TemporalAccessor) null); } @@ -170,13 +169,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {Month.JUNE, Queries.chronology(), IsoChronology.INSTANCE}, - {Month.JUNE, Queries.zoneId(), null}, - {Month.JUNE, Queries.precision(), ChronoUnit.MONTHS}, - {Month.JUNE, Queries.zone(), null}, - {Month.JUNE, Queries.offset(), null}, - {Month.JUNE, Queries.localDate(), null}, - {Month.JUNE, Queries.localTime(), null}, + {Month.JUNE, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {Month.JUNE, TemporalQuery.zoneId(), null}, + {Month.JUNE, TemporalQuery.precision(), ChronoUnit.MONTHS}, + {Month.JUNE, TemporalQuery.zone(), null}, + {Month.JUNE, TemporalQuery.offset(), null}, + {Month.JUNE, TemporalQuery.localDate(), null}, + {Month.JUNE, TemporalQuery.localTime(), null}, }; } @@ -198,17 +197,17 @@ //----------------------------------------------------------------------- // getText() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getText() { assertEquals(Month.JANUARY.getDisplayName(TextStyle.SHORT, Locale.US), "Jan"); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullStyle() { Month.JANUARY.getDisplayName(null, Locale.US); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullLocale() { Month.JANUARY.getDisplayName(TextStyle.FULL, null); } @@ -275,7 +274,7 @@ }; } - @Test(dataProvider="plus", groups={"tck"}) + @Test(dataProvider="plus") public void test_plus_long(int base, long amount, int expected) { assertEquals(Month.of(base).plus(amount), Month.of(expected)); } @@ -316,7 +315,7 @@ }; } - @Test(dataProvider="minus", groups={"tck"}) + @Test(dataProvider="minus") public void test_minus_long(int base, long amount, int expected) { assertEquals(Month.of(base).minus(amount), Month.of(expected)); } @@ -324,7 +323,7 @@ //----------------------------------------------------------------------- // length(boolean) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_length_boolean_notLeapYear() { assertEquals(Month.JANUARY.length(false), 31); assertEquals(Month.FEBRUARY.length(false), 28); @@ -340,7 +339,7 @@ assertEquals(Month.DECEMBER.length(false), 31); } - @Test(groups={"tck"}) + @Test public void test_length_boolean_leapYear() { assertEquals(Month.JANUARY.length(true), 31); assertEquals(Month.FEBRUARY.length(true), 29); @@ -359,7 +358,7 @@ //----------------------------------------------------------------------- // minLength() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minLength() { assertEquals(Month.JANUARY.minLength(), 31); assertEquals(Month.FEBRUARY.minLength(), 28); @@ -378,7 +377,7 @@ //----------------------------------------------------------------------- // maxLength() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_maxLength() { assertEquals(Month.JANUARY.maxLength(), 31); assertEquals(Month.FEBRUARY.maxLength(), 29); @@ -397,7 +396,7 @@ //----------------------------------------------------------------------- // firstDayOfYear(boolean) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_notLeapYear() { assertEquals(Month.JANUARY.firstDayOfYear(false), 1); assertEquals(Month.FEBRUARY.firstDayOfYear(false), 1 + 31); @@ -413,7 +412,7 @@ assertEquals(Month.DECEMBER.firstDayOfYear(false), 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_leapYear() { assertEquals(Month.JANUARY.firstDayOfYear(true), 1); assertEquals(Month.FEBRUARY.firstDayOfYear(true), 1 + 31); @@ -432,7 +431,7 @@ //----------------------------------------------------------------------- // firstMonthOfQuarter() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_firstMonthOfQuarter() { assertEquals(Month.JANUARY.firstMonthOfQuarter(), Month.JANUARY); assertEquals(Month.FEBRUARY.firstMonthOfQuarter(), Month.JANUARY); @@ -451,7 +450,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { assertEquals(Month.JANUARY.toString(), "JANUARY"); assertEquals(Month.FEBRUARY.toString(), "FEBRUARY"); @@ -470,7 +469,7 @@ //----------------------------------------------------------------------- // generated methods //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_enum() { assertEquals(Month.valueOf("JANUARY"), Month.JANUARY); assertEquals(Month.values()[0], Month.JANUARY); --- old/test/java/time/tck/java/time/TCKMonthDay.java 2013-04-11 23:17:30.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKMonthDay.java 2013-04-11 23:17:30.000000000 -0700 @@ -84,7 +84,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -106,7 +105,7 @@ private MonthDay TEST_07_15; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -164,7 +163,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { MonthDay expected = MonthDay.now(Clock.systemDefaultZone()); MonthDay test = MonthDay.now(); @@ -181,12 +180,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { MonthDay.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); MonthDay expected = MonthDay.now(Clock.system(zone)); @@ -204,7 +203,7 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -213,71 +212,71 @@ assertEquals(test.getDayOfMonth(), 31); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { MonthDay.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intMonth() { assertEquals(TEST_07_15, MonthDay.of(Month.JULY, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intMonth_dayTooLow() { MonthDay.of(Month.JANUARY, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intMonth_dayTooHigh() { MonthDay.of(Month.JANUARY, 32); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_intMonth_nullMonth() { MonthDay.of(null, 15); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ints() { check(TEST_07_15, 7, 15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooLow() { MonthDay.of(1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooHigh() { MonthDay.of(1, 32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooLow() { MonthDay.of(0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooHigh() { MonthDay.of(13, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(MonthDay.from(LocalDate.of(2007, 7, 15)), TEST_07_15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { MonthDay.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { MonthDay.from((TemporalAccessor) null); } @@ -315,7 +314,7 @@ }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, MonthDay expected) { MonthDay monthDay = MonthDay.parse(text); assertEquals(monthDay, expected); @@ -333,7 +332,7 @@ }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { MonthDay.parse(text); @@ -347,22 +346,22 @@ } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Day() { MonthDay.parse("--06-32"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue_Day() { MonthDay.parse("--06-31"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Month() { MonthDay.parse("--13-25"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { MonthDay.parse(null); } @@ -370,20 +369,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); MonthDay test = MonthDay.parse("12 3", f); assertEquals(test, MonthDay.of(12, 3)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); MonthDay.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { MonthDay.parse("ANY", null); } @@ -409,13 +408,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_07_15, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_07_15, Queries.zoneId(), null}, - {TEST_07_15, Queries.precision(), null}, - {TEST_07_15, Queries.zone(), null}, - {TEST_07_15, Queries.offset(), null}, - {TEST_07_15, Queries.localDate(), null}, - {TEST_07_15, Queries.localTime(), null}, + {TEST_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_07_15, TemporalQuery.zoneId(), null}, + {TEST_07_15, TemporalQuery.precision(), null}, + {TEST_07_15, TemporalQuery.zone(), null}, + {TEST_07_15, TemporalQuery.offset(), null}, + {TEST_07_15, TemporalQuery.localDate(), null}, + {TEST_07_15, TemporalQuery.localTime(), null}, }; } @@ -461,28 +460,28 @@ //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Month() { assertEquals(MonthDay.of(6, 30).with(Month.JANUARY), MonthDay.of(1, 30)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_adjustToValid() { assertEquals(MonthDay.of(7, 31).with(Month.JUNE), MonthDay.of(6, 30)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_adjustToValidFeb() { assertEquals(MonthDay.of(7, 31).with(Month.FEBRUARY), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.with(Month.JUNE), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Month_null() { MonthDay.of(6, 30).with((Month) null); } @@ -490,33 +489,33 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth() { assertEquals(MonthDay.of(6, 30).withMonth(1), MonthDay.of(1, 30)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_adjustToValid() { assertEquals(MonthDay.of(7, 31).withMonth(6), MonthDay.of(6, 30)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_adjustToValidFeb() { assertEquals(MonthDay.of(7, 31).withMonth(2), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.withMonth(6), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooLow() { MonthDay.of(6, 30).withMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooHigh() { MonthDay.of(6, 30).withMonth(13); } @@ -524,33 +523,33 @@ //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth() { assertEquals(MonthDay.of(6, 30).withDayOfMonth(1), MonthDay.of(6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { MonthDay.of(6, 30).withDayOfMonth(31); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_adjustToValidFeb() { assertEquals(MonthDay.of(2, 1).withDayOfMonth(29), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.withDayOfMonth(30), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooLow() { MonthDay.of(6, 30).withDayOfMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooHigh() { MonthDay.of(6, 30).withDayOfMonth(32); } @@ -558,28 +557,28 @@ //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 1, 1); assertEquals(test.adjustInto(date), LocalDate.of(2007, 6, 30)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { MonthDay test = MonthDay.of(2, 29); LocalDate date = LocalDate.of(2007, 6, 30); assertEquals(test.adjustInto(date), LocalDate.of(2007, 2, 28)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_equal() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 6, 30); assertEquals(test.adjustInto(date), date); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_null() { TEST_07_15.adjustInto((LocalDate) null); } @@ -587,40 +586,55 @@ //----------------------------------------------------------------------- // isValidYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidYear_june() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.isValidYear(2007), true); } - @Test(groups={"tck"}) + @Test public void test_isValidYear_febNonLeap() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.isValidYear(2007), false); } - @Test(groups={"tck"}) + @Test public void test_isValidYear_febLeap() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.isValidYear(2008), true); } //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); + String t = MonthDay.of(12, 3).format(f); + assertEquals(t, "12 3"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + MonthDay.of(12, 3).format(null); + } + + //----------------------------------------------------------------------- // atYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atYear_int() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.atYear(2008), LocalDate.of(2008, 6, 30)); } - @Test(groups={"tck"}) + @Test public void test_atYear_int_leapYearAdjust() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.atYear(2005), LocalDate.of(2005, 2, 28)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atYear_int_invalidYear() { MonthDay test = MonthDay.of(6, 30); test.atYear(Integer.MIN_VALUE); @@ -629,7 +643,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_MonthDay( MonthDay.of(1, 1), @@ -666,17 +680,17 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_07_15.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_07_15.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_07_15.isAfter(null); } @@ -684,7 +698,7 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { MonthDay a = MonthDay.of(1, 1); MonthDay b = MonthDay.of(1, 1); @@ -712,17 +726,17 @@ assertEquals(d.equals(d), true); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_07_15.equals(TEST_07_15), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_07_15.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_07_15.equals(null), false); } @@ -730,7 +744,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int m, int d) { MonthDay a = MonthDay.of(m, d); assertEquals(a.hashCode(), a.hashCode()); @@ -738,7 +752,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_unique() { int leapYear = 2008; Set uniques = new HashSet(366); @@ -763,26 +777,11 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int m, int d, String expected) { MonthDay test = MonthDay.of(m, d); String str = test.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); - String t = MonthDay.of(12, 3).toString(f); - assertEquals(t, "12 3"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - MonthDay.of(12, 3).toString(null); - } - } --- old/test/java/time/tck/java/time/TCKOffsetDateTime.java 2013-04-11 23:17:30.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKOffsetDateTime.java 2013-04-11 23:17:30.000000000 -0700 @@ -71,7 +71,6 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -86,6 +85,7 @@ import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; @@ -95,6 +95,7 @@ import static java.time.temporal.ChronoUnit.SECONDS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -120,7 +121,6 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -149,9 +149,9 @@ private static final ZoneOffset OFFSET_MTWO = ZoneOffset.ofHours(-2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { - TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); + TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE); } //----------------------------------------------------------------------- @@ -188,7 +188,7 @@ ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -261,7 +261,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { OffsetDateTime expected = OffsetDateTime.now(Clock.systemDefaultZone()); OffsetDateTime test = OffsetDateTime.now(); @@ -278,7 +278,7 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -295,7 +295,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -312,7 +312,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -328,7 +328,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { OffsetDateTime base = OffsetDateTime.of(1970, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -343,12 +343,12 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullZoneId() { OffsetDateTime.now((ZoneId) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { OffsetDateTime.now((Clock) null); } @@ -371,14 +371,14 @@ //----------------------------------------------------------------------- // factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_intsHMSN() { OffsetDateTime test = OffsetDateTime.of(2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTimeZoneOffset() { LocalDate date = LocalDate.of(2008, 6, 30); LocalTime time = LocalTime.of(11, 30, 10, 500); @@ -386,19 +386,19 @@ check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullLocalDate() { LocalTime time = LocalTime.of(11, 30, 10, 500); OffsetDateTime.of((LocalDate) null, time, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullLocalTime() { LocalDate date = LocalDate.of(2008, 6, 30); OffsetDateTime.of(date, (LocalTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullOffset() { LocalDate date = LocalDate.of(2008, 6, 30); LocalTime time = LocalTime.of(11, 30, 10, 500); @@ -406,19 +406,19 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTimeZoneOffset() { LocalDateTime dt = LocalDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500)); OffsetDateTime test = OffsetDateTime.of(dt, OFFSET_PONE); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTimeZoneOffset_nullProvider() { OffsetDateTime.of((LocalDateTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTimeZoneOffset_nullOffset() { LocalDateTime dt = LocalDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500)); OffsetDateTime.of(dt, (ZoneOffset) null); @@ -427,19 +427,19 @@ //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(OffsetDateTime.from( OffsetDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30), OFFSET_PONE)), OffsetDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30), OFFSET_PONE)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { OffsetDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_Calendricals_null() { OffsetDateTime.from((TemporalAccessor) null); } @@ -447,7 +447,7 @@ //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_parse(int y, int month, int d, int h, int m, int s, int n, String offsetId, String text) { OffsetDateTime t = OffsetDateTime.parse(text); assertEquals(t.getYear(), y); @@ -460,17 +460,17 @@ assertEquals(t.getOffset().getId(), offsetId); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { OffsetDateTime.parse("2008-06-32T11:15+01:00"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { OffsetDateTime.parse("2008-06-31T11:15+01:00"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { OffsetDateTime.parse((String) null); } @@ -478,26 +478,26 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s XXX"); OffsetDateTime test = OffsetDateTime.parse("2010 12 3 11 30 0 +01:00", f); assertEquals(test, OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), ZoneOffset.ofHours(1))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); OffsetDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { OffsetDateTime.parse("ANY", null); } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullTime() throws Throwable { Constructor con = OffsetDateTime.class.getDeclaredConstructor(LocalDateTime.class, ZoneOffset.class); con.setAccessible(true); @@ -508,7 +508,7 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullOffset() throws Throwable { Constructor con = OffsetDateTime.class.getDeclaredConstructor(LocalDateTime.class, ZoneOffset.class); con.setAccessible(true); @@ -532,7 +532,7 @@ }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -602,13 +602,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_6_30_11_30_59_000000500, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.zoneId(), null}, - {TEST_2008_6_30_11_30_59_000000500, Queries.precision(), ChronoUnit.NANOS}, - {TEST_2008_6_30_11_30_59_000000500, Queries.zone(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.offset(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.localDate(), LocalDate.of(2008, 6, 30)}, - {TEST_2008_6_30_11_30_59_000000500, Queries.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zoneId(), null}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zone(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.offset(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localDate(), LocalDate.of(2008, 6, 30)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } @@ -628,9 +628,49 @@ } //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 1, 1, 1, 100, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.MAX, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.MIN, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.MAX, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(OffsetDateTime.MAX.toLocalDateTime(), ZoneOffset.ofHours(-18)), null}, + {OffsetDateTime.MIN, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(OffsetDateTime.MIN.toLocalDateTime(), ZoneOffset.ofHours(18)), null}, + + + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), + ZonedDateTime.of(2012, 3, 4, 1, 1, 1, 100, ZONE_GAZA), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_GAZA), null}, + + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(OffsetDateTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final OffsetDateTime sample = OffsetDateTime.of(LocalDate.of(2012, 3, 4), LocalTime.of(23, 5), OFFSET_PONE); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -642,54 +682,54 @@ assertEquals(TEST_2008_6_30_11_30_59_000000500.with(adjuster), sample); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalDate() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalDate.of(2012, 9, 3)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalTime.of(19, 15)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(19, 15), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalDateTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15))); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OffsetTime.of(LocalTime.of(19, 15), OFFSET_PTWO)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(19, 15), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetDateTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PTWO)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_Month() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(DECEMBER); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 12, 30),LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_ZoneOffset() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OFFSET_PTWO); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2008_6_30_11_30_59_000000500.with((TemporalAdjuster) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameLocal_null() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); base.withOffsetSameLocal(null); @@ -698,7 +738,7 @@ //----------------------------------------------------------------------- // withOffsetSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameInstant(OFFSET_PTWO); @@ -706,16 +746,40 @@ assertEquals(test, expected); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameInstant_null() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); base.withOffsetSameInstant(null); } //----------------------------------------------------------------------- + // with(long,TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name = "withFieldLong") + Object[][] data_withFieldLong() { + return new Object[][] { + {TEST_2008_6_30_11_30_59_000000500, YEAR, 2009, + OffsetDateTime.of(2009, 6, 30, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, MONTH_OF_YEAR, 7, + OffsetDateTime.of(2008, 7, 30, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, DAY_OF_MONTH, 15, + OffsetDateTime.of(2008, 6, 15, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, HOUR_OF_DAY, 14, + OffsetDateTime.of(2008, 6, 30, 14, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, OFFSET_SECONDS, -3600, + OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_MONE)}, + }; + }; + + @Test(dataProvider = "withFieldLong") + public void test_with_fieldLong(OffsetDateTime base, TemporalField setField, long setValue, OffsetDateTime expected) { + assertEquals(base.with(setField, setValue), expected); + } + + //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withYear(2007); @@ -725,7 +789,7 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMonth(1); @@ -735,7 +799,7 @@ //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withDayOfMonth(15); @@ -745,18 +809,18 @@ //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.withDayOfYear(33); assertEquals(t, OffsetDateTime.of(LocalDate.of(2008, 2, 2), LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2008_6_30_11_30_59_000000500.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { OffsetDateTime.of(LocalDate.of(2007, 2, 2), LocalTime.of(11, 30), OFFSET_PONE).withDayOfYear(366); } @@ -764,7 +828,7 @@ //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withHour(15); @@ -774,7 +838,7 @@ //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMinute(15); @@ -784,7 +848,7 @@ //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withSecond(15); @@ -794,7 +858,7 @@ //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE); OffsetDateTime test = base.withNano(15); @@ -804,14 +868,14 @@ //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(NANOS), TEST_2008_6_30_11_30_59_000000500); assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(SECONDS), TEST_2008_6_30_11_30_59_000000500.withNano(0)); assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(DAYS), TEST_2008_6_30_11_30_59_000000500.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_2008_6_30_11_30_59_000000500.truncatedTo(null); } @@ -819,7 +883,7 @@ //----------------------------------------------------------------------- // plus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Period() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(period); @@ -829,20 +893,20 @@ //----------------------------------------------------------------------- // plus(Duration) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Duration() { Duration dur = Duration.ofSeconds(62, 3); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(dur); assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 32, 1, 503, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plus_Duration_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(Duration.ZERO); assertEquals(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_Duration_null() { TEST_2008_6_30_11_30_59_000000500.plus((Duration) null); } @@ -850,7 +914,7 @@ //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusYears(1); @@ -860,7 +924,7 @@ //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusMonths(1); @@ -870,7 +934,7 @@ //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusWeeks() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusWeeks(1); @@ -880,7 +944,7 @@ //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusDays() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusDays(1); @@ -890,7 +954,7 @@ //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusHours(13); @@ -900,7 +964,7 @@ //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusMinutes(30); @@ -910,7 +974,7 @@ //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusSeconds(1); @@ -920,7 +984,7 @@ //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusNanos(1); @@ -930,7 +994,7 @@ //----------------------------------------------------------------------- // minus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Period() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(period); @@ -940,20 +1004,20 @@ //----------------------------------------------------------------------- // minus(Duration) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Duration() { Duration dur = Duration.ofSeconds(62, 3); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(dur); assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 29, 57, 497, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minus_Duration_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(Duration.ZERO); assertEquals(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_Duration_null() { TEST_2008_6_30_11_30_59_000000500.minus((Duration) null); } @@ -961,7 +1025,7 @@ //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusYears(1); @@ -971,7 +1035,7 @@ //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusMonths(1); @@ -981,7 +1045,7 @@ //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusWeeks() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusWeeks(1); @@ -991,7 +1055,7 @@ //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusDays() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusDays(1); @@ -1001,7 +1065,7 @@ //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusHours(13); @@ -1011,7 +1075,7 @@ //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusMinutes(30); @@ -1021,7 +1085,7 @@ //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusSeconds(1); @@ -1031,7 +1095,7 @@ //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusNanos(1); @@ -1039,16 +1103,31 @@ } //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).format(f); + assertEquals(t, "2010 12 3 11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).format(null); + } + + //----------------------------------------------------------------------- // atZoneSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSameInstant(ZONE_PARIS), ZonedDateTime.of(2008, 6, 30, 15, 30, 0, 0, ZONE_PARIS)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZone_nullTimeZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); t.atZoneSameInstant((ZoneId) null); @@ -1057,21 +1136,21 @@ //----------------------------------------------------------------------- // atZoneSimilarLocal() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZoneSimilarLocal() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS), ZonedDateTime.of(2008, 6, 30, 11, 30, 0, 0, ZONE_PARIS)); } - @Test(groups={"tck"}) + @Test public void test_atZoneSimilarLocal_dstGap() { OffsetDateTime t = OffsetDateTime.of(2007, 4, 1, 0, 0, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSimilarLocal(ZONE_GAZA), ZonedDateTime.of(2007, 4, 1, 1, 0, 0, 0, ZONE_GAZA)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlapSummer() { OffsetDateTime t = OffsetDateTime.of(2007, 10, 28, 2, 30, 0, 0, OFFSET_PTWO); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).toLocalDateTime(), t.toLocalDateTime()); @@ -1079,7 +1158,7 @@ assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getZone(), ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlapWinter() { OffsetDateTime t = OffsetDateTime.of(2007, 10, 28, 2, 30, 0, 0, OFFSET_PONE); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).toLocalDateTime(), t.toLocalDateTime()); @@ -1087,7 +1166,7 @@ assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getZone(), ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZoneSimilarLocal_nullTimeZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); t.atZoneSimilarLocal((ZoneId) null); @@ -1096,7 +1175,7 @@ //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { for (int i = 0; i < 100000; i++) { OffsetDateTime a = OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).plusSeconds(i); @@ -1104,7 +1183,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { for (int i = 0; i < 100000; i++) { OffsetDateTime a = OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).minusSeconds(i); @@ -1115,7 +1194,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_timeMins() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 2, 0, OFFSET_PONE); // a is before b due to time @@ -1126,7 +1205,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_timeSecs() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 2, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE); // a is before b due to time @@ -1137,7 +1216,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_timeNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 4, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 5, OFFSET_PONE); // a is before b due to time @@ -1148,7 +1227,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1159,7 +1238,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offsetNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 6, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 5, OFFSET_PONE); // a is before b due to offset @@ -1170,7 +1249,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 50, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 20, 0, 0, OFFSET_PONE); // a is before b on instant scale @@ -1181,7 +1260,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 20, 40, 4, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 10, 20, 40, 5, OFFSET_PONE); // a is before b on instant scale @@ -1192,7 +1271,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 10, 0, 0, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 0, 0, 0, OFFSET_PTWO); // a is before b despite being same time-line time @@ -1203,7 +1282,7 @@ assertEquals(a.toInstant().compareTo(b.toInstant()) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_max() { OffsetDateTime a = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MONE); OffsetDateTime b = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MTWO); // a is before b due to offset @@ -1213,7 +1292,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_min() { OffsetDateTime a = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1223,13 +1302,13 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonOffsetDateTime() { Comparable c = TEST_2008_6_30_11_30_59_000000500; @@ -1239,7 +1318,7 @@ //----------------------------------------------------------------------- // isAfter() / isBefore() / isEqual() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 58, 3, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 2, OFFSET_PONE); // a is before b due to time @@ -1261,7 +1340,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 2, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 3, OFFSET_PONE); // a is before b due to time @@ -1283,7 +1362,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual_instantComparison() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 10, 0, 0, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 0, 0, 0, OFFSET_PTWO); // a is same instant as b @@ -1305,19 +1384,19 @@ assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isEqual_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isEqual(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isAfter(null); @@ -1326,65 +1405,65 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_year_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y + 1, o, d, h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { h = (h == 23 ? 22 : h); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h + 1, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { m = (m == 59 ? 58 : m); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m + 1, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { s = (s == 59 ? 58 : s); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s + 1, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { n = (n == 999999999 ? 999999998 : n); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n + 1, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PTWO); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals(TEST_2008_6_30_11_30_59_000000500), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals(null), false); } @@ -1406,26 +1485,11 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int o, int d, int h, int m, int s, int n, String offsetId, String expected) { OffsetDateTime t = OffsetDateTime.of(y, o, d, h, m, s, n, ZoneOffset.of(offsetId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).toString(f); - assertEquals(t, "2010 12 3 11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).toString(null); - } - } --- old/test/java/time/tck/java/time/TCKOffsetTime.java 2013-04-11 23:17:31.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKOffsetTime.java 2013-04-11 23:17:31.000000000 -0700 @@ -81,6 +81,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -92,6 +93,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.Period; import java.time.ZoneId; @@ -102,7 +104,6 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -124,12 +125,13 @@ @Test public class TCKOffsetTime extends AbstractDateTimeTest { + private static final ZoneId ZONE_GAZA = ZoneId.of("Asia/Gaza"); private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private static final LocalDate DATE = LocalDate.of(2008, 12, 3); private OffsetTime TEST_11_30_59_500_PONE; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE); } @@ -224,7 +226,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { ZonedDateTime nowDT = ZonedDateTime.now(); @@ -238,7 +240,7 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -252,7 +254,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -266,7 +268,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { Instant base = LocalDateTime.of(1970, 1, 1, 12, 0).toInstant(ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -281,12 +283,12 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullZoneId() { OffsetTime.now((ZoneId) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { OffsetTime.now((Clock) null); } @@ -309,26 +311,26 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intsHMSN() { OffsetTime test = OffsetTime.of(11, 30, 10, 500, OFFSET_PONE); check(test, 11, 30, 10, 500, OFFSET_PONE); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_LocalTimeZoneOffset() { LocalTime localTime = LocalTime.of(11, 30, 10, 500); OffsetTime test = OffsetTime.of(localTime, OFFSET_PONE); check(test, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_LocalTimeZoneOffset_nullTime() { OffsetTime.of((LocalTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_LocalTimeZoneOffset_nullOffset() { LocalTime localTime = LocalTime.of(11, 30, 10, 500); OffsetTime.of(localTime, (ZoneOffset) null); @@ -337,18 +339,18 @@ //----------------------------------------------------------------------- // ofInstant() //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullInstant() { OffsetTime.ofInstant((Instant) null, ZoneOffset.UTC); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullOffset() { Instant instant = Instant.ofEpochSecond(0L); OffsetTime.ofInstant(instant, (ZoneOffset) null); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -360,7 +362,7 @@ } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -373,7 +375,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxYear() { OffsetTime test = OffsetTime.ofInstant(Instant.MAX, ZoneOffset.UTC); assertEquals(test.getHour(), 23); @@ -382,7 +384,7 @@ assertEquals(test.getNano(), 999_999_999); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minYear() { OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC); assertEquals(test.getHour(), 0); @@ -394,23 +396,23 @@ //----------------------------------------------------------------------- // from(TemporalAccessor) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_OT() { assertEquals(OffsetTime.from(OffsetTime.of(17, 30, 0, 0, OFFSET_PONE)), OffsetTime.of(17, 30, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor_ZDT() { ZonedDateTime base = LocalDateTime.of(2007, 7, 15, 11, 30, 59, 500).atZone(OFFSET_PONE); assertEquals(OffsetTime.from(base), TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { OffsetTime.from(LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { OffsetTime.from((TemporalAccessor) null); } @@ -418,7 +420,7 @@ //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider = "sampleToString", groups={"tck"}) + @Test(dataProvider = "sampleToString") public void factory_parse_validText(int h, int m, int s, int n, String offsetId, String parsable) { OffsetTime t = OffsetTime.parse(parsable); assertNotNull(t, parsable); @@ -440,23 +442,23 @@ }; } - @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { OffsetTime.parse(unparsable); } //-----------------------------------------------------------------------s - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalHour() { OffsetTime.parse("25:00+01:00"); } - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalMinute() { OffsetTime.parse("12:60+01:00"); } - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalSecond() { OffsetTime.parse("12:12:60+01:00"); } @@ -464,20 +466,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s XXX"); OffsetTime test = OffsetTime.parse("11 30 0 +01:00", f); assertEquals(test, OffsetTime.of(11, 30, 0, 0, ZoneOffset.ofHours(1))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); OffsetTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { OffsetTime.parse("ANY", null); } @@ -485,7 +487,7 @@ //----------------------------------------------------------------------- // constructor //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullTime() throws Throwable { Constructor con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class); con.setAccessible(true); @@ -496,7 +498,7 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullOffset() throws Throwable { Constructor con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class); con.setAccessible(true); @@ -519,7 +521,7 @@ }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int h, int m, int s, int n, ZoneOffset offset) { LocalTime localTime = LocalTime.of(h, m, s, n); OffsetTime a = OffsetTime.of(localTime, offset); @@ -568,13 +570,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_11_30_59_500_PONE, Queries.chronology(), null}, - {TEST_11_30_59_500_PONE, Queries.zoneId(), null}, - {TEST_11_30_59_500_PONE, Queries.precision(), ChronoUnit.NANOS}, - {TEST_11_30_59_500_PONE, Queries.zone(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, Queries.offset(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, Queries.localDate(), null}, - {TEST_11_30_59_500_PONE, Queries.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_11_30_59_500_PONE, TemporalQuery.chronology(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.zoneId(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_11_30_59_500_PONE, TemporalQuery.zone(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQuery.offset(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQuery.localDate(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } @@ -596,7 +598,7 @@ //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameLocal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameLocal(OFFSET_PTWO); @@ -604,14 +606,14 @@ assertEquals(test.getOffset(), OFFSET_PTWO); } - @Test(groups={"tck"}) + @Test public void test_withOffsetSameLocal_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameLocal(OFFSET_PONE); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameLocal_null() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); base.withOffsetSameLocal(null); @@ -620,7 +622,7 @@ //----------------------------------------------------------------------- // withOffsetSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameInstant(OFFSET_PTWO); @@ -628,23 +630,62 @@ assertEquals(test, expected); } - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameInstant(OFFSET_PONE); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameInstant_null() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); base.withOffsetSameInstant(null); } //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(LocalTime.of(1, 1, 1, 100), ZoneOffset.UTC), OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MIN, OffsetTime.of(LocalTime.of(23 , 5), OFFSET_PONE), null}, + {OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MAX.toLocalTime(), ZoneOffset.ofHours(-18)), null}, + {OffsetTime.MIN, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MIN.toLocalTime(), ZoneOffset.ofHours(18)), null}, + + + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZONE_GAZA), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), ZONE_GAZA), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZoneOffset.UTC), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), OFFSET_PONE), null}, + + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(OffsetTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -656,25 +697,25 @@ assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalTime() { OffsetTime test = TEST_11_30_59_500_PONE.with(LocalTime.of(13, 30)); assertEquals(test, OffsetTime.of(13, 30, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetTime() { OffsetTime test = TEST_11_30_59_500_PONE.with(OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO)); assertEquals(test, OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_ZoneOffset() { OffsetTime test = TEST_11_30_59_500_PONE.with(OFFSET_PTWO); assertEquals(test, OffsetTime.of(11, 30, 59, 500, OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_AmPm() { OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() { @Override @@ -685,7 +726,7 @@ assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_11_30_59_500_PONE.with((TemporalAdjuster) null); } @@ -693,7 +734,7 @@ //----------------------------------------------------------------------- // with(TemporalField, long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_TemporalField() { OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE); assertEquals(test.with(ChronoField.HOUR_OF_DAY, 15), OffsetTime.of(15, 30, 40, 987654321, OFFSET_PONE)); @@ -706,12 +747,12 @@ assertEquals(test.with(ChronoField.OFFSET_SECONDS, 7205), OffsetTime.of(12, 30, 40, 987654321, ZoneOffset.ofHoursMinutesSeconds(2, 0, 5))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"} ) + @Test(expectedExceptions=NullPointerException.class ) public void test_with_TemporalField_null() { TEST_11_30_59_500_PONE.with((TemporalField) null, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_invalidField() { TEST_11_30_59_500_PONE.with(ChronoField.YEAR, 0); } @@ -719,14 +760,14 @@ //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withHour(15); assertEquals(test, OffsetTime.of(15, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withHour(11); @@ -736,14 +777,14 @@ //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withMinute(15); assertEquals(test, OffsetTime.of(11, 15, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withMinute(30); @@ -753,14 +794,14 @@ //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withSecond(15); assertEquals(test, OffsetTime.of(11, 30, 15, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withSecond(59); @@ -770,14 +811,14 @@ //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE); OffsetTime test = base.withNano(15); assertEquals(test, OffsetTime.of(11, 30, 59, 15, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE); OffsetTime test = base.withNano(1); @@ -787,14 +828,14 @@ //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_11_30_59_500_PONE.truncatedTo(NANOS), TEST_11_30_59_500_PONE); assertEquals(TEST_11_30_59_500_PONE.truncatedTo(SECONDS), TEST_11_30_59_500_PONE.withNano(0)); assertEquals(TEST_11_30_59_500_PONE.truncatedTo(DAYS), TEST_11_30_59_500_PONE.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_11_30_59_500_PONE.truncatedTo(null); } @@ -802,26 +843,26 @@ //----------------------------------------------------------------------- // plus(PlusAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES); OffsetTime t = TEST_11_30_59_500_PONE.plus(period); assertEquals(t, OffsetTime.of(11, 37, 59, 500, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster_noChange() { OffsetTime t = TEST_11_30_59_500_PONE.plus(MockSimplePeriod.of(0, SECONDS)); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster_zero() { OffsetTime t = TEST_11_30_59_500_PONE.plus(Period.ZERO); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_PlusAdjuster_null() { TEST_11_30_59_500_PONE.plus((TemporalAmount) null); } @@ -829,14 +870,14 @@ //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusHours(13); assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusHours_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusHours(0); @@ -846,14 +887,14 @@ //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusMinutes(30); assertEquals(test, OffsetTime.of(12, 0, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusMinutes(0); @@ -863,14 +904,14 @@ //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusSeconds(1); assertEquals(test, OffsetTime.of(11, 31, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusSeconds(0); @@ -880,14 +921,14 @@ //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusNanos(1); assertEquals(test, OffsetTime.of(11, 30, 59, 1, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusNanos(0); @@ -897,26 +938,26 @@ //----------------------------------------------------------------------- // minus(MinusAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES); OffsetTime t = TEST_11_30_59_500_PONE.minus(period); assertEquals(t, OffsetTime.of(11, 23, 59, 500, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster_noChange() { OffsetTime t = TEST_11_30_59_500_PONE.minus(MockSimplePeriod.of(0, SECONDS)); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster_zero() { OffsetTime t = TEST_11_30_59_500_PONE.minus(Period.ZERO); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_MinusAdjuster_null() { TEST_11_30_59_500_PONE.minus((TemporalAmount) null); } @@ -924,14 +965,14 @@ //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusHours(-13); assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusHours_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusHours(0); @@ -941,14 +982,14 @@ //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusMinutes(50); assertEquals(test, OffsetTime.of(10, 40, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusMinutes(0); @@ -958,14 +999,14 @@ //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusSeconds(60); assertEquals(test, OffsetTime.of(11, 29, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusSeconds(0); @@ -975,14 +1016,14 @@ //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusNanos(1); assertEquals(test, OffsetTime.of(11, 30, 58, 999999999, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusNanos(0); @@ -990,9 +1031,24 @@ } //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); + String t = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(f); + assertEquals(t, "11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(null); + } + + //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_time() { OffsetTime a = OffsetTime.of(11, 29, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to time @@ -1003,7 +1059,7 @@ assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset() { OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1014,7 +1070,7 @@ assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { OffsetTime a = OffsetTime.of(11, 50, 0, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 20, 0, 0, OFFSET_PONE); // a is before b on instant scale @@ -1025,7 +1081,7 @@ assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNearStartOfDay() { OffsetTime a = OffsetTime.of(0, 10, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(2, 30, 0, 0, OFFSET_PTWO); // a is before b on instant scale @@ -1036,7 +1092,7 @@ assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { OffsetTime a = OffsetTime.of(10, 0, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 0, 0, 0, OFFSET_PTWO); // a is before b despite being same time-line time @@ -1047,13 +1103,13 @@ assertEquals(convertInstant(a).compareTo(convertInstant(b)) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonOffsetTime() { Comparable c = TEST_11_30_59_500_PONE; @@ -1067,7 +1123,7 @@ //----------------------------------------------------------------------- // isAfter() / isBefore() / isEqual() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1() { OffsetTime a = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); // a is before b due to time @@ -1089,7 +1145,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1nanos() { OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE); // a is before b due to time @@ -1111,7 +1167,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); // a is before b due to offset @@ -1133,7 +1189,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2nanos() { OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1)); OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); // a is before b due to offset @@ -1155,7 +1211,7 @@ assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual_instantComparison() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(10, 30, 59, 0, OFFSET_PONE); // a is same instant as b @@ -1177,19 +1233,19 @@ assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isAfter(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isEqual_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isEqual(null); @@ -1198,59 +1254,59 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int h, int m, int s, int n, ZoneOffset ignored) { OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int h, int m, int s, int n, ZoneOffset ignored) { h = (h == 23 ? 22 : h); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h + 1, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) { m = (m == 59 ? 58 : m); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) { s = (s == 59 ? 58 : s); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int h, int m, int s, int n, ZoneOffset ignored) { n = (n == 999999999 ? 999999998 : n); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n + 1, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int h, int m, int s, int n, ZoneOffset ignored) { OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PTWO); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_11_30_59_500_PONE.equals(TEST_11_30_59_500_PONE), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_11_30_59_500_PONE.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_11_30_59_500_PONE.equals(null), false); } @@ -1272,26 +1328,11 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int h, int m, int s, int n, String offsetId, String expected) { OffsetTime t = OffsetTime.of(h, m, s, n, ZoneOffset.of(offsetId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); - String t = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).toString(f); - assertEquals(t, "11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).toString(null); - } - } --- old/test/java/time/tck/java/time/TCKPeriod.java 2013-04-11 23:17:32.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKPeriod.java 2013-04-11 23:17:31.000000000 -0700 @@ -59,14 +59,21 @@ */ package tck.java.time; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import java.time.DateTimeException; +import java.time.Duration; import java.time.LocalDate; import java.time.Period; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -139,6 +146,78 @@ } //----------------------------------------------------------------------- + // from(TemporalAmount) + //----------------------------------------------------------------------- + @Test + public void factory_from_TemporalAmount_Period() { + TemporalAmount amount = Period.of(1, 2, 3); + assertPeriod(Period.from(amount), 1, 2, 3); + } + + @Test + public void factory_from_TemporalAmount_YearsDays() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + if (unit == YEARS) { + return 23; + } else { + return 45; + } + } + @Override + public List getUnits() { + List list = new ArrayList<>(); + list.add(YEARS); + list.add(DAYS); + return list; + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } + }; + assertPeriod(Period.from(amount), 23, 0, 45); + } + + @Test(expectedExceptions = ArithmeticException.class) + public void factory_from_TemporalAmount_Years_tooBig() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + return ((long) (Integer.MAX_VALUE)) + 1; + } + @Override + public List getUnits() { + return Collections.singletonList(YEARS); + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } + }; + Period.from(amount); + } + + @Test(expectedExceptions = DateTimeException.class) + public void factory_from_TemporalAmount_Duration() { + Period.from(Duration.ZERO); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_from_TemporalAmount_null() { + Period.from(null); + } + + //----------------------------------------------------------------------- // parse(String) //----------------------------------------------------------------------- @DataProvider(name="parseSuccess") @@ -466,6 +545,32 @@ } //----------------------------------------------------------------------- + // plus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="plus") + Object[][] data_plus() { + return new Object[][] { + {pymd(0, 0, 0), pymd(0, 0, 0), pymd(0, 0, 0)}, + {pymd(0, 0, 0), pymd(5, 0, 0), pymd(5, 0, 0)}, + {pymd(0, 0, 0), pymd(-5, 0, 0), pymd(-5, 0, 0)}, + {pymd(0, 0, 0), pymd(0, 5, 0), pymd(0, 5, 0)}, + {pymd(0, 0, 0), pymd(0, -5, 0), pymd(0, -5, 0)}, + {pymd(0, 0, 0), pymd(0, 0, 5), pymd(0, 0, 5)}, + {pymd(0, 0, 0), pymd(0, 0, -5), pymd(0, 0, -5)}, + {pymd(0, 0, 0), pymd(2, 3, 4), pymd(2, 3, 4)}, + {pymd(0, 0, 0), pymd(-2, -3, -4), pymd(-2, -3, -4)}, + + {pymd(4, 5, 6), pymd(2, 3, 4), pymd(6, 8, 10)}, + {pymd(4, 5, 6), pymd(-2, -3, -4), pymd(2, 2, 2)}, + }; + } + + @Test(dataProvider="plus") + public void test_plus(Period base, Period add, Period expected) { + assertEquals(base.plus(add), expected); + } + + //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- @Test @@ -474,6 +579,11 @@ assertPeriod(Period.of(1, 2, 3).plusYears(10), 11, 2, 3); assertPeriod(Period.of(1, 2, 3).plusYears(-10), -9, 2, 3); assertPeriod(Period.of(1, 2, 3).plusYears(-1), 0, 2, 3); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(10)), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(-10)), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(-1)), 0, 2, 3); } @Test(expectedExceptions=ArithmeticException.class) @@ -497,6 +607,11 @@ assertPeriod(Period.of(1, 2, 3).plusMonths(10), 1, 12, 3); assertPeriod(Period.of(1, 2, 3).plusMonths(-10), 1, -8, 3); assertPeriod(Period.of(1, 2, 3).plusMonths(-2), 1, 0, 3); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(10)), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(-10)), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(-2)), 1, 0, 3); } @Test(expectedExceptions=ArithmeticException.class) @@ -520,6 +635,11 @@ assertPeriod(Period.of(1, 2, 3).plusDays(10), 1, 2, 13); assertPeriod(Period.of(1, 2, 3).plusDays(-10), 1, 2, -7); assertPeriod(Period.of(1, 2, 3).plusDays(-3), 1, 2, 0); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(10)), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(-10)), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(-3)), 1, 2, 0); } @Test(expectedExceptions=ArithmeticException.class) @@ -535,6 +655,116 @@ } //----------------------------------------------------------------------- + // minus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="minus") + Object[][] data_minus() { + return new Object[][] { + {pymd(0, 0, 0), pymd(0, 0, 0), pymd(0, 0, 0)}, + {pymd(0, 0, 0), pymd(5, 0, 0), pymd(-5, 0, 0)}, + {pymd(0, 0, 0), pymd(-5, 0, 0), pymd(5, 0, 0)}, + {pymd(0, 0, 0), pymd(0, 5, 0), pymd(0, -5, 0)}, + {pymd(0, 0, 0), pymd(0, -5, 0), pymd(0, 5, 0)}, + {pymd(0, 0, 0), pymd(0, 0, 5), pymd(0, 0, -5)}, + {pymd(0, 0, 0), pymd(0, 0, -5), pymd(0, 0, 5)}, + {pymd(0, 0, 0), pymd(2, 3, 4), pymd(-2, -3, -4)}, + {pymd(0, 0, 0), pymd(-2, -3, -4), pymd(2, 3, 4)}, + + {pymd(4, 5, 6), pymd(2, 3, 4), pymd(2, 2, 2)}, + {pymd(4, 5, 6), pymd(-2, -3, -4), pymd(6, 8, 10)}, + }; + } + + @Test(dataProvider="minus") + public void test_minus(Period base, Period subtract, Period expected) { + assertEquals(base.minus(subtract), expected); + } + + //----------------------------------------------------------------------- + // minusYears() + //----------------------------------------------------------------------- + @Test + public void test_minusYears() { + assertPeriod(Period.of(1, 2, 3).minusYears(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(10), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(-10), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(-1), 2, 2, 3); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(10)), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(-10)), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(-1)), 2, 2, 3); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusYears_overflowTooBig() { + Period test = Period.ofYears(Integer.MAX_VALUE); + test.minusYears(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusYears_overflowTooSmall() { + Period test = Period.ofYears(Integer.MIN_VALUE); + test.minusYears(1); + } + + //----------------------------------------------------------------------- + // minusMonths() + //----------------------------------------------------------------------- + @Test + public void test_minusMonths() { + assertPeriod(Period.of(1, 2, 3).minusMonths(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(10), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(-10), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(-2), 1, 4, 3); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(10)), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(-10)), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(-2)), 1, 4, 3); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusMonths_overflowTooBig() { + Period test = Period.ofMonths(Integer.MAX_VALUE); + test.minusMonths(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusMonths_overflowTooSmall() { + Period test = Period.ofMonths(Integer.MIN_VALUE); + test.minusMonths(1); + } + + //----------------------------------------------------------------------- + // minusDays() + //----------------------------------------------------------------------- + @Test + public void test_minusDays() { + assertPeriod(Period.of(1, 2, 3).minusDays(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusDays(10), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).minusDays(-10), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).minusDays(-3), 1, 2, 6); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(10)), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(-10)), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(-3)), 1, 2, 6); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusDays_overflowTooBig() { + Period test = Period.ofDays(Integer.MAX_VALUE); + test.minusDays(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusDays_overflowTooSmall() { + Period test = Period.ofDays(Integer.MIN_VALUE); + test.minusDays(1); + } + + //----------------------------------------------------------------------- // multipliedBy() //----------------------------------------------------------------------- @Test --- old/test/java/time/tck/java/time/TCKYear.java 2013-04-11 23:17:32.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKYear.java 2013-04-11 23:17:32.000000000 -0700 @@ -62,6 +62,14 @@ import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -69,12 +77,14 @@ import java.io.DataOutputStream; import java.time.Clock; import java.time.DateTimeException; +import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.Month; import java.time.MonthDay; import java.time.OffsetDateTime; +import java.time.Period; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; @@ -85,11 +95,13 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -159,7 +171,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); @@ -176,12 +188,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { Year.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); @@ -199,7 +211,7 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant(); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -207,13 +219,13 @@ assertEquals(test.getValue(), 2010); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { Year.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = -4; i <= 2104; i++) { Year test = Year.of(i); @@ -222,28 +234,28 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooLow() { Year.of(Year.MIN_VALUE - 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooHigh() { Year.of(Year.MAX_VALUE + 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(Year.from(LocalDate.of(2007, 7, 15)), Year.of(2007)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { Year.from((TemporalAccessor) null); } @@ -268,7 +280,7 @@ }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, Year expected) { Year year = Year.parse(text); assertEquals(year, expected); @@ -295,7 +307,7 @@ }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { Year.parse(text); @@ -307,7 +319,7 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { Year.parse(null); } @@ -315,20 +327,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); Year test = Year.parse("2010", f); assertEquals(test, Year.of(2010)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); Year.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { Year.parse("ANY", null); } @@ -356,13 +368,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008, Queries.zoneId(), null}, - {TEST_2008, Queries.precision(), ChronoUnit.YEARS}, - {TEST_2008, Queries.zone(), null}, - {TEST_2008, Queries.offset(), null}, - {TEST_2008, Queries.localDate(), null}, - {TEST_2008, Queries.localTime(), null}, + {TEST_2008, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008, TemporalQuery.zoneId(), null}, + {TEST_2008, TemporalQuery.precision(), ChronoUnit.YEARS}, + {TEST_2008, TemporalQuery.zone(), null}, + {TEST_2008, TemporalQuery.offset(), null}, + {TEST_2008, TemporalQuery.localDate(), null}, + {TEST_2008, TemporalQuery.localTime(), null}, }; } @@ -384,7 +396,7 @@ //----------------------------------------------------------------------- // isLeap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeap() { assertEquals(Year.of(1999).isLeap(), false); assertEquals(Year.of(2000).isLeap(), true); @@ -423,9 +435,51 @@ } //----------------------------------------------------------------------- + // plus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="plusValid") + Object[][] data_plusValid() { + return new Object[][] { + {2012, Period.ofYears(0), 2012}, + {2012, Period.ofYears(1), 2013}, + {2012, Period.ofYears(2), 2014}, + {2012, Period.ofYears(-2), 2010}, + }; + } + + @Test(dataProvider="plusValid") + public void test_plusValid(int year, TemporalAmount amount, int expected) { + assertEquals(Year.of(year).plus(amount), Year.of(expected)); + } + + @DataProvider(name="plusInvalidUnit") + Object[][] data_plusInvalidUnit() { + return new Object[][] { + {Period.of(0, 1, 0)}, + {Period.of(0, 0, 1)}, + {Period.of(0, 1, 1)}, + {Period.of(1, 1, 1)}, + {Duration.ofDays(1)}, + {Duration.ofHours(1)}, + {Duration.ofMinutes(1)}, + {Duration.ofSeconds(1)}, + }; + } + + @Test(dataProvider="plusInvalidUnit", expectedExceptions=UnsupportedTemporalTypeException.class) + public void test_plusInvalidUnit(TemporalAmount amount) { + TEST_2008.plus(amount); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_plus_null() { + TEST_2008.plus(null); + } + + //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { assertEquals(Year.of(2007).plusYears(-1), Year.of(2006)); assertEquals(Year.of(2007).plusYears(0), Year.of(2007)); @@ -439,42 +493,84 @@ assertEquals(Year.of(Year.MIN_VALUE).plusYears(0), Year.of(Year.MIN_VALUE)); } - @Test(groups={"tck"}) + @Test public void test_plusYear_zero_equals() { Year base = Year.of(2007); assertEquals(base.plusYears(0), base); } - @Test(groups={"tck"}) + @Test public void test_plusYears_big() { long years = 20L + Year.MAX_VALUE; assertEquals(Year.of(-40).plusYears(years), Year.of((int) (-40L + years))); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_max() { Year.of(Year.MAX_VALUE).plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_maxLots() { Year.of(Year.MAX_VALUE).plusYears(1000); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_min() { Year.of(Year.MIN_VALUE).plusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_minLots() { Year.of(Year.MIN_VALUE).plusYears(-1000); } //----------------------------------------------------------------------- + // minus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="minusValid") + Object[][] data_minusValid() { + return new Object[][] { + {2012, Period.ofYears(0), 2012}, + {2012, Period.ofYears(1), 2011}, + {2012, Period.ofYears(2), 2010}, + {2012, Period.ofYears(-2), 2014}, + }; + } + + @Test(dataProvider="minusValid") + public void test_minusValid(int year, TemporalAmount amount, int expected) { + assertEquals(Year.of(year).minus(amount), Year.of(expected)); + } + + @DataProvider(name="minusInvalidUnit") + Object[][] data_minusInvalidUnit() { + return new Object[][] { + {Period.of(0, 1, 0)}, + {Period.of(0, 0, 1)}, + {Period.of(0, 1, 1)}, + {Period.of(1, 1, 1)}, + {Duration.ofDays(1)}, + {Duration.ofHours(1)}, + {Duration.ofMinutes(1)}, + {Duration.ofSeconds(1)}, + }; + } + + @Test(dataProvider="minusInvalidUnit", expectedExceptions=UnsupportedTemporalTypeException.class) + public void test_minusInvalidUnit(TemporalAmount amount) { + TEST_2008.minus(amount); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_minus_null() { + TEST_2008.minus(null); + } + + //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { assertEquals(Year.of(2007).minusYears(-1), Year.of(2008)); assertEquals(Year.of(2007).minusYears(0), Year.of(2007)); @@ -488,34 +584,34 @@ assertEquals(Year.of(Year.MIN_VALUE).minusYears(0), Year.of(Year.MIN_VALUE)); } - @Test(groups={"tck"}) + @Test public void test_minusYear_zero_equals() { Year base = Year.of(2007); assertEquals(base.minusYears(0), base); } - @Test(groups={"tck"}) + @Test public void test_minusYears_big() { long years = 20L + Year.MAX_VALUE; assertEquals(Year.of(40).minusYears(years), Year.of((int) (40L - years))); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_max() { Year.of(Year.MAX_VALUE).minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_maxLots() { Year.of(Year.MAX_VALUE).minusYears(-1000); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_min() { Year.of(Year.MIN_VALUE).minusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_minLots() { Year.of(Year.MIN_VALUE).minusYears(1000); } @@ -523,7 +619,7 @@ //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { LocalDate base = LocalDate.of(2007, 2, 12); for (int i = -4; i <= 2104; i++) { @@ -532,13 +628,13 @@ } } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { Year test = Year.of(2011); assertEquals(test.adjustInto(LocalDate.of(2012, 2, 29)), LocalDate.of(2011, 2, 28)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_nullLocalDate() { Year test = Year.of(1); test.adjustInto((LocalDate) null); @@ -547,7 +643,7 @@ //----------------------------------------------------------------------- // length() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_length() { assertEquals(Year.of(1999).length(), 365); assertEquals(Year.of(2000).length(), 366); @@ -606,6 +702,99 @@ } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {Year.of(2000), Year.of(-1), YEARS, -2001}, + {Year.of(2000), Year.of(0), YEARS, -2000}, + {Year.of(2000), Year.of(1), YEARS, -1999}, + {Year.of(2000), Year.of(1998), YEARS, -2}, + {Year.of(2000), Year.of(1999), YEARS, -1}, + {Year.of(2000), Year.of(2000), YEARS, 0}, + {Year.of(2000), Year.of(2001), YEARS, 1}, + {Year.of(2000), Year.of(2002), YEARS, 2}, + {Year.of(2000), Year.of(2246), YEARS, 246}, + + {Year.of(2000), Year.of(-1), DECADES, -200}, + {Year.of(2000), Year.of(0), DECADES, -200}, + {Year.of(2000), Year.of(1), DECADES, -199}, + {Year.of(2000), Year.of(1989), DECADES, -1}, + {Year.of(2000), Year.of(1990), DECADES, -1}, + {Year.of(2000), Year.of(1991), DECADES, 0}, + {Year.of(2000), Year.of(2000), DECADES, 0}, + {Year.of(2000), Year.of(2009), DECADES, 0}, + {Year.of(2000), Year.of(2010), DECADES, 1}, + {Year.of(2000), Year.of(2011), DECADES, 1}, + + {Year.of(2000), Year.of(-1), CENTURIES, -20}, + {Year.of(2000), Year.of(0), CENTURIES, -20}, + {Year.of(2000), Year.of(1), CENTURIES, -19}, + {Year.of(2000), Year.of(1899), CENTURIES, -1}, + {Year.of(2000), Year.of(1900), CENTURIES, -1}, + {Year.of(2000), Year.of(1901), CENTURIES, 0}, + {Year.of(2000), Year.of(2000), CENTURIES, 0}, + {Year.of(2000), Year.of(2099), CENTURIES, 0}, + {Year.of(2000), Year.of(2100), CENTURIES, 1}, + {Year.of(2000), Year.of(2101), CENTURIES, 1}, + + {Year.of(2000), Year.of(-1), MILLENNIA, -2}, + {Year.of(2000), Year.of(0), MILLENNIA, -2}, + {Year.of(2000), Year.of(1), MILLENNIA, -1}, + {Year.of(2000), Year.of(999), MILLENNIA, -1}, + {Year.of(2000), Year.of(1000), MILLENNIA, -1}, + {Year.of(2000), Year.of(1001), MILLENNIA, 0}, + {Year.of(2000), Year.of(2000), MILLENNIA, 0}, + {Year.of(2000), Year.of(2999), MILLENNIA, 0}, + {Year.of(2000), Year.of(3000), MILLENNIA, 1}, + {Year.of(2000), Year.of(3001), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(Year year1, Year year2, TemporalUnit unit, long expected) { + long amount = year1.periodUntil(year2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(Year year1, Year year2, TemporalUnit unit, long expected) { + long amount = year2.periodUntil(year1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2008.periodUntil(TEST_2008, MONTHS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2008.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2008.periodUntil(TEST_2008, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); + String t = Year.of(2010).format(f); + assertEquals(t, "2010"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + Year.of(2010).format(null); + } + + //----------------------------------------------------------------------- // atMonth(Month) //----------------------------------------------------------------------- @Test @@ -636,7 +825,7 @@ } //----------------------------------------------------------------------- - // atMonthDay(Month) + // atMonthDay(MonthDay) //----------------------------------------------------------------------- @DataProvider(name="atMonthDay") Object[][] data_atMonthDay() { @@ -661,7 +850,7 @@ //----------------------------------------------------------------------- // atDay(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atDay_notLeapYear() { Year test = Year.of(2007); LocalDate expected = LocalDate.of(2007, 1, 1); @@ -671,13 +860,13 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_notLeapYear_day366() { Year test = Year.of(2007); test.atDay(366); } - @Test(groups={"tck"}) + @Test public void test_atDay_leapYear() { Year test = Year.of(2008); LocalDate expected = LocalDate.of(2008, 1, 1); @@ -687,13 +876,13 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_day0() { Year test = Year.of(2007); test.atDay(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_day367() { Year test = Year.of(2007); test.atDay(367); @@ -702,7 +891,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -734,7 +923,7 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_nullYear() { Year doy = null; Year test = Year.of(1); @@ -744,7 +933,7 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -756,20 +945,20 @@ } } - @Test(groups={"tck"}) + @Test public void test_equals_same() { Year test = Year.of(2011); assertEquals(test.equals(test), true); } - @Test(groups={"tck"}) + @Test public void test_equals_nullYear() { Year doy = null; Year test = Year.of(1); assertEquals(test.equals(doy), false); } - @Test(groups={"tck"}) + @Test public void test_equals_incorrectType() { Year test = Year.of(1); assertEquals(test.equals("Incorrect type"), false); @@ -778,7 +967,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -786,19 +975,4 @@ } } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); - String t = Year.of(2010).toString(f); - assertEquals(t, "2010"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - Year.of(2010).toString(null); - } - } --- old/test/java/time/tck/java/time/TCKYearMonth.java 2013-04-11 23:17:33.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKYearMonth.java 2013-04-11 23:17:33.000000000 -0700 @@ -59,11 +59,19 @@ */ package tck.java.time; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -78,6 +86,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; +import java.time.Period; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; @@ -88,10 +97,11 @@ import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -110,7 +120,7 @@ private YearMonth TEST_2008_06; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2008_06 = YearMonth.of(2008, 6); } @@ -126,7 +136,7 @@ protected List validFields() { TemporalField[] array = { MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -171,7 +181,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { YearMonth expected = YearMonth.now(Clock.systemDefaultZone()); YearMonth test = YearMonth.now(); @@ -188,12 +198,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { YearMonth.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); YearMonth expected = YearMonth.now(Clock.system(zone)); @@ -211,7 +221,7 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -220,72 +230,72 @@ assertEquals(test.getMonth(), Month.DECEMBER); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { YearMonth.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intsMonth() { YearMonth test = YearMonth.of(2008, Month.FEBRUARY); check(test, 2008, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intsMonth_yearTooLow() { YearMonth.of(Year.MIN_VALUE - 1, Month.JANUARY); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intsMonth_dayTooHigh() { YearMonth.of(Year.MAX_VALUE + 1, Month.JANUARY); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_intsMonth_nullMonth() { YearMonth.of(2008, null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ints() { YearMonth test = YearMonth.of(2008, 2); check(test, 2008, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_yearTooLow() { YearMonth.of(Year.MIN_VALUE - 1, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooHigh() { YearMonth.of(Year.MAX_VALUE + 1, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooLow() { YearMonth.of(2008, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooHigh() { YearMonth.of(2008, 13); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(YearMonth.from(LocalDate.of(2007, 7, 15)), YearMonth.of(2007, 7)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { YearMonth.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { YearMonth.from((TemporalAccessor) null); } @@ -323,7 +333,7 @@ }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, YearMonth expected) { YearMonth yearMonth = YearMonth.parse(text); assertEquals(yearMonth, expected); @@ -351,7 +361,7 @@ }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { YearMonth.parse(text); @@ -364,12 +374,12 @@ } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Month() { YearMonth.parse("2008-13"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { YearMonth.parse(null); } @@ -377,20 +387,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); YearMonth test = YearMonth.parse("2010 12", f); assertEquals(test, YearMonth.of(2010, 12)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); YearMonth.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { YearMonth.parse("ANY", null); } @@ -400,19 +410,19 @@ //----------------------------------------------------------------------- @Test public void test_get_TemporalField() { - assertEquals(TEST_2008_06.get(ChronoField.YEAR), 2008); - assertEquals(TEST_2008_06.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(TEST_2008_06.get(ChronoField.YEAR_OF_ERA), 2008); - assertEquals(TEST_2008_06.get(ChronoField.ERA), 1); + assertEquals(TEST_2008_06.get(YEAR), 2008); + assertEquals(TEST_2008_06.get(MONTH_OF_YEAR), 6); + assertEquals(TEST_2008_06.get(YEAR_OF_ERA), 2008); + assertEquals(TEST_2008_06.get(ERA), 1); } @Test public void test_getLong_TemporalField() { - assertEquals(TEST_2008_06.getLong(ChronoField.YEAR), 2008); - assertEquals(TEST_2008_06.getLong(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(TEST_2008_06.getLong(ChronoField.YEAR_OF_ERA), 2008); - assertEquals(TEST_2008_06.getLong(ChronoField.ERA), 1); - assertEquals(TEST_2008_06.getLong(ChronoField.EPOCH_MONTH), (2008 - 1970) * 12 + 6 - 1); + assertEquals(TEST_2008_06.getLong(YEAR), 2008); + assertEquals(TEST_2008_06.getLong(MONTH_OF_YEAR), 6); + assertEquals(TEST_2008_06.getLong(YEAR_OF_ERA), 2008); + assertEquals(TEST_2008_06.getLong(ERA), 1); + assertEquals(TEST_2008_06.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 - 1); } //----------------------------------------------------------------------- @@ -421,13 +431,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_06, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_06, Queries.zoneId(), null}, - {TEST_2008_06, Queries.precision(), ChronoUnit.MONTHS}, - {TEST_2008_06, Queries.zone(), null}, - {TEST_2008_06, Queries.offset(), null}, - {TEST_2008_06, Queries.localDate(), null}, - {TEST_2008_06, Queries.localTime(), null}, + {TEST_2008_06, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_06, TemporalQuery.zoneId(), null}, + {TEST_2008_06, TemporalQuery.precision(), ChronoUnit.MONTHS}, + {TEST_2008_06, TemporalQuery.zone(), null}, + {TEST_2008_06, TemporalQuery.offset(), null}, + {TEST_2008_06, TemporalQuery.localDate(), null}, + {TEST_2008_06, TemporalQuery.localTime(), null}, }; } @@ -470,19 +480,19 @@ //----------------------------------------------------------------------- // with(Year) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Year() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Year.of(2000)), YearMonth.of(2000, 6)); } - @Test(groups={"tck"}) + @Test public void test_with_Year_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Year.of(2008)), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Year_null() { YearMonth test = YearMonth.of(2008, 6); test.with((Year) null); @@ -491,19 +501,19 @@ //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Month() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Month.JANUARY), YearMonth.of(2008, 1)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Month.JUNE), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Month_null() { YearMonth test = YearMonth.of(2008, 6); test.with((Month) null); @@ -512,25 +522,25 @@ //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withYear(1999), YearMonth.of(1999, 6)); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withYear(2008), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_tooLow() { YearMonth test = YearMonth.of(2008, 6); test.withYear(Year.MIN_VALUE - 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_tooHigh() { YearMonth test = YearMonth.of(2008, 6); test.withYear(Year.MAX_VALUE + 1); @@ -539,25 +549,25 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withMonth(1), YearMonth.of(2008, 1)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withMonth(6), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooLow() { YearMonth test = YearMonth.of(2008, 6); test.withMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooHigh() { YearMonth test = YearMonth.of(2008, 6); test.withMonth(13); @@ -566,49 +576,49 @@ //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(1), YearMonth.of(2009, 6)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(0), test); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(-1), YearMonth.of(2007, 6)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_big() { YearMonth test = YearMonth.of(-40, 6); assertEquals(test.plusYears(20L + Year.MAX_VALUE), YearMonth.of((int) (-40L + 20L + Year.MAX_VALUE), 6)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 6); test.plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 6); test.plusYears(-1); @@ -617,62 +627,62 @@ //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(1), YearMonth.of(2008, 7)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(0), test); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_overYears() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(7), YearMonth.of(2009, 1)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(-1), YearMonth.of(2008, 5)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeOverYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(-6), YearMonth.of(2007, 12)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_big() { YearMonth test = YearMonth.of(-40, 6); long months = 20L + Integer.MAX_VALUE; assertEquals(test.plusMonths(months), YearMonth.of((int) (-40L + months / 12), 6 + (int) (months % 12))); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 1); test.plusMonths(-1); @@ -681,49 +691,49 @@ //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(1), YearMonth.of(2007, 6)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(0), test); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(-1), YearMonth.of(2009, 6)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_big() { YearMonth test = YearMonth.of(40, 6); assertEquals(test.minusYears(20L + Year.MAX_VALUE), YearMonth.of((int) (40L - 20L - Year.MAX_VALUE), 6)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 6); test.minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxSubtractMax() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 12); test.minusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxSubtractMin() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 12); test.minusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 6); test.minusYears(1); @@ -732,62 +742,62 @@ //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(1), YearMonth.of(2008, 5)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(0), test); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_overYears() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(6), YearMonth.of(2007, 12)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(-1), YearMonth.of(2008, 7)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeOverYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(-7), YearMonth.of(2009, 1)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_big() { YearMonth test = YearMonth.of(40, 6); long months = 20L + Integer.MAX_VALUE; assertEquals(test.minusMonths(months), YearMonth.of((int) (40L - months / 12), 6 - (int) (months % 12))); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxSubtractMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxSubtractMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 1); test.minusMonths(1); @@ -796,35 +806,35 @@ //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { YearMonth test = YearMonth.of(2008, 6); LocalDate date = LocalDate.of(2007, 1, 1); assertEquals(test.adjustInto(date), LocalDate.of(2008, 6, 1)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_preserveDoM() { YearMonth test = YearMonth.of(2011, 3); LocalDate date = LocalDate.of(2008, 2, 29); assertEquals(test.adjustInto(date), LocalDate.of(2011, 3, 29)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { YearMonth test = YearMonth.of(2007, 2); LocalDate date = LocalDate.of(2008, 3, 31); assertEquals(test.adjustInto(date), LocalDate.of(2007, 2, 28)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_equal() { YearMonth test = YearMonth.of(2008, 6); LocalDate date = LocalDate.of(2008, 6, 30); assertEquals(test.adjustInto(date), date); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_null() { TEST_2008_06.adjustInto((LocalDate) null); } @@ -832,7 +842,7 @@ //----------------------------------------------------------------------- // isLeapYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeapYear() { assertEquals(YearMonth.of(2007, 6).isLeapYear(), false); assertEquals(YearMonth.of(2008, 6).isLeapYear(), true); @@ -841,19 +851,19 @@ //----------------------------------------------------------------------- // lengthOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_june() { YearMonth test = YearMonth.of(2007, 6); assertEquals(test.lengthOfMonth(), 30); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_febNonLeap() { YearMonth test = YearMonth.of(2007, 2); assertEquals(test.lengthOfMonth(), 28); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_febLeap() { YearMonth test = YearMonth.of(2008, 2); assertEquals(test.lengthOfMonth(), 29); @@ -862,7 +872,7 @@ //----------------------------------------------------------------------- // lengthOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfYear() { assertEquals(YearMonth.of(2007, 6).lengthOfYear(), 365); assertEquals(YearMonth.of(2008, 6).lengthOfYear(), 366); @@ -871,7 +881,7 @@ //----------------------------------------------------------------------- // isValidDay(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_june() { YearMonth test = YearMonth.of(2007, 6); assertEquals(test.isValidDay(1), true); @@ -883,7 +893,7 @@ assertEquals(test.isValidDay(32), false); } - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_febNonLeap() { YearMonth test = YearMonth.of(2007, 2); assertEquals(test.isValidDay(1), true); @@ -895,7 +905,7 @@ assertEquals(test.isValidDay(32), false); } - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_febLeap() { YearMonth test = YearMonth.of(2008, 2); assertEquals(test.isValidDay(1), true); @@ -908,6 +918,127 @@ } //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {ym(2000, 1), ym(-1, 12), MONTHS, -2000 * 12 - 1}, + {ym(2000, 1), ym(0, 1), MONTHS, -2000 * 12}, + {ym(2000, 1), ym(0, 12), MONTHS, -1999 * 12 - 1}, + {ym(2000, 1), ym(1, 1), MONTHS, -1999 * 12}, + {ym(2000, 1), ym(1999, 12), MONTHS, -1}, + {ym(2000, 1), ym(2000, 1), MONTHS, 0}, + {ym(2000, 1), ym(2000, 2), MONTHS, 1}, + {ym(2000, 1), ym(2000, 3), MONTHS, 2}, + {ym(2000, 1), ym(2000, 12), MONTHS, 11}, + {ym(2000, 1), ym(2001, 1), MONTHS, 12}, + {ym(2000, 1), ym(2246, 5), MONTHS, 246 * 12 + 4}, + + {ym(2000, 1), ym(-1, 12), YEARS, -2000}, + {ym(2000, 1), ym(0, 1), YEARS, -2000}, + {ym(2000, 1), ym(0, 12), YEARS, -1999}, + {ym(2000, 1), ym(1, 1), YEARS, -1999}, + {ym(2000, 1), ym(1998, 12), YEARS, -1}, + {ym(2000, 1), ym(1999, 1), YEARS, -1}, + {ym(2000, 1), ym(1999, 2), YEARS, 0}, + {ym(2000, 1), ym(1999, 12), YEARS, 0}, + {ym(2000, 1), ym(2000, 1), YEARS, 0}, + {ym(2000, 1), ym(2000, 2), YEARS, 0}, + {ym(2000, 1), ym(2000, 12), YEARS, 0}, + {ym(2000, 1), ym(2001, 1), YEARS, 1}, + {ym(2000, 1), ym(2246, 5), YEARS, 246}, + + {ym(2000, 5), ym(-1, 5), DECADES, -200}, + {ym(2000, 5), ym(0, 4), DECADES, -200}, + {ym(2000, 5), ym(0, 5), DECADES, -200}, + {ym(2000, 5), ym(0, 6), DECADES, -199}, + {ym(2000, 5), ym(1, 5), DECADES, -199}, + {ym(2000, 5), ym(1990, 4), DECADES, -1}, + {ym(2000, 5), ym(1990, 5), DECADES, -1}, + {ym(2000, 5), ym(1990, 6), DECADES, 0}, + {ym(2000, 5), ym(2000, 4), DECADES, 0}, + {ym(2000, 5), ym(2000, 5), DECADES, 0}, + {ym(2000, 5), ym(2000, 6), DECADES, 0}, + {ym(2000, 5), ym(2010, 4), DECADES, 0}, + {ym(2000, 5), ym(2010, 5), DECADES, 1}, + {ym(2000, 5), ym(2010, 6), DECADES, 1}, + + {ym(2000, 5), ym(-1, 5), CENTURIES, -20}, + {ym(2000, 5), ym(0, 4), CENTURIES, -20}, + {ym(2000, 5), ym(0, 5), CENTURIES, -20}, + {ym(2000, 5), ym(0, 6), CENTURIES, -19}, + {ym(2000, 5), ym(1, 5), CENTURIES, -19}, + {ym(2000, 5), ym(1900, 4), CENTURIES, -1}, + {ym(2000, 5), ym(1900, 5), CENTURIES, -1}, + {ym(2000, 5), ym(1900, 6), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 4), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 5), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 6), CENTURIES, 0}, + {ym(2000, 5), ym(2100, 4), CENTURIES, 0}, + {ym(2000, 5), ym(2100, 5), CENTURIES, 1}, + {ym(2000, 5), ym(2100, 6), CENTURIES, 1}, + + {ym(2000, 5), ym(-1, 5), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 4), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 5), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 6), MILLENNIA, -1}, + {ym(2000, 5), ym(1, 5), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 4), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 5), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 6), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 4), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 5), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 6), MILLENNIA, 0}, + {ym(2000, 5), ym(3000, 4), MILLENNIA, 0}, + {ym(2000, 5), ym(3000, 5), MILLENNIA, 1}, + {ym(2000, 5), ym(3000, 5), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) { + long amount = ym1.periodUntil(ym2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) { + long amount = ym2.periodUntil(ym1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2008_06.periodUntil(TEST_2008_06, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2008_06.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2008_06.periodUntil(TEST_2008_06, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); + String t = YearMonth.of(2010, 12).format(f); + assertEquals(t, "2010 12"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + YearMonth.of(2010, 12).format(null); + } + + //----------------------------------------------------------------------- // atDay(int) //----------------------------------------------------------------------- @DataProvider(name="atDay") @@ -975,7 +1106,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_YearMonth( YearMonth.of(-1, 1), @@ -1015,17 +1146,17 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2008_06.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2008_06.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2008_06.isAfter(null); } @@ -1033,7 +1164,7 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { YearMonth a = YearMonth.of(2008, 6); YearMonth b = YearMonth.of(2008, 6); @@ -1061,17 +1192,17 @@ assertEquals(d.equals(d), true); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2008_06.equals(TEST_2008_06), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2008_06.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2008_06.equals(null), false); } @@ -1079,7 +1210,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int y, int m) { YearMonth a = YearMonth.of(y, m); assertEquals(a.hashCode(), a.hashCode()); @@ -1087,7 +1218,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_unique() { Set uniques = new HashSet(201 * 12); for (int i = 1900; i <= 2100; i++) { @@ -1111,26 +1242,15 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, String expected) { YearMonth test = YearMonth.of(y, m); String str = test.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); - String t = YearMonth.of(2010, 12).toString(f); - assertEquals(t, "2010 12"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - YearMonth.of(2010, 12).toString(null); + private YearMonth ym(int year, int month) { + return YearMonth.of(year, month); } } --- old/test/java/time/tck/java/time/TCKZoneId.java 2013-04-11 23:17:33.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKZoneId.java 2013-04-11 23:17:33.000000000 -0700 @@ -64,23 +64,24 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamConstants; import java.lang.reflect.Field; import java.time.DateTimeException; +import java.time.Instant; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.temporal.Queries; +import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.zone.ZoneRulesException; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.Set; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -114,9 +115,12 @@ // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); - // getting the ID and string are OK + // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); + assertEquals(deser, deser); + assertEquals(deser.hashCode(), deser.hashCode()); + assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); @@ -133,32 +137,32 @@ deserialize("|!?"); } - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="offsetBasedValid") public void test_deserialization_lenient_offsetNotAllowed_noPrefix(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize(input); - } - - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("UTC" + input); - } - - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("GMT" + input); - } - - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("UT" + input); + ZoneId deserialized = deserialize(input); + assertEquals(deserialized, ZoneId.of(input)); + assertEquals(deserialized, ZoneId.of(resolvedId)); + } + + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("UTC" + input); + assertEquals(deserialized, ZoneId.of("UTC" + input)); + assertEquals(deserialized, ZoneId.of("UTC" + resolvedId)); + } + + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("GMT" + input); + assertEquals(deserialized, ZoneId.of("GMT" + input)); + assertEquals(deserialized, ZoneId.of("GMT" + resolvedId)); + } + + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("UT" + input); + assertEquals(deserialized, ZoneId.of("UT" + input)); + assertEquals(deserialized, ZoneId.of("UT" + resolvedId)); } private ZoneId deserialize(String id) throws Exception { @@ -193,10 +197,10 @@ } //----------------------------------------------------------------------- - // OLD_IDS_PRE_2005 + // OLD_SHORT_IDS //----------------------------------------------------------------------- public void test_constant_OLD_IDS_PRE_2005() { - Map ids = ZoneId.OLD_IDS_PRE_2005; + Map ids = ZoneId.OLD_SHORT_IDS; assertEquals(ids.get("EST"), "America/New_York"); assertEquals(ids.get("MST"), "America/Denver"); assertEquals(ids.get("HST"), "Pacific/Honolulu"); @@ -229,15 +233,15 @@ @Test(expectedExceptions=UnsupportedOperationException.class) public void test_constant_OLD_IDS_PRE_2005_immutable() { - Map ids = ZoneId.OLD_IDS_PRE_2005; + Map ids = ZoneId.OLD_SHORT_IDS; ids.clear(); } //----------------------------------------------------------------------- - // OLD_IDS_POST_2005 + // SHORT_IDS //----------------------------------------------------------------------- public void test_constant_OLD_IDS_POST_2005() { - Map ids = ZoneId.OLD_IDS_POST_2005; + Map ids = ZoneId.SHORT_IDS; assertEquals(ids.get("EST"), "-05:00"); assertEquals(ids.get("MST"), "-07:00"); assertEquals(ids.get("HST"), "-10:00"); @@ -270,11 +274,24 @@ @Test(expectedExceptions=UnsupportedOperationException.class) public void test_constant_OLD_IDS_POST_2005_immutable() { - Map ids = ZoneId.OLD_IDS_POST_2005; + Map ids = ZoneId.SHORT_IDS; ids.clear(); } //----------------------------------------------------------------------- + // getAvailableZoneIds() + //----------------------------------------------------------------------- + @Test + public void test_getAvailableGroupIds() { + Set zoneIds = ZoneId.getAvailableZoneIds(); + assertEquals(zoneIds.contains("Europe/London"), true); + zoneIds.clear(); + assertEquals(zoneIds.size(), 0); + Set zoneIds2 = ZoneId.getAvailableZoneIds(); + assertEquals(zoneIds2.contains("Europe/London"), true); + } + + //----------------------------------------------------------------------- // mapped factory //----------------------------------------------------------------------- @Test @@ -315,65 +332,41 @@ } //----------------------------------------------------------------------- - // regular factory - //----------------------------------------------------------------------- - @DataProvider(name="offsetBasedZero") - Object[][] data_offsetBasedZero() { - return new Object[][] { - {""}, {"0"}, - {"+00"},{"+0000"},{"+00:00"},{"+000000"},{"+00:00:00"}, - {"-00"},{"-0000"},{"-00:00"},{"-000000"},{"-00:00:00"}, - }; - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_noPrefix(String id) { - if (id.length() > 0 && id.equals("0") == false) { - ZoneId test = ZoneId.of(id); - assertEquals(test, ZoneOffset.UTC); - } - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixUTC(String id) { - ZoneId test = ZoneId.of("UTC" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixGMT(String id) { - ZoneId test = ZoneId.of("GMT" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixUT(String id) { - ZoneId test = ZoneId.of("UT" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test - public void factory_of_String_offsetBasedZero_z() { - ZoneId test = ZoneId.of("Z"); - assertEquals(test, ZoneOffset.UTC); - } - + // regular factory and .normalized() //----------------------------------------------------------------------- @DataProvider(name="offsetBasedValid") Object[][] data_offsetBasedValid() { return new Object[][] { + {"Z", "Z"}, {"+0", "Z"}, + {"-0", "Z"}, + {"+00", "Z"}, + {"+0000", "Z"}, + {"+00:00", "Z"}, + {"+000000", "Z"}, + {"+00:00:00", "Z"}, + {"-00", "Z"}, + {"-0000", "Z"}, + {"-00:00", "Z"}, + {"-000000", "Z"}, + {"-00:00:00", "Z"}, {"+5", "+05:00"}, {"+01", "+01:00"}, - {"+0100", "+01:00"},{"+01:00", "+01:00"}, - {"+010000", "+01:00"},{"+01:00:00", "+01:00"}, + {"+0100", "+01:00"}, + {"+01:00", "+01:00"}, + {"+010000", "+01:00"}, + {"+01:00:00", "+01:00"}, {"+12", "+12:00"}, - {"+1234", "+12:34"},{"+12:34", "+12:34"}, - {"+123456", "+12:34:56"},{"+12:34:56", "+12:34:56"}, + {"+1234", "+12:34"}, + {"+12:34", "+12:34"}, + {"+123456", "+12:34:56"}, + {"+12:34:56", "+12:34:56"}, {"-02", "-02:00"}, {"-5", "-05:00"}, - {"-0200", "-02:00"},{"-02:00", "-02:00"}, - {"-020000", "-02:00"},{"-02:00:00", "-02:00"}, + {"-0200", "-02:00"}, + {"-02:00", "-02:00"}, + {"-020000", "-02:00"}, + {"-02:00:00", "-02:00"}, }; } @@ -382,27 +375,126 @@ ZoneId test = ZoneId.of(input); assertEquals(test.getId(), id); assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.normalized(), ZoneOffset.of(id)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(id)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixUTC(String input, String id) { + //----------------------------------------------------------------------- + @DataProvider(name="offsetBasedValidPrefix") + Object[][] data_offsetBasedValidPrefix() { + return new Object[][] { + {"", "", "Z"}, + {"+0", "", "Z"}, + {"-0", "", "Z"}, + {"+00", "", "Z"}, + {"+0000", "", "Z"}, + {"+00:00", "", "Z"}, + {"+000000", "", "Z"}, + {"+00:00:00", "", "Z"}, + {"-00", "", "Z"}, + {"-0000", "", "Z"}, + {"-00:00", "", "Z"}, + {"-000000", "", "Z"}, + {"-00:00:00", "", "Z"}, + {"+5", "+05:00", "+05:00"}, + {"+01", "+01:00", "+01:00"}, + {"+0100", "+01:00", "+01:00"}, + {"+01:00", "+01:00", "+01:00"}, + {"+010000", "+01:00", "+01:00"}, + {"+01:00:00", "+01:00", "+01:00"}, + {"+12", "+12:00", "+12:00"}, + {"+1234", "+12:34", "+12:34"}, + {"+12:34", "+12:34", "+12:34"}, + {"+123456", "+12:34:56", "+12:34:56"}, + {"+12:34:56", "+12:34:56", "+12:34:56"}, + {"-02", "-02:00", "-02:00"}, + {"-5", "-05:00", "-05:00"}, + {"-0200", "-02:00", "-02:00"}, + {"-02:00", "-02:00", "-02:00"}, + {"-020000", "-02:00", "-02:00"}, + {"-02:00:00", "-02:00", "-02:00"}, + }; + } + + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixUTC(String input, String id, String offsetId) { ZoneId test = ZoneId.of("UTC" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "UTC" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("UTC" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixGMT(String input, String id) { + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixGMT(String input, String id, String offsetId) { ZoneId test = ZoneId.of("GMT" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "GMT" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("GMT" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixUT(String input, String id) { + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixUT(String input, String id, String offsetId) { ZoneId test = ZoneId.of("UT" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "UT" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("UT" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); + } + + private String displayName(String id) { + if (id.equals("GMT")) { + return "Greenwich Mean Time"; + } + if (id.equals("GMT0")) { + return "Greenwich Mean Time"; + } + if (id.equals("UTC")) { + return "Coordinated Universal Time"; + } + return id; + } + + //----------------------------------------------------------------------- + @DataProvider(name="offsetBasedValidOther") + Object[][] data_offsetBasedValidOther() { + return new Object[][] { + {"GMT", "Z"}, + {"GMT0", "Z"}, + {"UCT", "Z"}, + {"Greenwich", "Z"}, + {"Universal", "Z"}, + {"Zulu", "Z"}, + {"Etc/GMT", "Z"}, + {"Etc/GMT+0", "Z"}, + {"Etc/GMT+1", "-01:00"}, + {"Etc/GMT-1", "+01:00"}, + {"Etc/GMT+9", "-09:00"}, + {"Etc/GMT-9", "+09:00"}, + {"Etc/GMT0", "Z"}, + {"Etc/UCT", "Z"}, + {"Etc/UTC", "Z"}, + {"Etc/Greenwich", "Z"}, + {"Etc/Universal", "Z"}, + {"Etc/Zulu", "Z"}, + }; + } + + @Test(dataProvider="offsetBasedValidOther") + public void factory_of_String_offsetBasedValidOther(String input, String offsetId) { + ZoneId test = ZoneId.of(input); + assertEquals(test.getId(), input); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); } //----------------------------------------------------------------------- @@ -422,6 +514,12 @@ {"-19"}, {"-19:00"}, {"-18:01"}, {"-18:00:01"}, {"-1801"}, {"-180001"}, {"-01_00"}, {"-01;00"}, {"-01@00"}, {"-01:AA"}, {"@01:00"}, + {"0"}, + {"UT0"}, + {"UTZ"}, + {"UTC0"}, + {"UTCZ"}, + {"GMTZ"}, // GMT0 is valid in ZoneRulesProvider }; } @@ -440,6 +538,9 @@ @Test(dataProvider="offsetBasedInvalid", expectedExceptions=DateTimeException.class) public void factory_of_String_offsetBasedInvalid_prefixGMT(String id) { + if (id.equals("0")) { + throw new DateTimeException("Fake exception: GMT0 is valid, not invalid"); + } ZoneId.of("GMT" + id); } @@ -479,6 +580,7 @@ ZoneId test = ZoneId.of("Europe/London"); assertEquals(test.getId(), "Europe/London"); assertEquals(test.getRules().isFixedOffset(), false); + assertEquals(test.normalized(), test); } //----------------------------------------------------------------------- @@ -514,7 +616,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) ZoneId.of("Europe/Paris"); } return TemporalAccessor.super.query(query); @@ -578,8 +680,10 @@ {"Europe/London", "Europe/London"}, {"Europe/Paris", "Europe/Paris"}, {"Europe/Berlin", "Europe/Berlin"}, - {"UTC", "Z"}, - {"UTC+01:00", "+01:00"}, + {"Z", "Z"}, + {"+01:00", "+01:00"}, + {"UTC", "UTC"}, + {"UTC+01:00", "UTC+01:00"}, }; } --- old/test/java/time/tck/java/time/TCKZoneOffset.java 2013-04-11 23:17:34.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKZoneOffset.java 2013-04-11 23:17:34.000000000 -0700 @@ -77,7 +77,6 @@ import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -183,7 +182,7 @@ //----------------------------------------------------------------------- // of(String) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_string_UTC() { String[] values = new String[] { "Z", "+0", @@ -196,7 +195,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_factory_string_invalid() { String[] values = new String[] { "","A","B","C","D","E","F","G","H","I","J","K","L","M", @@ -223,13 +222,13 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_string_null() { ZoneOffset.of((String) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_string_singleDigitHours() { for (int i = -9; i <= 9; i++) { String str = (i < 0 ? "-" : "+") + Math.abs(i); @@ -238,7 +237,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours() { for (int i = -18; i <= 18; i++) { String str = (i < 0 ? "-" : "+") + Integer.toString(Math.abs(i) + 100).substring(1); @@ -247,7 +246,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_noColon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -266,7 +265,7 @@ doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_colon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -285,7 +284,7 @@ doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_seconds_noColon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -308,7 +307,7 @@ doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_seconds_colon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -332,7 +331,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours() { for (int i = -18; i <= 18; i++) { ZoneOffset test = ZoneOffset.ofHours(i); @@ -340,18 +339,18 @@ } } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_tooBig() { ZoneOffset.ofHours(19); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_tooSmall() { ZoneOffset.ofHours(-19); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours_minutes() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -367,18 +366,18 @@ doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_tooBig() { ZoneOffset.ofHoursMinutes(19, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_tooSmall() { ZoneOffset.ofHoursMinutes(-19, 0); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours_minutes_seconds() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -397,80 +396,80 @@ doTestOffset(test2, 18, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_plusHoursMinusMinutes() { ZoneOffset.ofHoursMinutesSeconds(1, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_plusHoursMinusSeconds() { ZoneOffset.ofHoursMinutesSeconds(1, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minusHoursPlusMinutes() { ZoneOffset.ofHoursMinutesSeconds(-1, 1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minusHoursPlusSeconds() { ZoneOffset.ofHoursMinutesSeconds(-1, 0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_zeroHoursMinusMinutesPlusSeconds() { ZoneOffset.ofHoursMinutesSeconds(0, -1, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_zeroHoursPlusMinutesMinusSeconds() { ZoneOffset.ofHoursMinutesSeconds(0, 1, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minutesTooLarge() { ZoneOffset.ofHoursMinutesSeconds(0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minutesTooSmall() { ZoneOffset.ofHoursMinutesSeconds(0, -60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_secondsTooLarge() { ZoneOffset.ofHoursMinutesSeconds(0, 0, 60); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_secondsTooSmall() { ZoneOffset.ofHoursMinutesSeconds(0, 0, 60); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_hoursTooBig() { ZoneOffset.ofHoursMinutesSeconds(19, 0, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_hoursTooSmall() { ZoneOffset.ofHoursMinutesSeconds(-19, 0, 0); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_ofTotalSeconds() { assertEquals(ZoneOffset.ofTotalSeconds(60 * 60 + 1), ZoneOffset.ofHoursMinutesSeconds(1, 0, 1)); assertEquals(ZoneOffset.ofTotalSeconds(18 * 60 * 60), ZoneOffset.ofHours(18)); assertEquals(ZoneOffset.ofTotalSeconds(-18 * 60 * 60), ZoneOffset.ofHours(-18)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ofTotalSeconds_tooLarge() { ZoneOffset.ofTotalSeconds(18 * 60 * 60 + 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ofTotalSeconds_tooSmall() { ZoneOffset.ofTotalSeconds(-18 * 60 * 60 - 1); } @@ -478,18 +477,18 @@ //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(ZoneOffset.from(ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30)), ZoneOffset.ofHours(2))), ZoneOffset.ofHours(2)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { ZoneOffset.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { ZoneOffset.from((TemporalAccessor) null); } @@ -497,7 +496,7 @@ //----------------------------------------------------------------------- // getTotalSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getTotalSeconds() { ZoneOffset offset = ZoneOffset.ofTotalSeconds(60 * 60 + 1); assertEquals(offset.getTotalSeconds(), 60 * 60 + 1); @@ -506,7 +505,7 @@ //----------------------------------------------------------------------- // getId() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getId() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.getId(), "+01:00"); @@ -519,7 +518,7 @@ //----------------------------------------------------------------------- // getRules() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getRules() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); assertEquals(offset.getRules().isFixedOffset(), true); @@ -562,13 +561,13 @@ @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {ZoneOffset.UTC, Queries.chronology(), null}, - {ZoneOffset.UTC, Queries.zoneId(), null}, - {ZoneOffset.UTC, Queries.precision(), null}, - {ZoneOffset.UTC, Queries.zone(), ZoneOffset.UTC}, - {ZoneOffset.UTC, Queries.offset(), ZoneOffset.UTC}, - {ZoneOffset.UTC, Queries.localDate(), null}, - {ZoneOffset.UTC, Queries.localTime(), null}, + {ZoneOffset.UTC, TemporalQuery.chronology(), null}, + {ZoneOffset.UTC, TemporalQuery.zoneId(), null}, + {ZoneOffset.UTC, TemporalQuery.precision(), null}, + {ZoneOffset.UTC, TemporalQuery.zone(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQuery.offset(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQuery.localDate(), null}, + {ZoneOffset.UTC, TemporalQuery.localTime(), null}, }; } @@ -590,7 +589,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4); @@ -603,7 +602,7 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4); @@ -623,7 +622,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.toString(), "+01:00"); --- old/test/java/time/tck/java/time/TCKZonedDateTime.java 2013-04-11 23:17:35.000000000 -0700 +++ new/test/java/time/tck/java/time/TCKZonedDateTime.java 2013-04-11 23:17:34.000000000 -0700 @@ -59,8 +59,6 @@ */ package tck.java.time; -import java.time.*; - import static java.time.Month.JANUARY; import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; @@ -73,7 +71,6 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -88,6 +85,7 @@ import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; @@ -103,28 +101,35 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import java.time.Clock; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.Year; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.JulianFields; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; -import java.time.chrono.IsoChronology; -import java.time.temporal.JulianFields; -import test.java.time.temporal.MockFieldNoValue; - -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.time.OffsetDateTime; -import java.time.Year; +import java.time.temporal.TemporalQuery; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -153,7 +158,7 @@ private ZonedDateTime TEST_DATE_TIME; private ZonedDateTime TEST_DATE_TIME_PARIS; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_LOCAL_2008_06_30_11_30_59_500 = LocalDateTime.of(2008, 6, 30, 11, 30, 59, 500); TEST_DATE_TIME = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); @@ -196,7 +201,7 @@ ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -267,7 +272,7 @@ //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { ZonedDateTime expected = ZonedDateTime.now(Clock.systemDefaultZone()); ZonedDateTime test = ZonedDateTime.now(); @@ -284,12 +289,12 @@ //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { ZonedDateTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); ZonedDateTime expected = ZonedDateTime.now(Clock.system(zone)); @@ -307,12 +312,12 @@ //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { - ZonedDateTime.now((Clock)null); + ZonedDateTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -330,7 +335,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_zone() { ZoneId zone = ZoneId.of("Europe/London"); for (int i = 0; i < (2 * 24 * 60 * 60); i++) { @@ -342,7 +347,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -359,7 +364,7 @@ } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(1970, 1, 1, 12, 0), ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -393,35 +398,35 @@ //----------------------------------------------------------------------- // of(LocalDate, LocalTime, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime() { ZonedDateTime test = ZonedDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500), ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime_inGap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_GAP_2008_03_30_02_30.toLocalDate(), TEST_PARIS_GAP_2008_03_30_02_30.toLocalTime(), ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime_inOverlap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30.toLocalDate(), TEST_PARIS_OVERLAP_2008_10_26_02_30.toLocalTime(), ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time in summer offset } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullDate() { ZonedDateTime.of((LocalDate) null, LocalTime.of(11, 30, 10, 500), ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullTime() { ZonedDateTime.of(LocalDate.of(2008, 6, 30), (LocalTime) null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullZone() { ZonedDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500), null); } @@ -429,31 +434,31 @@ //----------------------------------------------------------------------- // of(LocalDateTime, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime() { LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime test = ZonedDateTime.of(base, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime_inGap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_GAP_2008_03_30_02_30, ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime_inOverlap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time in summer offset } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTime_nullDateTime() { ZonedDateTime.of((LocalDateTime) null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTime_nullZone() { LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime.of(base, null); @@ -462,7 +467,7 @@ //----------------------------------------------------------------------- // of(int..., ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_ints() { ZonedDateTime test = ZonedDateTime.of(2008, 6, 30, 11, 30, 10, 500, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); @@ -471,49 +476,49 @@ //----------------------------------------------------------------------- // ofInstant(Instant, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_ZR() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 35).toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 35, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_ZO() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 45).toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_0200); check(test, 2008, 6, 30, 11, 30, 10, 45, OFFSET_0200, OFFSET_0200); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inGap() { Instant instant = TEST_PARIS_GAP_2008_03_30_02_30.toInstant(OFFSET_0100); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inOverlap_earlier() { Instant instant = TEST_PARIS_OVERLAP_2008_10_26_02_30.toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time and offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inOverlap_later() { Instant instant = TEST_PARIS_OVERLAP_2008_10_26_02_30.toInstant(OFFSET_0100); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS); // same time and offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_invalidOffset() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).toInstant(OFFSET_0130); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 6, 30, 12, 0, 10, 500, OFFSET_0200, ZONE_PARIS); // corrected offset, thus altered time } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -527,7 +532,7 @@ } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allDaysInCycle() { // sanity check using different algorithm ZonedDateTime expected = LocalDateTime.of(1970, 1, 1, 0, 0, 0, 0).atZone(ZoneOffset.UTC); @@ -539,7 +544,7 @@ } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; @@ -556,7 +561,7 @@ assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; @@ -573,7 +578,7 @@ assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; @@ -590,7 +595,7 @@ assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; @@ -608,19 +613,19 @@ } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_maxInstantWithMaxOffset() { Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); ZonedDateTime.ofInstant(instant, OFFSET_MAX); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_maxInstantWithMinOffset() { Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); ZonedDateTime.ofInstant(instant, OFFSET_MIN); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_tooBig() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); long year = Year.MAX_VALUE + 1L; @@ -629,7 +634,7 @@ ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_tooLow() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE - 1; @@ -638,12 +643,12 @@ ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_Instant_nullInstant() { ZonedDateTime.ofInstant((Instant) null, ZONE_0100); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_Instant_nullZone() { ZonedDateTime.ofInstant(Instant.EPOCH, null); } @@ -651,14 +656,14 @@ //----------------------------------------------------------------------- // ofStrict(LocalDateTime, ZoneId, ZoneOffset) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofStrict_LDT_ZI_ZO() { LocalDateTime normal = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime test = ZonedDateTime.ofStrict(normal, OFFSET_0200, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_inGap() { try { ZonedDateTime.ofStrict(TEST_PARIS_GAP_2008_03_30_02_30, OFFSET_0100, ZONE_PARIS); @@ -668,7 +673,7 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_inOverlap_invalidOfset() { try { ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0130, ZONE_PARIS); @@ -678,7 +683,7 @@ } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_invalidOffset() { try { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0130, ZONE_PARIS); @@ -688,17 +693,17 @@ } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullLDT() { ZonedDateTime.ofStrict((LocalDateTime) null, OFFSET_0100, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullZO() { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullZI() { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0100, null); } @@ -706,12 +711,12 @@ //----------------------------------------------------------------------- // from(TemporalAccessor) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_ZDT() { assertEquals(ZonedDateTime.from(TEST_DATE_TIME_PARIS), TEST_DATE_TIME_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_LDT_ZoneId() { assertEquals(ZonedDateTime.from(new TemporalAccessor() { @Override @@ -725,7 +730,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -733,7 +738,7 @@ }), TEST_DATE_TIME_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_Instant_ZoneId() { assertEquals(ZonedDateTime.from(new TemporalAccessor() { @Override @@ -749,7 +754,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -757,12 +762,12 @@ }), TEST_DATE_TIME_PARIS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { ZonedDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { ZonedDateTime.from((TemporalAccessor) null); } @@ -814,17 +819,17 @@ assertEquals(t.getZone().getId(), zoneId); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { ZonedDateTime.parse("2008-06-32T11:15+01:00[Europe/Paris]"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { ZonedDateTime.parse("2008-06-31T11:15+01:00[Europe/Paris]"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { ZonedDateTime.parse((String) null); } @@ -832,20 +837,20 @@ //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s VV"); ZonedDateTime test = ZonedDateTime.parse("2010 12 3 11 30 0 Europe/London", f); assertEquals(test, ZonedDateTime.of(LocalDateTime.of(2010, 12, 3, 11, 30), ZoneId.of("Europe/London"))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); ZonedDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { ZonedDateTime.parse("ANY", null); } @@ -865,7 +870,7 @@ }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneId zone) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -941,32 +946,32 @@ //----------------------------------------------------------------------- @Test public void test_query_chrono() { - assertEquals(TEST_DATE_TIME.query(Queries.chronology()), IsoChronology.INSTANCE); - assertEquals(Queries.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.chronology()), IsoChronology.INSTANCE); + assertEquals(TemporalQuery.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); } @Test public void test_query_zoneId() { - assertEquals(TEST_DATE_TIME.query(Queries.zoneId()), TEST_DATE_TIME.getZone()); - assertEquals(Queries.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.zoneId()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQuery.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test public void test_query_precision() { - assertEquals(TEST_DATE_TIME.query(Queries.precision()), NANOS); - assertEquals(Queries.precision().queryFrom(TEST_DATE_TIME), NANOS); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.precision()), NANOS); + assertEquals(TemporalQuery.precision().queryFrom(TEST_DATE_TIME), NANOS); } @Test public void test_query_offset() { - assertEquals(TEST_DATE_TIME.query(Queries.offset()), TEST_DATE_TIME.getOffset()); - assertEquals(Queries.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.offset()), TEST_DATE_TIME.getOffset()); + assertEquals(TemporalQuery.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); } @Test public void test_query_zone() { - assertEquals(TEST_DATE_TIME.query(Queries.zone()), TEST_DATE_TIME.getZone()); - assertEquals(Queries.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.zone()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQuery.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test(expectedExceptions=NullPointerException.class) @@ -977,14 +982,14 @@ //----------------------------------------------------------------------- // withEarlierOffsetAtOverlap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_notAtOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); assertEquals(test, base); // not changed } - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_atOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0100, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); @@ -992,7 +997,7 @@ assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); // date-time not changed } - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_atOverlap_noChange() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); @@ -1002,14 +1007,14 @@ //----------------------------------------------------------------------- // withLaterOffsetAtOverlap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_notAtOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); assertEquals(test, base); // not changed } - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_atOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); @@ -1017,7 +1022,7 @@ assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); // date-time not changed } - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_atOverlap_noChange() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0100, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); @@ -1027,7 +1032,7 @@ //----------------------------------------------------------------------- // withZoneSameLocal(ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1035,7 +1040,7 @@ assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); } - @Test(groups={"tck","implementation"}) + @Test public void test_withZoneSameLocal_noChange() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1043,7 +1048,7 @@ assertEquals(test, base); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal_retainOffset1() { LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0); // overlap ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-04:00") ); @@ -1052,7 +1057,7 @@ assertEquals(test.getOffset(), ZoneOffset.ofHours(-4)); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal_retainOffset2() { LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0); // overlap ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-05:00") ); @@ -1061,7 +1066,7 @@ assertEquals(test.getOffset(), ZoneOffset.ofHours(-5)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withZoneSameLocal_null() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1071,7 +1076,7 @@ //----------------------------------------------------------------------- // withZoneSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneSameInstant() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withZoneSameInstant(ZONE_0200); @@ -1079,14 +1084,14 @@ assertEquals(test, expected); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameInstant_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withZoneSameInstant(ZONE_0100); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withZoneSameInstant_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.withZoneSameInstant(null); @@ -1095,7 +1100,7 @@ //----------------------------------------------------------------------- // withFixedOffsetZone() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneLocked() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.withFixedOffsetZone(); @@ -1104,67 +1109,67 @@ } //----------------------------------------------------------------------- - // with(WithAdjuster) + // with(TemporalAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDateTime_sameOffset() { + @Test + public void test_with_adjuster_LocalDateTime_sameOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 7, 15, 14, 30)); check(test, 2012, 7, 15, 14, 30, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDateTime_adjustedOffset() { + @Test + public void test_with_adjuster_LocalDateTime_adjustedOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 1, 15, 14, 30)); check(test, 2012, 1, 15, 14, 30, 0, 0, OFFSET_0100, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate() { + @Test + public void test_with_adjuster_LocalDate() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDate.of(2012, 7, 28)); check(test, 2012, 7, 28, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalTime() { + @Test + public void test_with_adjuster_LocalTime() { ZonedDateTime base = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30, ZONE_PARIS); ZonedDateTime test = base.with(LocalTime.of(2, 29)); check(test, 2008, 10, 26, 2, 29, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Year() { + @Test + public void test_with_adjuster_Year() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); ZonedDateTime test = base.with(Year.of(2007)); assertEquals(test, ZonedDateTime.of(ldt.withYear(2007), ZONE_0100)); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Month_adjustedDayOfMonth() { + @Test + public void test_with_adjuster_Month_adjustedDayOfMonth() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(Month.JUNE); check(test, 2012, 6, 30, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Offset_same() { + @Test + public void test_with_adjuster_Offset_same() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(2)); check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Offset_timeAdjust() { + @Test + public void test_with_adjuster_Offset_timeAdjust() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(1)); - check(test, 2012, 7, 31, 1, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // time adjusted + check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // invalid offset ignored } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate_retainOffset1() { + @Test + public void test_with_adjuster_LocalDate_retainOffset1() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 1, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); @@ -1173,8 +1178,8 @@ assertEquals(test.getOffset(), ZoneOffset.ofHours(-4)); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate_retainOffset2() { + @Test + public void test_with_adjuster_LocalDate_retainOffset2() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 3, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); @@ -1183,23 +1188,176 @@ assertEquals(test.getOffset(), ZoneOffset.ofHours(-5)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_with_WithAdjuster_null() { + @Test + public void test_with_adjuster_OffsetDateTime_validOffsetNotInOverlap() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0200); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetDateTime_invalidOffsetIgnored() { + // ODT has invalid offset for ZDT, so only LDT is set + OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0130); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toLocalDateTime(), TEST_LOCAL_2008_06_30_11_30_59_500); + assertEquals(test.getOffset(), zdt.getOffset()); + } + + @Test + public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); + ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap2() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0200); + ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetNotInOverlap() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0100); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); + } + + @Test + public void test_with_adjuster_OffsetTime_invalidOffsetIgnored1() { + // OT has invalid offset for ZDT, so only LT is set + OffsetTime ot = OffsetTime.of(0, 50, 30, 40, OFFSET_0130); + ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0200); // offset not adjusted + } + + @Test + public void test_with_adjuster_OffsetTime_invalidOffsetIgnored2() { + // OT has invalid offset for ZDT, so only LT is set + OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0130); + ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); // offset adjusted because of time change + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100); // valid offset in overlap + ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap2() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0200); // valid offset in overlap + ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0200); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_with_adjuster_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.with((TemporalAdjuster) null); } //----------------------------------------------------------------------- + // with(long,TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name = "withFieldLong") + Object[][] data_withFieldLong() { + return new Object[][] { + // set simple fields + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), YEAR, 2009, + dateTime(2009, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), MONTH_OF_YEAR, 7, + dateTime(2008, 7, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), DAY_OF_MONTH, 15, + dateTime(2008, 6, 15, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), HOUR_OF_DAY, 14, + dateTime(2008, 6, 30, 14, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + + // set around overlap + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), HOUR_OF_DAY, 0, + dateTime(2008, 10, 26, 0, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), HOUR_OF_DAY, 0, + dateTime(2008, 10, 26, 0, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), MINUTE_OF_HOUR, 20, + dateTime(2008, 10, 26, 2, 20, 0, 0, OFFSET_0200, ZONE_PARIS)}, // offset unchanged + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), MINUTE_OF_HOUR, 20, + dateTime(2008, 10, 26, 2, 20, 0, 0, OFFSET_0100, ZONE_PARIS)}, // offset unchanged + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), HOUR_OF_DAY, 3, + dateTime(2008, 10, 26, 3, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), HOUR_OF_DAY, 3, + dateTime(2008, 10, 26, 3, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + + // set offset + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), OFFSET_SECONDS, 7200, + dateTime(2008, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, // offset unchanged + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), OFFSET_SECONDS, 3600, + dateTime(2008, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, // invalid offset ignored + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), OFFSET_SECONDS, 3600, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), OFFSET_SECONDS, 3600, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), OFFSET_SECONDS, 7200, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), OFFSET_SECONDS, 7200, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + }; + }; + + @Test(dataProvider = "withFieldLong") + public void test_with_fieldLong(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + assertEquals(base.with(setField, setValue), expected); + } + + @Test(dataProvider = "withFieldLong") + public void test_with_adjuster_ensureZoneOffsetConsistent(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + if (setField == OFFSET_SECONDS) { + assertEquals(base.with(ZoneOffset.ofTotalSeconds(setValue)), expected); + } + } + + @Test(dataProvider = "withFieldLong") + public void test_with_adjuster_ensureOffsetDateTimeConsistent(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + if (setField == OFFSET_SECONDS) { + OffsetDateTime odt = base.toOffsetDateTime().with(setField, setValue); + assertEquals(base.with(odt), expected); + } + } + + //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withYear(2007); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withYear(2007), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withYear_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withYear(2008); @@ -1209,14 +1367,14 @@ //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_Month_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.with(JANUARY); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMonth(1), ZONE_0100)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_withMonth_Month_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.with((Month) null); @@ -1225,26 +1383,26 @@ //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMonth(1); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMonth(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMonth(6); assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooBig() { TEST_DATE_TIME.withMonth(13); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooSmall() { TEST_DATE_TIME.withMonth(0); } @@ -1252,31 +1410,31 @@ //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfMonth(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withDayOfMonth(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfMonth(30); assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooBig() { LocalDateTime.of(2007, 7, 2, 11, 30).atZone(ZONE_PARIS).withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooSmall() { TEST_DATE_TIME.withDayOfMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid31() { LocalDateTime.of(2007, 6, 2, 11, 30).atZone(ZONE_PARIS).withDayOfMonth(31); } @@ -1284,14 +1442,14 @@ //----------------------------------------------------------------------- // withDayOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfYear(33); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withDayOfYear(33), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_noChange() { LocalDateTime ldt = LocalDateTime.of(2008, 2, 5, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1299,17 +1457,17 @@ assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_tooBig() { TEST_DATE_TIME.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_tooSmall() { TEST_DATE_TIME.withDayOfYear(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid366() { LocalDateTime.of(2007, 2, 2, 11, 30).atZone(ZONE_PARIS).withDayOfYear(366); } @@ -1317,14 +1475,14 @@ //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withHour(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withHour(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withHour(11); @@ -1334,14 +1492,14 @@ //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMinute(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMinute(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMinute(30); @@ -1351,14 +1509,14 @@ //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withSecond(12); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withSecond(12), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withSecond(59); @@ -1368,14 +1526,14 @@ //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withNano(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withNano(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withNano(500); @@ -1385,14 +1543,14 @@ //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_DATE_TIME.truncatedTo(NANOS), TEST_DATE_TIME); assertEquals(TEST_DATE_TIME.truncatedTo(SECONDS), TEST_DATE_TIME.withNano(0)); assertEquals(TEST_DATE_TIME.truncatedTo(DAYS), TEST_DATE_TIME.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_DATE_TIME.truncatedTo(null); } @@ -1444,22 +1602,22 @@ //----------------------------------------------------------------------- // plus(TemporalAmount) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plus_TemporalAmount_Period_days(ZonedDateTime base, int amount, ZonedDateTime expected) { assertEquals(base.plus(Period.ofDays(amount)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_TemporalAmount_Period_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(MockSimplePeriod.of(amount, HOURS)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_TemporalAmount_Duration_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(Duration.ofHours(amount)), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1467,7 +1625,7 @@ assertEquals(t.plus(period), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Duration() { Duration duration = Duration.ofSeconds(4L * 60 * 60 + 5L * 60 + 6L); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1475,19 +1633,19 @@ assertEquals(t.plus(duration), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Period_zero() { ZonedDateTime t = TEST_DATE_TIME.plus(MockSimplePeriod.ZERO_DAYS); assertEquals(t, TEST_DATE_TIME); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Duration_zero() { ZonedDateTime t = TEST_DATE_TIME.plus(Duration.ZERO); assertEquals(t, TEST_DATE_TIME); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_TemporalAmount_null() { TEST_DATE_TIME.plus((TemporalAmount) null); } @@ -1495,32 +1653,32 @@ //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plus_longUnit_days(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount, DAYS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount, HOURS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_minutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 60, MINUTES), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_seconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 3600, SECONDS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_nanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 3600_000_000_000L, NANOS), expected); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longUnit_null() { TEST_DATE_TIME_PARIS.plus(0, null); } @@ -1528,7 +1686,7 @@ //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1536,7 +1694,7 @@ assertEquals(test, ZonedDateTime.of(ldt.plusYears(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1547,7 +1705,7 @@ //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1555,7 +1713,7 @@ assertEquals(test, ZonedDateTime.of(ldt.plusMonths(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1566,7 +1724,7 @@ //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusWeeks() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1574,7 +1732,7 @@ assertEquals(test, ZonedDateTime.of(ldt.plusWeeks(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1585,7 +1743,7 @@ //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plusDays(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusDays(amount), expected); } @@ -1593,7 +1751,7 @@ //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusHours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusHours(amount), expected); } @@ -1601,12 +1759,12 @@ //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusMinutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusMinutes(amount * 60), expected); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_minutes() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1617,12 +1775,12 @@ //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusSeconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusSeconds(amount * 3600), expected); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_seconds() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1633,12 +1791,12 @@ //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusNanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusNanos(amount * 3600_000_000_000L), expected); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_nanos() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1649,22 +1807,22 @@ //----------------------------------------------------------------------- // minus(TemporalAmount) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_minus_TemporalAmount_Period_days(ZonedDateTime base, int amount, ZonedDateTime expected) { assertEquals(base.minus(Period.ofDays(-amount)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minus_TemporalAmount_Period_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minus(MockSimplePeriod.of(-amount, HOURS)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minus_TemporalAmount_Duration_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minus(Duration.ofHours(-amount)), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1672,7 +1830,7 @@ assertEquals(t.minus(period), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Duration() { Duration duration = Duration.ofSeconds(4L * 60 * 60 + 5L * 60 + 6L); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1680,19 +1838,19 @@ assertEquals(t.minus(duration), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Period_zero() { ZonedDateTime t = TEST_DATE_TIME.minus(MockSimplePeriod.ZERO_DAYS); assertEquals(t, TEST_DATE_TIME); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Duration_zero() { ZonedDateTime t = TEST_DATE_TIME.minus(Duration.ZERO); assertEquals(t, TEST_DATE_TIME); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_TemporalAmount_null() { TEST_DATE_TIME.minus((TemporalAmount) null); } @@ -1700,7 +1858,7 @@ //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1708,7 +1866,7 @@ assertEquals(test, ZonedDateTime.of(ldt.minusYears(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1719,7 +1877,7 @@ //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1727,7 +1885,7 @@ assertEquals(test, ZonedDateTime.of(ldt.minusMonths(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1738,7 +1896,7 @@ //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusWeeks() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1746,7 +1904,7 @@ assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1757,7 +1915,7 @@ //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_minusDays(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusDays(-amount), expected); } @@ -1765,7 +1923,7 @@ //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusHours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusHours(-amount), expected); } @@ -1773,12 +1931,12 @@ //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusMinutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusMinutes(-amount * 60), expected); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_minutes() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1789,12 +1947,12 @@ //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusSeconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusSeconds(-amount * 3600), expected); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_seconds() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1805,12 +1963,12 @@ //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusNanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusNanos(-amount * 3600_000_000_000L), expected); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_nanos() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1824,32 +1982,35 @@ // TODO: more tests for period between two different zones // compare results to OffsetDateTime.periodUntil, especially wrt dates - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_periodUntil_days(ZonedDateTime base, long expected, ZonedDateTime end) { + if (base.toLocalTime().equals(end.toLocalTime()) == false) { + return; // avoid DST gap input values + } assertEquals(base.periodUntil(end, DAYS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_hours(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, HOURS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_minutes(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, MINUTES), expected * 60); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_seconds(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, SECONDS), expected * 3600); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_nanos(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, NANOS), expected * 3600_000_000_000L); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_parisLondon() { ZonedDateTime midnightLondon = LocalDate.of(2012, 6, 28).atStartOfDay(ZONE_LONDON); ZonedDateTime midnightParis1 = LocalDate.of(2012, 6, 29).atStartOfDay(ZONE_PARIS); @@ -1865,7 +2026,7 @@ assertEquals(midnightLondon.periodUntil(midnightParis2, DAYS), 1); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_gap() { ZonedDateTime before = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).atZone(ZONE_PARIS); ZonedDateTime after = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).plusDays(1).atZone(ZONE_PARIS); @@ -1874,7 +2035,7 @@ assertEquals(before.periodUntil(after, DAYS), 1); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_overlap() { ZonedDateTime before = TEST_PARIS_OVERLAP_2008_10_26_02_30.withHour(0).withMinute(0).atZone(ZONE_PARIS); ZonedDateTime after = TEST_PARIS_OVERLAP_2008_10_26_02_30.withHour(0).withMinute(0).plusDays(1).atZone(ZONE_PARIS); @@ -1883,25 +2044,40 @@ assertEquals(before.periodUntil(after, DAYS), 1); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_periodUntil_differentType() { TEST_DATE_TIME_PARIS.periodUntil(TEST_LOCAL_2008_06_30_11_30_59_500, DAYS); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_periodUntil_nullTemporal() { TEST_DATE_TIME_PARIS.periodUntil(null, DAYS); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_periodUntil_nullUnit() { TEST_DATE_TIME_PARIS.periodUntil(TEST_DATE_TIME_PARIS, null); } //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).format(f); + assertEquals(t, "2010 12 3 11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).format(null); + } + + //----------------------------------------------------------------------- // toOffsetDateTime() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toOffsetDateTime() { assertEquals(TEST_DATE_TIME.toOffsetDateTime(), OffsetDateTime.of(TEST_DATE_TIME.toLocalDateTime(), TEST_DATE_TIME.getOffset())); } @@ -1923,7 +2099,7 @@ }; } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_UTC(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZoneOffset.UTC); Instant test = dt.toInstant(); @@ -1931,7 +2107,7 @@ assertEquals(test.getNano(), expectedNos); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_P0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_0100); Instant test = dt.toInstant(); @@ -1939,7 +2115,7 @@ assertEquals(test.getNano(), expectedNos); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_M0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_M0100); Instant test = dt.toInstant(); @@ -1950,7 +2126,7 @@ //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1); for (int i = 0; i < 100000; i++) { @@ -1960,7 +2136,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1); for (int i = 0; i < 100000; i++) { @@ -1970,19 +2146,19 @@ } } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_UTC(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZoneOffset.UTC); assertEquals(dt.toEpochSecond(), expectedEpSec); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_P0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_0100); assertEquals(dt.toEpochSecond(), expectedEpSec - 3600); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_M0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_M0100); assertEquals(dt.toEpochSecond(), expectedEpSec + 3600); @@ -1991,7 +2167,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_time1() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0100); // a is before b due to time @@ -2001,7 +2177,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_time2() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 4, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 5, ZONE_0100); // a is before b due to time @@ -2011,7 +2187,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset1() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100); // a is before b due to offset @@ -2021,7 +2197,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset2() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 5, ZoneId.of("UTC+01:01")); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 4, ZONE_0100); // a is before b due to offset @@ -2031,7 +2207,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 50, 0, 0, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 20, 0, 0, ZONE_0100); // a is before b on instant scale @@ -2041,7 +2217,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNanos() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 20, 40, 5, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 10, 20, 40, 6, ZONE_0100); // a is before b on instant scale @@ -2051,7 +2227,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 10, 0, 0, 0, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 0, 0, 0, ZONE_0200); // a is before b despite being same time-line time @@ -2061,7 +2237,7 @@ assertEquals(b.compareTo(b) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.compareTo(null); @@ -2079,7 +2255,7 @@ }; } - @Test(dataProvider="IsBefore", groups={"tck"}) + @Test(dataProvider="IsBefore") public void test_isBefore(int hour1, int minute1, ZoneId zone1, int hour2, int minute2, ZoneId zone2, boolean expected) { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, hour1, minute1, 0, 0, zone1); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, hour2, minute2, 0, 0, zone2); @@ -2089,7 +2265,7 @@ assertEquals(b.isBefore(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.isBefore(null); @@ -2107,7 +2283,7 @@ }; } - @Test(dataProvider="IsAfter", groups={"tck"}) + @Test(dataProvider="IsAfter") public void test_isAfter(int hour1, int minute1, ZoneId zone1, int hour2, int minute2, ZoneId zone2, boolean expected) { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, hour1, minute1, 0, 0, zone1); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, hour2, minute2, 0, 0, zone2); @@ -2117,7 +2293,7 @@ assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.isAfter(null); @@ -2126,60 +2302,60 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_year_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y + 1, o, d, h, m, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { h = (h == 23 ? 22 : h); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h + 1, m, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { m = (m == 59 ? 58 : m); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m + 1, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { s = (s == 59 ? 58 : s); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s + 1, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { n = (n == 999999999 ? 999999998 : n); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n + 1), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0200); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_DATE_TIME.equals(TEST_DATE_TIME), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_DATE_TIME.equals("2007-07-15"), false); } @@ -2204,28 +2380,13 @@ }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int o, int d, int h, int m, int s, int n, String zoneId, String expected) { ZonedDateTime t = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZoneId.of(zoneId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).toString(f); - assertEquals(t, "2010 12 3 11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).toString(null); - } - //------------------------------------------------------------------------- private static LocalDateTime dateTime( int year, int month, int dayOfMonth, --- old/test/java/time/tck/java/time/TestIsoChronology.java 2013-04-11 23:17:35.000000000 -0700 +++ new/test/java/time/tck/java/time/TestIsoChronology.java 2013-04-11 23:17:35.000000000 -0700 @@ -59,8 +59,8 @@ */ package tck.java.time; -import static java.time.chrono.IsoChronology.ERA_BCE; -import static java.time.chrono.IsoChronology.ERA_CE; +import static java.time.chrono.IsoEra.BCE; +import static java.time.chrono.IsoEra.CE; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; @@ -73,13 +73,14 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Month; -import java.time.temporal.Adjusters; -import java.time.temporal.ChronoField; -import java.time.chrono.HijrahChronology; import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahEra; import java.time.chrono.IsoChronology; +import java.time.chrono.IsoEra; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAdjuster; import org.testng.Assert; import org.testng.annotations.DataProvider; @@ -94,7 +95,7 @@ //----------------------------------------------------------------------- // Chronology.ofName("ISO") Lookup by name //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_chrono_byName() { Chronology c = IsoChronology.INSTANCE; Chronology test = Chronology.of("ISO"); @@ -107,7 +108,7 @@ //----------------------------------------------------------------------- // Lookup by Singleton //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void instanceNotNull() { assertNotNull(IsoChronology.INSTANCE); } @@ -115,10 +116,10 @@ //----------------------------------------------------------------------- // Era creation //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_eraOf() { - assertEquals(IsoChronology.INSTANCE.eraOf(0), ERA_BCE); - assertEquals(IsoChronology.INSTANCE.eraOf(1), ERA_CE); + assertEquals(IsoChronology.INSTANCE.eraOf(0), BCE); + assertEquals(IsoChronology.INSTANCE.eraOf(1), CE); } //----------------------------------------------------------------------- @@ -144,12 +145,12 @@ }; } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_toLocalDate(LocalDate isoDate, LocalDate iso) { assertEquals(LocalDate.from(isoDate), iso); } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_fromCalendrical(LocalDate isoDate, LocalDate iso) { assertEquals(IsoChronology.INSTANCE.date(iso), isoDate); } @@ -174,18 +175,18 @@ }; } - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) public void test_badDates(int year, int month, int dom) { IsoChronology.INSTANCE.date(year, month, dom); } - @Test(groups="tck") + @Test public void test_date_withEra() { int year = 5; int month = 5; int dayOfMonth = 5; - LocalDate test = IsoChronology.INSTANCE.date(ERA_BCE, year, month, dayOfMonth); - assertEquals(test.getEra(), ERA_BCE); + LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth); + assertEquals(test.getEra(), IsoEra.BCE); assertEquals(test.get(ChronoField.YEAR_OF_ERA), year); assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month); assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth); @@ -196,39 +197,39 @@ } @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test(expectedExceptions=DateTimeException.class, groups="tck") + @Test(expectedExceptions=ClassCastException.class) public void test_date_withEra_withWrongEra() { - IsoChronology.INSTANCE.date((Era) HijrahChronology.ERA_AH, 1, 1, 1); + IsoChronology.INSTANCE.date((Era) HijrahEra.AH, 1, 1, 1); } //----------------------------------------------------------------------- // with(DateTimeAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust1() { LocalDate base = IsoChronology.INSTANCE.date(1728, 10, 28); - LocalDate test = base.with(Adjusters.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 10, 31)); } - @Test(groups={"tck"}) + @Test public void test_adjust2() { LocalDate base = IsoChronology.INSTANCE.date(1728, 12, 2); - LocalDate test = base.with(Adjusters.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 12, 31)); } //----------------------------------------------------------------------- // ISODate.with(Local*) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust_toLocalDate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4); LocalDate test = isoDate.with(LocalDate.of(2012, 7, 6)); assertEquals(test, IsoChronology.INSTANCE.date(2012, 7, 6)); } - @Test(groups={"tck"}) + @Test public void test_adjust_toMonth() { LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4); assertEquals(IsoChronology.INSTANCE.date(1726, 4, 4), isoDate.with(Month.APRIL)); @@ -237,14 +238,14 @@ //----------------------------------------------------------------------- // LocalDate.with(ISODate) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_LocalDate_adjustToISODate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29); LocalDate test = LocalDate.MIN.with(isoDate); assertEquals(test, LocalDate.of(1728, 10, 29)); } - @Test(groups={"tck"}) + @Test public void test_LocalDateTime_adjustToISODate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29); LocalDateTime test = LocalDateTime.MIN.with(isoDate); @@ -266,7 +267,7 @@ }; } - @Test(dataProvider="leapYears", groups="tck") + @Test(dataProvider="leapYears") public void test_isLeapYear(int year, boolean isLeapYear) { assertEquals(IsoChronology.INSTANCE.isLeapYear(year), isLeapYear); } @@ -274,7 +275,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_now() { assertEquals(LocalDate.from(IsoChronology.INSTANCE.dateNow()), LocalDate.now()); } @@ -293,7 +294,7 @@ }; } - @Test(dataProvider="toString", groups={"tck"}) + @Test(dataProvider="toString") public void test_toString(LocalDate isoDate, String expected) { assertEquals(isoDate.toString(), expected); } @@ -301,12 +302,12 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equals_true() { assertTrue(IsoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); } - @Test(groups="tck") + @Test public void test_equals_false() { assertFalse(IsoChronology.INSTANCE.equals(HijrahChronology.INSTANCE)); } --- old/test/java/time/tck/java/time/chrono/CopticChronology.java 2013-04-11 23:17:36.000000000 -0700 +++ new/test/java/time/tck/java/time/chrono/CopticChronology.java 2013-04-11 23:17:36.000000000 -0700 @@ -59,18 +59,17 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import java.io.Serializable; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.time.DateTimeException; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.ValueRange; import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.Era; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + /** * The Coptic calendar system. *

    @@ -102,16 +101,6 @@ * Singleton instance of the Coptic chronology. */ public static final CopticChronology INSTANCE = new CopticChronology(); - /** - * The singleton instance for the era BEFORE_AM. - * This has the numeric value of {@code 0}. - */ - public static final Era ERA_BEFORE_AM = CopticEra.BEFORE_AM; - /** - * The singleton instance for the era AM - 'Era of the Martyrs'. - * This has the numeric value of {@code 1}. - */ - public static final Era ERA_AM = CopticEra.AM; /** * Serialization version. @@ -193,6 +182,11 @@ } @Override + public CopticDate dateEpochDay(long epochDay) { + return CopticDate.ofEpochDay(epochDay); + } + + @Override public CopticDate date(TemporalAccessor dateTime) { if (dateTime instanceof CopticDate) { return (CopticDate) dateTime; @@ -219,7 +213,7 @@ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof CopticEra == false) { - throw new DateTimeException("Era must be CopticEra"); + throw new ClassCastException("Era must be CopticEra"); } return (era == CopticEra.AM ? yearOfEra : 1 - yearOfEra); } @@ -241,7 +235,7 @@ case DAY_OF_MONTH: return ValueRange.of(1, 5, 30); case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 1, 5); case MONTH_OF_YEAR: return ValueRange.of(1, 13); - case EPOCH_MONTH: return ValueRange.of(-1000, 1000); // TODO + case PROLEPTIC_MONTH: return ValueRange.of(-1000, 1000); // TODO case YEAR_OF_ERA: return ValueRange.of(1, 999, 1000); // TODO case YEAR: return ValueRange.of(-1000, 1000); // TODO } --- old/test/java/time/tck/java/time/chrono/CopticDate.java 2013-04-11 23:17:37.000000000 -0700 +++ new/test/java/time/tck/java/time/chrono/CopticDate.java 2013-04-11 23:17:36.000000000 -0700 @@ -68,6 +68,7 @@ import java.time.DateTimeException; import java.time.LocalDate; import java.time.Period; +import java.time.Year; import java.time.chrono.ChronoLocalDate; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; @@ -75,7 +76,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalUnit; import java.time.temporal.ValueRange; -import java.time.Year; +import java.time.temporal.UnsupportedTemporalTypeException; /** * A date in the Coptic calendar system. @@ -201,7 +202,7 @@ } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -223,7 +224,7 @@ case YEAR: return prolepticYear; case ERA: return (prolepticYear >= 1 ? 1 : 0); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -248,7 +249,7 @@ case YEAR: return resolvePreviousValid(nvalue, month, day); case ERA: return resolvePreviousValid(1 - prolepticYear, month, day); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -267,7 +268,7 @@ case CENTURIES: return plusYears(Math.multiplyExact(amountToAdd, 100)); case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); } - throw new DateTimeException(unit.getName() + " not valid for CopticDate"); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } --- old/test/java/time/tck/java/time/chrono/CopticEra.java 2013-04-11 23:17:37.000000000 -0700 +++ new/test/java/time/tck/java/time/chrono/CopticEra.java 2013-04-11 23:17:37.000000000 -0700 @@ -71,7 +71,7 @@ *

    Implementation notes

    * This is an immutable and thread-safe enum. */ -enum CopticEra implements Era { +public enum CopticEra implements Era { /** * The singleton instance for the era BEFORE_AM, 'Before Era of the Martyrs'. @@ -118,21 +118,4 @@ return ordinal(); } - @Override - public CopticChronology getChronology() { - return CopticChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public CopticDate date(int year, int month, int day) { - return (CopticDate)(getChronology().date(this, year, month, day)); - } - - @Override - public CopticDate dateYearDay(int year, int dayOfYear) { - return (CopticDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - } --- old/test/java/time/tck/java/time/chrono/TCKChronology.java 2013-04-11 23:17:38.000000000 -0700 +++ new/test/java/time/tck/java/time/chrono/TCKChronology.java 2013-04-11 23:17:38.000000000 -0700 @@ -4,9 +4,7 @@ * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -24,7 +22,12 @@ */ /* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * @@ -57,217 +60,189 @@ package tck.java.time.chrono; import static org.testng.Assert.assertEquals; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.time.DateTimeException; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; -import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; -import java.time.temporal.ValueRange; -import java.util.List; +import java.util.Locale; +import java.util.Set; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * Test. + * Test Chronology class. */ @Test public class TCKChronology { - // Can only work with IsoChronology here - // others may be in separate module - @Test - public void factory_from_TemporalAccessor_dateWithChronlogy() { - assertEquals(Chronology.from(LocalDate.of(2012, 6, 30)), IsoChronology.INSTANCE); + //----------------------------------------------------------------------- + // regular data factory for ID and calendarType of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendarNameAndType") + Object[][] data_of_calendars() { + return new Object[][] { + {"Hijrah-umalqura", "islamic-umalqura"}, + {"ISO", "iso8601"}, + {"Japanese", "japanese"}, + {"Minguo", "roc"}, + {"ThaiBuddhist", "buddhist"}, + }; + } + + @Test(dataProvider = "calendarNameAndType") + public void test_getters(String chronoId, String calendarSystemType) { + Chronology chrono = Chronology.of(chronoId); + assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); + assertEquals(chrono.getId(), chronoId); + assertEquals(chrono.getCalendarType(), calendarSystemType); + } + + @Test(dataProvider = "calendarNameAndType") + public void test_required_calendars(String chronoId, String calendarSystemType) { + Chronology chrono = Chronology.of(chronoId); + assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); + chrono = Chronology.of(calendarSystemType); + assertNotNull(chrono, "Required calendar not found by type: " + chronoId); + Set cals = Chronology.getAvailableChronologies(); + assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars"); } @Test - public void factory_from_TemporalAccessor_chronology() { - assertEquals(Chronology.from(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - throw new UnsupportedOperationException(); - } - @Override - public long getLong(TemporalField field) { - throw new UnsupportedOperationException(); - } - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) IsoChronology.INSTANCE; - } - throw new UnsupportedOperationException(); - } - }), IsoChronology.INSTANCE); - } - - @Test - public void factory_from_TemporalAccessor_noChronology() { - assertEquals(Chronology.from(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - throw new UnsupportedOperationException(); - } - - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return null; - } - throw new UnsupportedOperationException(); - } - }), IsoChronology.INSTANCE); - } - - @Test(expectedExceptions=NullPointerException.class) - public void factory_from_TemporalAccessor_null() { - Chronology.from(null); + public void test_calendar_list() { + Set chronos = Chronology.getAvailableChronologies(); + assertNotNull(chronos, "Required list of calendars must be non-null"); + for (Chronology chrono : chronos) { + Chronology lookup = Chronology.of(chrono.getId()); + assertNotNull(lookup, "Required calendar not found: " + chrono); + } + assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size() + + ", expected >= " + data_of_calendars().length); + } + + /** + * Compute the number of days from the Epoch and compute the date from the number of days. + */ + @Test(dataProvider = "calendarNameAndType") + public void test_epoch(String name, String alias) { + Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded + ChronoLocalDate date1 = chrono.dateNow(); + long epoch1 = date1.getLong(ChronoField.EPOCH_DAY); + ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1); + assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2); + long epoch2 = date1.getLong(ChronoField.EPOCH_DAY); + assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2); + } + + @Test(dataProvider = "calendarNameAndType") + public void test_dateEpochDay(String name, String alias) { + Chronology chrono = Chronology.of(name); + ChronoLocalDate date = chrono.dateNow(); + long epochDay = date.getLong(ChronoField.EPOCH_DAY); + ChronoLocalDate test = chrono.dateEpochDay(epochDay); + assertEquals(test, date); } //----------------------------------------------------------------------- - @Test - public void test_date_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.date(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - throw new UnsupportedOperationException(); - } - }), LocalDate.of(2012, 6, 30)); - } - - @Test(expectedExceptions=NullPointerException.class) - public void test_date_TemporalAccessor_null() { - IsoChronology.INSTANCE.date(null); - } - + // locale based lookup //----------------------------------------------------------------------- - @Test - public void test_localDateTime_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.localDateTime(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - if (field == ChronoField.NANO_OF_DAY) { - return LocalTime.of(12, 30, 40).toNanoOfDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - if (query == Queries.localTime()) { - return (R) LocalTime.of(12, 30, 40); - } - throw new UnsupportedOperationException(); - } - }), LocalDateTime.of(2012, 6, 30, 12, 30, 40)); - } - - @Test(expectedExceptions=NullPointerException.class) - public void test_localDateTime_TemporalAccessor_null() { - IsoChronology.INSTANCE.localDateTime(null); + @DataProvider(name = "calendarsystemtype") + Object[][] data_CalendarType() { + return new Object[][] { + {HijrahChronology.INSTANCE, "islamic", "umalqura"}, + {IsoChronology.INSTANCE, "iso8601", null}, + {JapaneseChronology.INSTANCE, "japanese", null}, + {MinguoChronology.INSTANCE, "roc", null}, + {ThaiBuddhistChronology.INSTANCE, "buddhist", null}, + }; + } + + @Test(dataProvider = "calendarsystemtype") + public void test_getCalendarType(Chronology chrono, String calendarType, String variant) { + String type = calendarType; + if (variant != null) { + type += '-'; + type += variant; + } + assertEquals(chrono.getCalendarType(), type); + } + + @Test(dataProvider = "calendarsystemtype") + public void test_lookupLocale(Chronology chrono, String calendarType, String variant) { + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", calendarType); + if (variant != null) { + builder.setUnicodeLocaleKeyword("cv", variant); + } + Locale locale = builder.build(); + assertEquals(Chronology.ofLocale(locale), chrono); + } + + + /** + * Test lookup by calendarType of each chronology. + * The calendarType is split on "-" to separate the calendar and variant. + * Verify that the calendar can be found by {@link java.time.chrono.Chronology#ofLocale}. + */ + @Test + public void test_ofLocaleByType() { + // Test that all available chronologies can be successfully found using ofLocale + Set chronos = Chronology.getAvailableChronologies(); + for (Chronology chrono : chronos) { + String[] split = chrono.getCalendarType().split("-"); + + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", split[0]); + if (split.length > 1) { + builder.setUnicodeLocaleKeyword("cv", split[1]); + } + Locale locale = builder.build(); + assertEquals(Chronology.ofLocale(locale), chrono, "Lookup by type and variant"); + } + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_lookupLocale() { + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", "xxx"); + builder.setUnicodeLocaleKeyword("cv", "yyy"); + + Locale locale = builder.build(); + Chronology.ofLocale(locale); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_noChrono() { + Chronology chrono = Chronology.of("FooFoo"); } //----------------------------------------------------------------------- - @Test - public void test_zonedDateTime_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.zonedDateTime(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY || - field == ChronoField.INSTANT_SECONDS || field == ChronoField.NANO_OF_SECOND) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.INSTANT_SECONDS) { - return ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London")).toEpochSecond(); - } - if (field == ChronoField.NANO_OF_SECOND) { - return 0; - } - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - if (field == ChronoField.NANO_OF_DAY) { - return LocalTime.of(12, 30, 40).toNanoOfDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - if (query == Queries.localTime()) { - return (R) LocalTime.of(12, 30, 40); - } - if (query == Queries.zoneId() || query == Queries.zone()) { - return (R) ZoneId.of("Europe/London"); - } - throw new UnsupportedOperationException(); - } - }), ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London"))); - } - - @Test(expectedExceptions=NullPointerException.class) - public void test_zonedDateTime_TemporalAccessor_null() { - IsoChronology.INSTANCE.zonedDateTime(null); + // serialization; serialize and check each calendar system + //----------------------------------------------------------------------- + @Test(dataProvider = "calendarNameAndType") + public void test_chronoSerializationSingleton(String id, String _calendarType) throws Exception { + Chronology original = Chronology.of(id); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(original); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, original, "Deserialized Chronology is not correct"); } } --- old/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java 2013-04-11 23:17:38.000000000 -0700 +++ new/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java 2013-04-11 23:17:38.000000000 -0700 @@ -60,9 +60,13 @@ import static org.testng.Assert.assertEquals; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.time.LocalDate; -import java.time.chrono.Chronology; import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; import org.testng.annotations.Test; @@ -73,7 +77,7 @@ @Test public class TCKTestServiceLoader { - @Test(groups={"tck"}) + @Test public void test_CopticServiceLoader() { Chronology chrono = Chronology.of("Coptic"); ChronoLocalDate copticDate = chrono.date(1729, 4, 27); @@ -81,4 +85,22 @@ assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate"); } + + //----------------------------------------------------------------------- + // Test Serialization of Loaded Coptic Calendar + //----------------------------------------------------------------------- + @Test + public void test_ChronoSerialization() throws Exception { + Chronology chrono = Chronology.of("Coptic"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(chrono); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, chrono, "deserialized Chronology is wrong"); + } } --- old/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java 2013-04-11 23:17:39.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java 2013-04-11 23:17:39.000000000 -0700 @@ -67,8 +67,8 @@ import java.time.chrono.JapaneseChronology; import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; @@ -122,7 +122,7 @@ TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text, pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(Queries.chronology()), expected); + assertEquals(parsed.query(TemporalQuery.chronology()), expected); } @Test(dataProvider="parseValid") @@ -140,7 +140,7 @@ TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text.toLowerCase(Locale.ENGLISH), pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(Queries.chronology()), expected); + assertEquals(parsed.query(TemporalQuery.chronology()), expected); } //----------------------------------------------------------------------- --- old/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java 2013-04-11 23:17:39.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java 2013-04-11 23:17:39.000000000 -0700 @@ -59,11 +59,9 @@ */ package tck.java.time.format; -import java.time.format.*; -import test.java.time.format.*; - import static org.testng.Assert.assertEquals; +import java.time.format.DateTimeFormatSymbols; import java.util.Arrays; import java.util.Locale; @@ -75,7 +73,7 @@ @Test public class TCKDateTimeFormatSymbols { - @Test(groups={"tck"}) + @Test public void test_getAvailableLocales() { Locale[] locales = DateTimeFormatSymbols.getAvailableLocales(); assertEquals(locales.length > 0, true); @@ -83,7 +81,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_of_Locale() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.of(Locale.CANADA); assertEquals(loc1.getZeroDigit(), '0'); @@ -93,7 +91,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_STANDARD() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.STANDARD; assertEquals(loc1.getZeroDigit(), '0'); @@ -103,25 +101,25 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_zeroDigit() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withZeroDigit('A').getZeroDigit(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_positiveSign() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withPositiveSign('A').getPositiveSign(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_negativeSign() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withNegativeSign('A').getNegativeSign(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_decimalSeparator() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withDecimalSeparator('A').getDecimalSeparator(), 'A'); @@ -129,7 +127,7 @@ //----------------------------------------------------------------------- /* TBD: convertToDigit and convertNumberToI18N are package-private methods - @Test(groups={"tck"}) + @Test public void test_convertToDigit_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.convertToDigit('0'), 0); @@ -139,7 +137,7 @@ assertEquals(base.convertToDigit('A'), -1); } - @Test(groups={"tck"}) + @Test public void test_convertToDigit_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); assertEquals(base.convertToDigit('A'), 0); @@ -150,20 +148,20 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_convertNumberToI18N_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.convertNumberToI18N("134"), "134"); } - @Test(groups={"tck"}) + @Test public void test_convertNumberToI18N_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); assertEquals(base.convertNumberToI18N("134"), "BDE"); } */ //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equalsHashCode1() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD; DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD; @@ -172,7 +170,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode2() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); @@ -181,7 +179,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode3() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD.withDecimalSeparator('A'); @@ -189,7 +187,7 @@ assertEquals(b.equals(a), false); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode_bad() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD; assertEquals(a.equals(""), false); @@ -197,13 +195,13 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.toString(), "Symbols[0+-.]"); } - @Test(groups={"tck"}) + @Test public void test_toString_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.of(Locale.US).withZeroDigit('A').withDecimalSeparator('@'); assertEquals(base.toString(), "Symbols[A+-@]"); --- old/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java 2013-04-11 23:17:40.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java 2013-04-11 23:17:40.000000000 -0700 @@ -60,6 +60,8 @@ package tck.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.HOUR_OF_DAY; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; @@ -71,29 +73,37 @@ import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; -import java.util.Locale; - import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; import java.time.format.DateTimeFormatSymbols; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.format.SignStyle; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.OffsetDateTime; -import java.time.OffsetTime; -import java.time.temporal.Temporal; +import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -102,7 +112,7 @@ /** * Test DateTimeFormatter. */ -@Test(groups={"tck"}) +@Test public class TCKDateTimeFormatter { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -160,87 +170,241 @@ } //----------------------------------------------------------------------- - // print + @Test + public void test_resolverFields_selectOneDateResolveYMD() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, MONTH_OF_YEAR, DAY_OF_MONTH); + try { + base.parse("2012-6-30-321", LocalDate::from); // wrong day-of-year + fail(); + } catch (DateTimeException ex) { + // expected, fails as it produces two different dates + } + LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored day-of-year + assertEquals(parsed, LocalDate.of(2012, 6, 30)); + } + + @Test + public void test_resolverFields_selectOneDateResolveYD() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR); + assertEquals(f.getResolverFields(), new HashSet<>(Arrays.asList(YEAR, DAY_OF_YEAR))); + try { + base.parse("2012-6-30-321", LocalDate::from); // wrong month/day-of-month + fail(); + } catch (DateTimeException ex) { + // expected, fails as it produces two different dates + } + LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored month/day-of-month + assertEquals(parsed, LocalDate.of(2012, 11, 16)); + } + + @Test + public void test_resolverFields_ignoreCrossCheck() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(DAY_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR); + try { + base.parse("2012-321-1", LocalDate::from); // wrong day-of-week + fail(); + } catch (DateTimeException ex) { + // expected, should fail in cross-check of day-of-week + } + LocalDate parsed = f.parse("2012-321-1", LocalDate::from); // ignored wrong day-of-week + assertEquals(parsed, LocalDate.of(2012, 11, 16)); + } + + @Test + public void test_resolverFields_emptyList() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + } + + @Test + public void test_resolverFields_listOfOneMatching() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(YEAR); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), true); + } + + @Test + public void test_resolverFields_listOfOneNotMatching() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(MONTH_OF_YEAR); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + assertEquals(parsed.isSupported(MONTH_OF_YEAR), false); + } + + @Test + public void test_resolverFields_listOfOneNull() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields((TemporalField) null); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_resolverFields_Array_null() throws Exception { + DateTimeFormatter.ISO_DATE.withResolverFields((TemporalField[]) null); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_resolverFields_Set_null() throws Exception { + DateTimeFormatter.ISO_DATE.withResolverFields((Set) null); + } + + //----------------------------------------------------------------------- + // format //----------------------------------------------------------------------- - @DataProvider(name="print") - Object[][] data_format() { + @DataProvider(name="formatWithZoneWithChronology") + Object[][] data_format_withZone_withChronology() { + YearMonth ym = YearMonth.of(2008, 6); LocalDate ld = LocalDate.of(2008, 6, 30); LocalTime lt = LocalTime.of(11, 30); LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 11, 30); OffsetTime ot = OffsetTime.of(LocalTime.of(11, 30), OFFSET_PONE); OffsetDateTime odt = OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PONE); ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS); + ChronoZonedDateTime thaiZdt = ThaiBuddhistChronology.INSTANCE.zonedDateTime(zdt); Instant instant = Instant.ofEpochSecond(3600); return new Object[][] { - {null, null, ld, "2008::"}, - {null, null, lt, ":11:"}, - {null, null, ldt, "2008:11:"}, - {null, null, ot, ":11:+01:00"}, - {null, null, odt, "2008:11:+01:00"}, - {null, null, zdt, "2008:11:+02:00Europe/Paris"}, - {null, null, instant, "::"}, - - {null, ZONE_PARIS, ld, "2008::"}, - {null, ZONE_PARIS, lt, ":11:"}, - {null, ZONE_PARIS, ldt, "2008:11:"}, - {null, ZONE_PARIS, ot, ":11:+01:00"}, - {null, ZONE_PARIS, odt, "2008:12:+02:00Europe/Paris"}, - {null, ZONE_PARIS, zdt, "2008:11:+02:00Europe/Paris"}, - {null, ZONE_PARIS, instant, "1970:02:+01:00Europe/Paris"}, - - {null, OFFSET_PTHREE, ld, "2008::"}, - {null, OFFSET_PTHREE, lt, ":11:"}, - {null, OFFSET_PTHREE, ldt, "2008:11:"}, - {null, OFFSET_PTHREE, ot, ":11:+01:00"}, - {null, OFFSET_PTHREE, odt, "2008:13:+03:00"}, - {null, OFFSET_PTHREE, zdt, "2008:12:+03:00"}, - {null, OFFSET_PTHREE, instant, "1970:04:+03:00"}, - - {ThaiBuddhistChronology.INSTANCE, null, ld, "2551::"}, - {ThaiBuddhistChronology.INSTANCE, null, lt, ":11:"}, - {ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:"}, - {ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, null, instant, "::"}, - - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551::"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11:"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11:"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "1970:02:+01:00Europe/Paris"}, + {null, null, DayOfWeek.MONDAY, "::::"}, + {null, null, ym, "2008::::ISO"}, + {null, null, ld, "2008::::ISO"}, + {null, null, lt, ":11:::"}, + {null, null, ldt, "2008:11:::ISO"}, + {null, null, ot, ":11:+01:00::"}, + {null, null, odt, "2008:11:+01:00::ISO"}, + {null, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {null, null, instant, "::::"}, + + {IsoChronology.INSTANCE, null, DayOfWeek.MONDAY, "::::ISO"}, + {IsoChronology.INSTANCE, null, ym, "2008::::ISO"}, + {IsoChronology.INSTANCE, null, ld, "2008::::ISO"}, + {IsoChronology.INSTANCE, null, lt, ":11:::ISO"}, + {IsoChronology.INSTANCE, null, ldt, "2008:11:::ISO"}, + {IsoChronology.INSTANCE, null, ot, ":11:+01:00::ISO"}, + {IsoChronology.INSTANCE, null, odt, "2008:11:+01:00::ISO"}, + {IsoChronology.INSTANCE, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {IsoChronology.INSTANCE, null, instant, "::::ISO"}, + + {null, ZONE_PARIS, DayOfWeek.MONDAY, ":::Europe/Paris:"}, + {null, ZONE_PARIS, ym, "2008:::Europe/Paris:ISO"}, + {null, ZONE_PARIS, ld, "2008:::Europe/Paris:ISO"}, + {null, ZONE_PARIS, lt, ":11::Europe/Paris:"}, + {null, ZONE_PARIS, ldt, "2008:11::Europe/Paris:ISO"}, + {null, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:"}, + {null, ZONE_PARIS, odt, "2008:12:+02:00:Europe/Paris:ISO"}, + {null, ZONE_PARIS, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {null, ZONE_PARIS, instant, "1970:02:+01:00:Europe/Paris:ISO"}, + + {null, OFFSET_PTHREE, DayOfWeek.MONDAY, ":::+03:00:"}, + {null, OFFSET_PTHREE, ym, "2008:::+03:00:ISO"}, + {null, OFFSET_PTHREE, ld, "2008:::+03:00:ISO"}, + {null, OFFSET_PTHREE, lt, ":11::+03:00:"}, + {null, OFFSET_PTHREE, ldt, "2008:11::+03:00:ISO"}, + {null, OFFSET_PTHREE, ot, null}, // offset and zone clash + {null, OFFSET_PTHREE, odt, "2008:13:+03:00:+03:00:ISO"}, + {null, OFFSET_PTHREE, zdt, "2008:12:+03:00:+03:00:ISO"}, + {null, OFFSET_PTHREE, instant, "1970:04:+03:00:+03:00:ISO"}, + + {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, null, ym, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, null, ld, "2551::::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, lt, ":11:::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, instant, "::::ThaiBuddhist"}, + + {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ym, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551:::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"}, + + {null, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {IsoChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"}, }; } - @Test(dataProvider="print") - public void test_print_Temporal(Chronology overrideChrono, ZoneId overrideZone, Temporal temporal, String expected) { + @Test(dataProvider="formatWithZoneWithChronology") + public void test_format_withZone_withChronology(Chronology overrideChrono, ZoneId overrideZone, TemporalAccessor temporal, String expected) { DateTimeFormatter test = new DateTimeFormatterBuilder() .optionalStart().appendValue(YEAR, 4).optionalEnd() .appendLiteral(':').optionalStart().appendValue(HOUR_OF_DAY, 2).optionalEnd() - .appendLiteral(':').optionalStart().appendOffsetId().optionalStart().appendZoneRegionId().optionalEnd().optionalEnd() + .appendLiteral(':').optionalStart().appendOffsetId().optionalEnd() + .appendLiteral(':').optionalStart().appendZoneId().optionalEnd() + .appendLiteral(':').optionalStart().appendChronologyId().optionalEnd() .toFormatter(Locale.ENGLISH) .withChronology(overrideChrono).withZone(overrideZone); + if (expected != null) { + String result = test.format(temporal); + assertEquals(result, expected); + } else { + try { + test.format(temporal); + fail("Formatting should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test + public void test_format_withChronology_nonChronoFieldMapLink() { + TemporalAccessor temporal = new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + return field == IsoFields.WEEK_BASED_YEAR; + } + @Override + public long getLong(TemporalField field) { + if (field == IsoFields.WEEK_BASED_YEAR) { + return 2345; + } + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); + } + }; + DateTimeFormatter test = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR, 4) + .toFormatter(Locale.ENGLISH) + .withChronology(IsoChronology.INSTANCE); String result = test.format(temporal); - assertEquals(result, expected); + assertEquals(result, "2345"); } + //----------------------------------------------------------------------- @Test - public void test_print_Temporal_simple() throws Exception { + public void test_format_TemporalAccessor_simple() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); String result = test.format(LocalDate.of(2008, 6, 30)); assertEquals(result, "ONE30"); } - @Test(expectedExceptions=DateTimeException.class) - public void test_print_Temporal_noSuchField() throws Exception { + @Test(expectedExceptions = DateTimeException.class) + public void test_format_TemporalAccessor_noSuchField() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); test.format(LocalTime.of(11, 30)); } - @Test(expectedExceptions=NullPointerException.class) - public void test_print_Temporal_null() throws Exception { + @Test(expectedExceptions = NullPointerException.class) + public void test_format_TemporalAccessor_null() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); test.format((TemporalAccessor) null); } --- old/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java 2013-04-11 23:17:41.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java 2013-04-11 23:17:40.000000000 -0700 @@ -98,7 +98,36 @@ @Test public void test_toFormatter_empty() throws Exception { DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), ""); + assertEquals(f.format(LocalDate.of(2012, 6, 30)), ""); + } + + //----------------------------------------------------------------------- + @Test + public void test_parseDefaulting_entireDate() { + DateTimeFormatter f = builder + .parseDefaulting(YEAR, 2012).parseDefaulting(MONTH_OF_YEAR, 6) + .parseDefaulting(DAY_OF_MONTH, 30).toFormatter(); + LocalDate parsed = f.parse("", LocalDate::from); // blank string can be parsed + assertEquals(parsed, LocalDate.of(2012, 6, 30)); + } + + @Test + public void test_parseDefaulting_yearOptionalMonthOptionalDay() { + DateTimeFormatter f = builder + .appendValue(YEAR) + .optionalStart().appendLiteral('-').appendValue(MONTH_OF_YEAR) + .optionalStart().appendLiteral('-').appendValue(DAY_OF_MONTH) + .optionalEnd().optionalEnd() + .parseDefaulting(MONTH_OF_YEAR, 1) + .parseDefaulting(DAY_OF_MONTH, 1).toFormatter(); + assertEquals(f.parse("2012", LocalDate::from), LocalDate.of(2012, 1, 1)); + assertEquals(f.parse("2012-6", LocalDate::from), LocalDate.of(2012, 6, 1)); + assertEquals(f.parse("2012-6-30", LocalDate::from), LocalDate.of(2012, 6, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_parseDefaulting_null() { + builder.parseDefaulting(null, 1); } //----------------------------------------------------------------------- @@ -393,6 +422,7 @@ {"''"}, {"'!'"}, {"!"}, + {"'#'"}, {"'hello_people,][)('"}, {"'hi'"}, @@ -418,17 +448,20 @@ {"MMMM"}, {"MMMMM"}, + {"L"}, + {"LL"}, + {"LLL"}, + {"LLLL"}, + {"LLLLL"}, + {"D"}, {"DD"}, {"DDD"}, {"d"}, {"dd"}, - {"ddd"}, {"F"}, - {"FF"}, - {"FFF"}, {"Q"}, {"QQ"}, @@ -436,41 +469,48 @@ {"QQQQ"}, {"QQQQQ"}, + {"q"}, + {"qq"}, + {"qqq"}, + {"qqqq"}, + {"qqqqq"}, + {"E"}, {"EE"}, {"EEE"}, {"EEEE"}, {"EEEEE"}, + {"e"}, + {"ee"}, + {"eee"}, + {"eeee"}, + {"eeeee"}, + + {"c"}, + {"ccc"}, + {"cccc"}, + {"ccccc"}, + {"a"}, - {"aa"}, - {"aaa"}, - {"aaaa"}, - {"aaaaa"}, {"H"}, {"HH"}, - {"HHH"}, {"K"}, {"KK"}, - {"KKK"}, {"k"}, {"kk"}, - {"kkk"}, {"h"}, {"hh"}, - {"hhh"}, {"m"}, {"mm"}, - {"mmm"}, {"s"}, {"ss"}, - {"sss"}, {"S"}, {"SS"}, @@ -523,8 +563,9 @@ {"e"}, {"w"}, + {"ww"}, + {"W"}, {"W"}, - {"WW"}, }; } @@ -545,18 +586,40 @@ {"{"}, {"}"}, {"{}"}, + {"#"}, {"]"}, {"yyyy]"}, {"yyyy]MM"}, {"yyyy[MM]]"}, + {"aa"}, + {"aaa"}, + {"aaaa"}, + {"aaaaa"}, + {"aaaaaa"}, {"MMMMMM"}, {"QQQQQQ"}, + {"qqqqqq"}, {"EEEEEE"}, - {"aaaaaa"}, - {"ZZZZ"}, + {"eeeeee"}, + {"cc"}, + {"cccccc"}, + {"ddd"}, + {"DDDD"}, + {"FF"}, + {"FFF"}, + {"hhh"}, + {"HHH"}, + {"kkk"}, + {"KKK"}, + {"mmm"}, + {"sss"}, + {"OO"}, + {"OOO"}, + {"OOOOO"}, {"XXXXXX"}, {"zzzzz"}, + {"ZZZZZZ"}, {"RO"}, @@ -571,9 +634,8 @@ {"fa"}, {"fM"}, - {"ww"}, - {"ee"}, - {"WWW"}, + {"www"}, + {"WW"}, }; } @@ -588,9 +650,9 @@ return new Object[][] { {"Q", date(2012, 2, 10), "1"}, {"QQ", date(2012, 2, 10), "01"}, -// {"QQQ", date(2012, 2, 10), "Q1"}, // TODO: data for quarters? -// {"QQQQ", date(2012, 2, 10), "Q1"}, -// {"QQQQQ", date(2012, 2, 10), "Q1"}, + {"QQQ", date(2012, 2, 10), "Q1"}, + {"QQQQ", date(2012, 2, 10), "1st quarter"}, + {"QQQQQ", date(2012, 2, 10), "1"}, }; } --- old/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java 2013-04-11 23:17:41.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java 2013-04-11 23:17:41.000000000 -0700 @@ -77,16 +77,20 @@ import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.time.format.FormatStyle; +import java.time.format.ResolverStyle; +import java.time.format.TextStyle; import java.time.temporal.IsoFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -110,27 +114,28 @@ } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_print_nullCalendrical() { + @Test(expectedExceptions=NullPointerException.class) + public void test_format_nullTemporalAccessor() { DateTimeFormatter.ISO_DATE.format((TemporalAccessor) null); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_pattern_String() { DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy"); - assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)"); + assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 " + + Month.JUNE.getDisplayName(TextStyle.SHORT, Locale.getDefault()) + " 2012"); assertEquals(test.getLocale(), Locale.getDefault()); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_pattern_String_invalid() { DateTimeFormatter.ofPattern("p"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_String_null() { DateTimeFormatter.ofPattern(null); } @@ -138,24 +143,24 @@ //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_pattern_StringLocale() { DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.UK); - assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)"); + assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 Jun 2012"); assertEquals(test.getLocale(), Locale.UK); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_pattern_StringLocale_invalid() { DateTimeFormatter.ofPattern("p", Locale.UK); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_StringLocale_nullPattern() { DateTimeFormatter.ofPattern(null, Locale.UK); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_StringLocale_nullLocale() { DateTimeFormatter.ofPattern("yyyy", null); } @@ -163,6 +168,37 @@ //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- + @Test + public void test_ofLocalizedDate_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedTime_basics() { + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedDateTime1_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedDateTime2_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getResolverStyle(), ResolverStyle.SMART); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- @DataProvider(name="sample_isoLocalDate") Object[][] provider_sample_isoLocalDate() { return new Object[][]{ @@ -183,7 +219,7 @@ }; } - @Test(dataProvider="sample_isoLocalDate", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDate") public void test_print_isoLocalDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -200,7 +236,7 @@ } } - @Test(dataProvider="sample_isoLocalDate", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDate") public void test_parse_isoLocalDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -211,42 +247,49 @@ } } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_999999999() { Expected expected = createDate(999999999, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+999999999-08-06", new ParsePosition(0)), expected); assertEquals(LocalDate.parse("+999999999-08-06"), LocalDate.of(999999999, 8, 6)); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_1000000000() { Expected expected = createDate(1000000000, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+1000000000-08-06", new ParsePosition(0)), expected); } - @Test(expectedExceptions = DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions = DateTimeException.class) public void test_parse_isoLocalDate_1000000000_failedCreate() { LocalDate.parse("+1000000000-08-06"); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_M999999999() { Expected expected = createDate(-999999999, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-999999999-08-06", new ParsePosition(0)), expected); assertEquals(LocalDate.parse("-999999999-08-06"), LocalDate.of(-999999999, 8, 6)); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_M1000000000() { Expected expected = createDate(-1000000000, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-1000000000-08-06", new ParsePosition(0)), expected); } - @Test(expectedExceptions = DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions = DateTimeException.class) public void test_parse_isoLocalDate_M1000000000_failedCreate() { LocalDate.parse("-1000000000-08-06"); } + @Test + public void test_isoLocalDate_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -270,7 +313,7 @@ }; } - @Test(dataProvider="sample_isoOffsetDate", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDate") public void test_print_isoOffsetDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -287,7 +330,7 @@ } } - @Test(dataProvider="sample_isoOffsetDate", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDate") public void test_parse_isoOffsetDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -298,6 +341,13 @@ } } + @Test + public void test_isoOffsetDate_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -321,7 +371,7 @@ }; } - @Test(dataProvider="sample_isoDate", groups={"tck"}) + @Test(dataProvider="sample_isoDate") public void test_print_isoDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -338,7 +388,7 @@ } } - @Test(dataProvider="sample_isoDate", groups={"tck"}) + @Test(dataProvider="sample_isoDate") public void test_parse_isoDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -351,6 +401,13 @@ } } + @Test + public void test_isoDate_basics() { + assertEquals(DateTimeFormatter.ISO_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -386,7 +443,7 @@ }; } - @Test(dataProvider="sample_isoLocalTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalTime") public void test_print_isoLocalTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -403,7 +460,7 @@ } } - @Test(dataProvider="sample_isoLocalTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalTime") public void test_parse_isoLocalTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -414,6 +471,13 @@ } } + @Test + public void test_isoLocalTime_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -449,7 +513,7 @@ }; } - @Test(dataProvider="sample_isoOffsetTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetTime") public void test_print_isoOffsetTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -466,7 +530,7 @@ } } - @Test(dataProvider="sample_isoOffsetTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetTime") public void test_parse_isoOffsetTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -477,6 +541,13 @@ } } + @Test + public void test_isoOffsetTime_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -512,7 +583,7 @@ }; } - @Test(dataProvider="sample_isoTime", groups={"tck"}) + @Test(dataProvider="sample_isoTime") public void test_print_isoTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -529,7 +600,7 @@ } } - @Test(dataProvider="sample_isoTime", groups={"tck"}) + @Test(dataProvider="sample_isoTime") public void test_parse_isoTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -542,6 +613,13 @@ } } + @Test + public void test_isoTime_basics() { + assertEquals(DateTimeFormatter.ISO_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -585,7 +663,7 @@ }; } - @Test(dataProvider="sample_isoLocalDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDateTime") public void test_print_isoLocalDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -603,7 +681,7 @@ } } - @Test(dataProvider="sample_isoLocalDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDateTime") public void test_parse_isoLocalDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -614,6 +692,13 @@ } } + @Test + public void test_isoLocalDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -657,7 +742,7 @@ }; } - @Test(dataProvider="sample_isoOffsetDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDateTime") public void test_print_isoOffsetDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -675,7 +760,7 @@ } } - @Test(dataProvider="sample_isoOffsetDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDateTime") public void test_parse_isoOffsetDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -687,6 +772,13 @@ } } + @Test + public void test_isoOffsetDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -739,7 +831,7 @@ }; } - @Test(dataProvider="sample_isoZonedDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoZonedDateTime") public void test_print_isoZonedDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -757,7 +849,7 @@ } } - @Test(dataProvider="sample_isoZonedDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoZonedDateTime") public void test_parse_isoZonedDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -773,6 +865,13 @@ } } + @Test + public void test_isoZonedDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -816,7 +915,7 @@ }; } - @Test(dataProvider="sample_isoDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoDateTime") public void test_print_isoDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -834,7 +933,7 @@ } } - @Test(dataProvider="sample_isoDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoDateTime") public void test_parse_isoDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -851,28 +950,35 @@ } } + @Test + public void test_isoDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_offset() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155Z"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_zoned() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris"); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155+02:00"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_zoned_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "+123456-155Z"); @@ -907,65 +1013,72 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_isoOrdinalDate() { Expected expected = new Expected(YEAR, 2008, DAY_OF_YEAR, 123); assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("2008-123", new ParsePosition(0)), expected); } - @Test(groups={"tck"}) + @Test public void test_parse_isoOrdinalDate_largeYear() { Expected expected = new Expected(YEAR, 123456, DAY_OF_YEAR, 123); assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("+123456-123", new ParsePosition(0)), expected); } + @Test + public void test_isoOrdinalDate_basics() { + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603"); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_offset() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603Z"); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_zoned() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris"); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603+0200"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_basicIsoDate_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); DateTimeFormatter.BASIC_ISO_DATE.format(test); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_fields() { TemporalAccessor test = buildAccessor(LocalDate.of(2008, 6, 3), null, null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_basicIsoDate_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.BASIC_ISO_DATE.format(test); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_basicIsoDate() { LocalDate expected = LocalDate.of(2008, 6, 3); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.parse("20080603", LocalDate::from), expected); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void test_parse_basicIsoDate_largeYear() { try { LocalDate expected = LocalDate.of(123456, 6, 3); @@ -977,6 +1090,13 @@ } } + @Test + public void test_basicIsoDate_basics() { + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getZone(), null); + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1012,37 +1132,37 @@ }; } - @Test(dataProvider="weekDate", groups={"tck"}) + @Test(dataProvider="weekDate") public void test_print_isoWeekDate(TemporalAccessor test, String expected) { assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), expected); } - @Test(groups={"tck"}) + @Test public void test_print_isoWeekDate_zoned_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "+123456-W23-2Z"); } - @Test(groups={"tck"}) + @Test public void test_print_isoWeekDate_fields() { TemporalAccessor test = buildAccessor(LocalDate.of(2004, 1, 27), null, null); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "2004-W05-2"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_isoWeekDate_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.ISO_WEEK_DATE.format(test); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_weekDate() { LocalDate expected = LocalDate.of(2004, 1, 28); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.parse("2004-W05-3", LocalDate::from), expected); } - @Test(groups={"tck"}) + @Test public void test_parse_weekDate_largeYear() { TemporalAccessor parsed = DateTimeFormatter.ISO_WEEK_DATE.parseUnresolved("+123456-W04-5", new ParsePosition(0)); assertEquals(parsed.getLong(IsoFields.WEEK_BASED_YEAR), 123456L); @@ -1050,6 +1170,23 @@ assertEquals(parsed.getLong(DAY_OF_WEEK), 5L); } + @Test + public void test_isoWeekDate_basics() { + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @Test + public void test_isoInstant_basics() { + assertEquals(DateTimeFormatter.ISO_INSTANT.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_INSTANT.getZone(), null); + assertEquals(DateTimeFormatter.ISO_INSTANT.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1063,24 +1200,31 @@ }; } - @Test(groups={"tck"}, dataProvider="rfc") + @Test(dataProvider="rfc") public void test_print_rfc1123(LocalDateTime base, String offsetId, String expected) { TemporalAccessor test = buildAccessor(base, offsetId, null); assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.format(test), expected); } - @Test(groups={"tck"}, dataProvider="rfc") + @Test(dataProvider="rfc") public void test_print_rfc1123_french(LocalDateTime base, String offsetId, String expected) { TemporalAccessor test = buildAccessor(base, offsetId, null); assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.withLocale(Locale.FRENCH).format(test), expected); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_print_rfc1123_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.RFC_1123_DATE_TIME.format(test); } + @Test + public void test_rfc1123_basics() { + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getResolverStyle(), ResolverStyle.SMART); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1204,13 +1348,11 @@ assertEquals(parsed.isSupported(field), true); parsed.getLong(field); } - assertEquals(parsed.query(Queries.chronology()), expected.chrono); - assertEquals(parsed.query(Queries.zoneId()), expected.zone); + assertEquals(parsed.query(TemporalQuery.chronology()), expected.chrono); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected.zone); } //------------------------------------------------------------------------- - Map fields = new HashMap<>(); - ZoneId zoneId; static class MockAccessor implements TemporalAccessor { Map fields = new HashMap<>(); ZoneId zoneId; @@ -1272,7 +1414,7 @@ @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) zoneId; } return TemporalAccessor.super.query(query); --- old/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java 2013-04-11 23:17:42.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java 2013-04-11 23:17:42.000000000 -0700 @@ -59,20 +59,20 @@ */ package tck.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static org.testng.Assert.assertEquals; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - import java.time.LocalDateTime; import java.time.Month; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; import java.time.temporal.TemporalField; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -86,7 +86,7 @@ private DateTimeFormatterBuilder builder; - @BeforeMethod(groups={"tck"}) + @BeforeMethod public void setUp() { builder = new DateTimeFormatterBuilder(); } @@ -135,7 +135,7 @@ }; } - @Test(dataProvider="printText", groups={"tck"}) + @Test(dataProvider="printText") public void test_appendText2arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { DateTimeFormatter f = builder.appendText(field, style).toFormatter(Locale.ENGLISH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -144,7 +144,7 @@ assertEquals(text, expected); } - @Test(dataProvider="printText", groups={"tck"}) + @Test(dataProvider="printText") public void test_appendText1arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { if (style == TextStyle.FULL) { DateTimeFormatter f = builder.appendText(field).toFormatter(Locale.ENGLISH); @@ -156,7 +156,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_appendText2arg_french_long() throws Exception { DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.FULL).toFormatter(Locale.FRENCH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -164,7 +164,7 @@ assertEquals(text, "janvier"); } - @Test(groups={"tck"}) + @Test public void test_print_appendText2arg_french_short() throws Exception { DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT).toFormatter(Locale.FRENCH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -173,7 +173,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_appendTextMap() throws Exception { Map map = new HashMap(); map.put(1L, "JNY"); @@ -196,7 +196,7 @@ } } - @Test(groups={"tck"}) + @Test public void test_appendTextMap_DOM() throws Exception { Map map = new HashMap(); map.put(1L, "1st"); @@ -210,7 +210,7 @@ assertEquals(f.format(dt.withDayOfMonth(3)), "3rd"); } - @Test(groups={"tck"}) + @Test public void test_appendTextMapIncomplete() throws Exception { Map map = new HashMap(); map.put(1L, "JNY"); --- old/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java 2013-04-11 23:17:42.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java 2013-04-11 23:17:42.000000000 -0700 @@ -59,8 +59,7 @@ */ package tck.java.time.format; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static org.testng.Assert.assertEquals; import java.text.ParsePosition; @@ -78,7 +77,7 @@ /** * Test TCKLocalizedFieldParser. */ -@Test(groups={"tck"}) +@Test public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -86,13 +85,16 @@ Object[][] provider_fieldPatterns() { return new Object[][] { {"e", "6", 0, 1, 6}, - {"w", "3", 0, 1, 3}, - {"W", "29", 0, 2, 29}, - {"WW", "29", 0, 2, 29}, + {"W", "3", 0, 1, 3}, + {"w", "29", 0, 2, 29}, + {"ww", "29", 0, 2, 29}, + {"Y", "2013", 0, 4, 2013}, + {"YY", "13", 0, 2, 2013}, + {"YYYY", "2013", 0, 4, 2013}, }; } - @Test(dataProvider="FieldPatterns",groups={"tck"}) + @Test(dataProvider="FieldPatterns") public void test_parse_textField(String pattern, String text, int pos, int expectedPos, long expectedValue) { WeekFields weekDef = WeekFields.of(locale); TemporalField field = null; @@ -101,10 +103,13 @@ field = weekDef.dayOfWeek(); break; case 'w': - field = weekDef.weekOfMonth(); + field = weekDef.weekOfWeekBasedYear(); break; case 'W': - field = weekDef.weekOfYear(); + field = weekDef.weekOfMonth(); + break; + case 'Y': + field = weekDef.weekBasedYear(); break; default: throw new IllegalStateException("bad format letter from pattern"); @@ -123,27 +128,24 @@ } } - //----------------------------------------------------------------------- - @DataProvider(name="LocalDatePatterns") + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekMonthYearPatterns") Object[][] provider_patternLocalDate() { return new Object[][] { - {"e w M y", "1 1 1 2012", 0, 10, LocalDate.of(2012, 1, 1)}, - {"e w M y", "1 2 1 2012", 0, 10, LocalDate.of(2012, 1, 8)}, - {"e w M y", "2 2 1 2012", 0, 10, LocalDate.of(2012, 1, 9)}, - {"e w M y", "3 2 1 2012", 0, 10, LocalDate.of(2012, 1, 10)}, - {"e w M y", "1 3 1 2012", 0, 10, LocalDate.of(2012, 1, 15)}, - {"e w M y", "2 3 1 2012", 0, 10, LocalDate.of(2012, 1, 16)}, - {"e w M y", "6 2 1 2012", 0, 10, LocalDate.of(2012, 1, 13)}, - {"e w M y", "6 2 7 2012", 0, 10, LocalDate.of(2012, 7, 13)}, - {"e W y", "6 29 2012", 0, 9, LocalDate.of(2012, 7, 20)}, - {"'Date: 'y-MM', day-of-week: 'e', week-of-month: 'w", + {"e W M y", "1 1 1 2012", 0, 10, LocalDate.of(2012, 1, 1)}, + {"e W M y", "1 2 1 2012", 0, 10, LocalDate.of(2012, 1, 8)}, + {"e W M y", "2 2 1 2012", 0, 10, LocalDate.of(2012, 1, 9)}, + {"e W M y", "3 2 1 2012", 0, 10, LocalDate.of(2012, 1, 10)}, + {"e W M y", "1 3 1 2012", 0, 10, LocalDate.of(2012, 1, 15)}, + {"e W M y", "2 3 1 2012", 0, 10, LocalDate.of(2012, 1, 16)}, + {"e W M y", "6 2 1 2012", 0, 10, LocalDate.of(2012, 1, 13)}, + {"e W M y", "6 2 7 2012", 0, 10, LocalDate.of(2012, 7, 13)}, + {"'Date: 'y-MM', day-of-week: 'e', week-of-month: 'W", "Date: 2012-07, day-of-week: 6, week-of-month: 3", 0, 47, LocalDate.of(2012, 7, 20)}, - {"'Date: 'y', day-of-week: 'e', week-of-year: 'W", - "Date: 2012, day-of-week: 6, week-of-year: 29", 0, 44, LocalDate.of(2012, 7, 20)}, }; } - @Test(dataProvider="LocalDatePatterns",groups={"tck"}) + @Test(dataProvider="LocalWeekMonthYearPatterns") public void test_parse_textLocalDate(String pattern, String text, int pos, int expectedPos, LocalDate expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); @@ -153,7 +155,7 @@ assertEquals(ppos.getErrorIndex(), expectedPos); } else { assertEquals(ppos.getIndex(), expectedPos, "Incorrect ending parse position"); - assertEquals(parsed.isSupported(YEAR), true); + assertEquals(parsed.isSupported(YEAR_OF_ERA), true); assertEquals(parsed.isSupported(WeekFields.of(locale).dayOfWeek()), true); assertEquals(parsed.isSupported(WeekFields.of(locale).weekOfMonth()) || parsed.isSupported(WeekFields.of(locale).weekOfYear()), true); @@ -163,4 +165,41 @@ } } + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekBasedYearPatterns") + Object[][] provider_patternLocalWeekBasedYearDate() { + return new Object[][] { + //{"w Y", "29 2012", 0, 7, LocalDate.of(2012, 7, 20)}, // Default lenient dayOfWeek not supported + {"e w Y", "6 29 2012", 0, 9, LocalDate.of(2012, 7, 20)}, + {"'Date: 'Y', day-of-week: 'e', week-of-year: 'w", + "Date: 2012, day-of-week: 6, week-of-year: 29", 0, 44, LocalDate.of(2012, 7, 20)}, + {"Y-w-e", "2008-01-1", 0, 9, LocalDate.of(2007, 12, 30)}, + {"Y-w-e", "2008-52-1", 0, 9, LocalDate.of(2008, 12, 21)}, + {"Y-w-e", "2008-52-7", 0, 9, LocalDate.of(2008, 12, 27)}, + {"Y-w-e", "2009-01-01", 0, 10, LocalDate.of(2008, 12, 28)}, + {"Y-w-e", "2009-01-04", 0, 10, LocalDate.of(2008, 12, 31)}, + {"Y-w-e", "2009-01-05", 0, 10, LocalDate.of(2009, 1, 1)}, + }; + } + + @Test(dataProvider="LocalWeekBasedYearPatterns") + public void test_parse_WeekBasedYear(String pattern, String text, int pos, int expectedPos, LocalDate expectedValue) { + ParsePosition ppos = new ParsePosition(pos); + DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); + DateTimeFormatter dtf = b.toFormatter(locale); + TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); + if (ppos.getErrorIndex() != -1) { + assertEquals(ppos.getErrorIndex(), expectedPos); + } else { + WeekFields weekDef = WeekFields.of(locale); + assertEquals(ppos.getIndex(), expectedPos, "Incorrect ending parse position"); + assertEquals(parsed.isSupported(weekDef.dayOfWeek()), pattern.indexOf('e') >= 0); + assertEquals(parsed.isSupported(weekDef.weekOfWeekBasedYear()), pattern.indexOf('w') >= 0); + assertEquals(parsed.isSupported(weekDef.weekBasedYear()), pattern.indexOf('Y') >= 0); + // ensure combination resolves into a date + LocalDate result = LocalDate.parse(text, dtf); + assertEquals(result, expectedValue, "LocalDate incorrect for " + pattern + ", weekDef: " + weekDef); + } + } + } --- old/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java 2013-04-11 23:17:43.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java 2013-04-11 23:17:43.000000000 -0700 @@ -59,22 +59,22 @@ */ package tck.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; import java.time.LocalDate; - -import test.java.time.format.AbstractTestPrinterParser; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.WeekFields; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.format.AbstractTestPrinterParser; + /** * Test LocalizedFieldPrinterParser. */ -@Test(groups={"tck"}) +@Test public class TCKLocalizedFieldPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -82,17 +82,17 @@ Object[][] provider_pad() { return new Object[][] { {"e", "6"}, - {"w", "3"}, - {"W", "29"}, - {"WW", "29"}, - {"'Date: 'y-MM-d', week-of-month: 'w', week-of-year: 'W", + {"W", "3"}, + {"w", "29"}, + {"ww", "29"}, + {"'Date: 'y-MM-d', week-of-month: 'W', week-of-year: 'w", "Date: 2012-07-20, week-of-month: 3, week-of-year: 29"}, }; } //----------------------------------------------------------------------- - @Test(dataProvider="Patterns",groups={"tck"}) + @Test(dataProvider="Patterns") public void test_localizedDayOfWeek(String pattern, String expected) { DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); @@ -102,4 +102,28 @@ assertEquals(result, expected, "Wrong output for pattern '" + pattern + "'."); } + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekBasedYearPatterns") + Object[][] provider_patternLocalWeekBasedYearDate() { + return new Object[][] { + {"e w Y", "6 29 2012", LocalDate.of(2012, 7, 20)}, + {"'Date: 'Y', day-of-week: 'e', week-of-year: 'w", + "Date: 2012, day-of-week: 6, week-of-year: 29", LocalDate.of(2012, 7, 20)}, + {"Y-ww-ee", "2008-01-01", LocalDate.of(2007, 12, 30)}, + {"Y-w-e", "2008-52-1", LocalDate.of(2008, 12, 21)}, + {"Y-w-e", "2008-52-7", LocalDate.of(2008, 12, 27)}, + {"Y-ww-e", "2009-01-1", LocalDate.of(2008, 12, 28)}, + {"Y-w-e", "2009-1-4", LocalDate.of(2008, 12, 31)}, + {"Y-w-e", "2009-1-5", LocalDate.of(2009, 1, 1)}, + {"YYYYYYYYY-w-e", "000002009-1-5", LocalDate.of(2009, 1, 1)}, + }; + } + + @Test(dataProvider = "LocalWeekBasedYearPatterns") + public void test_print_WeekBasedYear(String pattern, String expectedText, LocalDate date) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern, locale); + String result = dtf.format(date); + WeekFields weekDef = WeekFields.of(locale); + assertEquals(result, expectedText, "Incorrect formatting for " + pattern + ", weekDef: " + weekDef); + } } --- old/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java 2013-04-11 23:17:44.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java 2013-04-11 23:17:43.000000000 -0700 @@ -63,7 +63,6 @@ import java.text.DateFormat; import java.text.ParsePosition; -import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; --- old/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java 2013-04-11 23:17:44.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java 2013-04-11 23:17:44.000000000 -0700 @@ -62,11 +62,13 @@ import static org.testng.Assert.assertEquals; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -200,6 +202,34 @@ }; } + @DataProvider(name="print_localized") + Object[][] data_print_localized() { + return new Object[][] { + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+01:00"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+01:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+00:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+01:23:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-01:00"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-01:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-00:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-01:23:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+1"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+1:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+0:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+1:23:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-1"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-1:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-0:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-1:23:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"}, + }; + } + @Test(dataProvider="print") public void test_print(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) { ZonedDateTime zdt = ldt.atZone(zone); @@ -275,6 +305,45 @@ DateTimeFormatter f3 = new DateTimeFormatterBuilder().appendPattern("ZZZ").toFormatter(); String output3 = f3.format(zdt); assertEquals(output3, (expected.equals("Z") ? "+0000" : expected)); + } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) { + ZonedDateTime zdt = ldt.atZone(zone); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendPattern("ZZZZZ").toFormatter(); + String output = f.format(zdt); + assertEquals(output, expected); + } + } + + @Test(dataProvider="print_localized") + public void test_print_localized(TextStyle style, LocalDateTime ldt, ZoneOffset offset, String expected) { + OffsetDateTime odt = OffsetDateTime.of(ldt, offset); + ZonedDateTime zdt = ldt.atZone(offset); + + DateTimeFormatter f = new DateTimeFormatterBuilder().appendLocalizedOffset(style) + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + + if (style == TextStyle.FULL) { + f = new DateTimeFormatterBuilder().appendPattern("ZZZZ") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + + f = new DateTimeFormatterBuilder().appendPattern("OOOO") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + } + + if (style == TextStyle.SHORT) { + f = new DateTimeFormatterBuilder().appendPattern("O") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); } } @@ -290,8 +359,43 @@ } @Test(expectedExceptions=IllegalArgumentException.class) - public void test_print_pattern_Z4rejected() { - builder.appendPattern("ZZZZ"); + public void test_print_pattern_Z6rejected() { + builder.appendPattern("ZZZZZZ"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O2rejected() { + builder.appendPattern("OO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O3rejected() { + builder.appendPattern("OOO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O5rejected() { + builder.appendPattern("OOOOO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_full_standline() { + builder.appendLocalizedOffset(TextStyle.FULL_STANDALONE); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_short_standalone() { + builder.appendLocalizedOffset(TextStyle.SHORT_STANDALONE); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_narrow() { + builder.appendLocalizedOffset(TextStyle.NARROW); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_narrow_standalone() { + builder.appendLocalizedOffset(TextStyle.NARROW_STANDALONE); } } --- old/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java 2013-04-11 23:17:45.000000000 -0700 +++ new/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java 2013-04-11 23:17:44.000000000 -0700 @@ -67,8 +67,8 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; @@ -209,9 +209,9 @@ assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -225,9 +225,9 @@ assertEquals(pos.getErrorIndex(), expectedErrorIndex >= 0 ? expectedErrorIndex + 3 : expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex + 3); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -240,9 +240,9 @@ assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -261,9 +261,9 @@ assertEquals(pos.getIndex(), expectedIndex); assertEquals(pos.getErrorIndex(), expectedErrorIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -277,9 +277,9 @@ assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } --- old/test/java/time/tck/java/time/temporal/TCKIsoFields.java 2013-04-11 23:17:45.000000000 -0700 +++ new/test/java/time/tck/java/time/temporal/TCKIsoFields.java 2013-04-11 23:17:45.000000000 -0700 @@ -66,11 +66,14 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.format.ResolverStyle; import java.time.temporal.IsoFields; import java.time.temporal.ValueRange; @@ -80,7 +83,7 @@ /** * Test. */ -@Test(groups={"tck"}) +@Test public class TCKIsoFields { @DataProvider(name="quarter") @@ -115,35 +118,133 @@ //----------------------------------------------------------------------- // DAY_OF_QUARTER //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_DOQ(LocalDate date, int doq, int qoy) { assertEquals(IsoFields.DAY_OF_QUARTER.getFrom(date), doq); assertEquals(date.get(IsoFields.DAY_OF_QUARTER), doq); } + public void test_DOQ_basics() { + assertEquals(IsoFields.DAY_OF_QUARTER.isDateBased(), true); + assertEquals(IsoFields.DAY_OF_QUARTER.isTimeBased(), false); + } + //----------------------------------------------------------------------- // QUARTER_OF_YEAR //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_QOY(LocalDate date, int doq, int qoy) { assertEquals(IsoFields.QUARTER_OF_YEAR.getFrom(date), qoy); assertEquals(date.get(IsoFields.QUARTER_OF_YEAR), qoy); } + public void test_QOY_basics() { + assertEquals(IsoFields.QUARTER_OF_YEAR.isDateBased(), true); + assertEquals(IsoFields.QUARTER_OF_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // parse quarters //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_parse_quarters(LocalDate date, int doq, int qoy) { DateTimeFormatter f = new DateTimeFormatterBuilder() .appendValue(YEAR).appendLiteral('-') .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') - .appendValue(IsoFields.DAY_OF_QUARTER).toFormatter(); + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); + assertEquals(parsed, date); + } + + @Test(dataProvider = "quarter") + public void test_parse_quarters_SMART(LocalDate date, int doq, int qoy) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); + assertEquals(parsed, date); + } + + @Test(dataProvider = "quarter") + public void test_parse_quarters_LENIENT(LocalDate date, int doq, int qoy) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); assertEquals(parsed, date); } //----------------------------------------------------------------------- + @DataProvider(name="parseLenientQuarter") + Object[][] data_parseLenientQuarter() { + return new Object[][] { + {"2012:0:1", LocalDate.of(2011, 10, 1), false}, + {"2012:5:1", LocalDate.of(2013, 1, 1), false}, + + {"2012:1:-1", LocalDate.of(2011, 12, 30), false}, + {"2012:1:0", LocalDate.of(2011, 12, 31), false}, + {"2012:0:0", LocalDate.of(2011, 9, 30), false}, + + {"2012:1:92", LocalDate.of(2012, 4, 1), true}, + {"2012:2:92", LocalDate.of(2012, 7, 1), true}, + {"2012:2:93", LocalDate.of(2012, 7, 2), false}, + {"2012:3:93", LocalDate.of(2012, 10, 1), false}, + {"2012:4:93", LocalDate.of(2013, 1, 1), false}, + {"2012:4:182", LocalDate.of(2013, 3, 31), false}, + {"2012:4:183", LocalDate.of(2013, 4, 1), false}, + + {"2011:1:91", LocalDate.of(2011, 4, 1), true}, + {"2011:1:92", LocalDate.of(2011, 4, 2), true}, + }; + } + + @Test(dataProvider = "parseLenientQuarter", expectedExceptions = DateTimeParseException.class) + public void test_parse_parseLenientQuarter_STRICT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate.parse(str, f); + } + + @Test(dataProvider = "parseLenientQuarter") + public void test_parse_parseLenientQuarter_SMART(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + if (smart) { + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } else { + try { + LocalDate.parse(str, f); + fail("Should have failed"); + } catch (DateTimeParseException ex) { + // expected + } + } + } + + @Test(dataProvider = "parseLenientQuarter") + public void test_parse_parseLenientQuarter_LENIENT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } + + //----------------------------------------------------------------------- // quarters between //----------------------------------------------------------------------- @DataProvider(name="quartersBetween") @@ -214,6 +315,11 @@ assertEquals(date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR), week); } + public void test_WOWBY_basics() { + assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isDateBased(), true); + assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // WEEK_BASED_YEAR //----------------------------------------------------------------------- @@ -224,20 +330,106 @@ assertEquals(date.get(IsoFields.WEEK_BASED_YEAR), wby); } + public void test_WBY_basics() { + assertEquals(IsoFields.WEEK_BASED_YEAR.isDateBased(), true); + assertEquals(IsoFields.WEEK_BASED_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // parse weeks //----------------------------------------------------------------------- @Test(dataProvider="week") - public void test_parse_weeks(LocalDate date, DayOfWeek dow, int week, int wby) { + public void test_parse_weeks_STRICT(LocalDate date, DayOfWeek dow, int week, int wby) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="week") + public void test_parse_weeks_SMART(LocalDate date, DayOfWeek dow, int week, int wby) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="week") + public void test_parse_weeks_LENIENT(LocalDate date, DayOfWeek dow, int week, int wby) { DateTimeFormatter f = new DateTimeFormatterBuilder() .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') - .appendValue(DAY_OF_WEEK).toFormatter(); + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); assertEquals(parsed, date); } //----------------------------------------------------------------------- + @DataProvider(name="parseLenientWeek") + Object[][] data_parseLenientWeek() { + return new Object[][] { + {"2012:52:-1", LocalDate.of(2012, 12, 22), false}, + {"2012:52:0", LocalDate.of(2012, 12, 23), false}, + {"2012:52:8", LocalDate.of(2012, 12, 31), false}, + {"2012:52:9", LocalDate.of(2013, 1, 1), false}, + + {"2012:53:1", LocalDate.of(2012, 12, 31), true}, + {"2012:54:1", LocalDate.of(2013, 1, 7), false}, + + {"2013:0:1", LocalDate.of(2012, 12, 24), false}, + {"2013:0:0", LocalDate.of(2012, 12, 23), false}, + }; + } + + @Test(dataProvider = "parseLenientWeek", expectedExceptions = DateTimeParseException.class) + public void test_parse_parseLenientWeek_STRICT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate.parse(str, f); + } + + @Test(dataProvider = "parseLenientWeek") + public void test_parse_parseLenientWeek_SMART(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + if (smart) { + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } else { + try { + LocalDate.parse(str, f); + fail("Should have failed"); + } catch (DateTimeParseException ex) { + // expected + } + } + } + + @Test(dataProvider = "parseLenientWeek") + public void test_parse_parseLenientWeek_LENIENT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } + + //----------------------------------------------------------------------- public void test_loop() { // loop round at least one 400 year cycle, including before 1970 LocalDate date = LocalDate.of(1960, 1, 5); // Tuseday of week 1 1960 --- old/test/java/time/tck/java/time/temporal/TCKJulianFields.java 2013-04-11 23:17:46.000000000 -0700 +++ new/test/java/time/tck/java/time/temporal/TCKJulianFields.java 2013-04-11 23:17:46.000000000 -0700 @@ -65,7 +65,9 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; @@ -125,6 +127,17 @@ assertSerializable(field); } + public void test_basics() { + assertEquals(JulianFields.JULIAN_DAY.isDateBased(), true); + assertEquals(JulianFields.JULIAN_DAY.isTimeBased(), false); + + assertEquals(JulianFields.MODIFIED_JULIAN_DAY.isDateBased(), true); + assertEquals(JulianFields.MODIFIED_JULIAN_DAY.isTimeBased(), false); + + assertEquals(JulianFields.RATA_DIE.isDateBased(), true); + assertEquals(JulianFields.RATA_DIE.isTimeBased(), false); + } + //----------------------------------------------------------------------- @Test(dataProvider="samples") public void test_samples_get(TemporalField field, LocalDate date, long expected) { @@ -142,8 +155,25 @@ //----------------------------------------------------------------------- @Test(dataProvider="samples") - public void test_samples_parse(TemporalField field, LocalDate date, long value) { - DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter(); + public void test_samples_parse_STRICT(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate parsed = LocalDate.parse(Long.toString(value), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="samples") + public void test_samples_parse_SMART(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(Long.toString(value), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="samples") + public void test_samples_parse_LENIENT(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); LocalDate parsed = LocalDate.parse(Long.toString(value), f); assertEquals(parsed, date); } --- old/test/java/time/tck/java/time/temporal/TCKWeekFields.java 2013-04-11 23:17:46.000000000 -0700 +++ new/test/java/time/tck/java/time/temporal/TCKWeekFields.java 2013-04-11 23:17:46.000000000 -0700 @@ -61,6 +61,7 @@ import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; @@ -69,6 +70,8 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.ChronoUnit; +import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; @@ -92,6 +95,26 @@ } //----------------------------------------------------------------------- + @Test(dataProvider="weekFields") + public void test_basics(DayOfWeek firstDayOfWeek, int minDays) { + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + assertEquals(week.dayOfWeek().isDateBased(), true); + assertEquals(week.dayOfWeek().isTimeBased(), false); + + assertEquals(week.weekOfMonth().isDateBased(), true); + assertEquals(week.weekOfMonth().isTimeBased(), false); + + assertEquals(week.weekOfYear().isDateBased(), true); + assertEquals(week.weekOfYear().isTimeBased(), false); + + assertEquals(week.weekOfWeekBasedYear().isDateBased(), true); + assertEquals(week.weekOfWeekBasedYear().isTimeBased(), false); + + assertEquals(week.weekBasedYear().isDateBased(), true); + assertEquals(week.weekBasedYear().isTimeBased(), false); + } + + //----------------------------------------------------------------------- @Test public void test_dayOfWeekField_simpleGet() { LocalDate date = LocalDate.of(2000, 1, 10); // Known to be ISO Monday @@ -124,10 +147,8 @@ LocalDate day = LocalDate.of(2000, 1, 10); // Known to be ISO Monday WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField f = week.dayOfWeek(); - //System.out.printf(" Week: %s; field: %s%n", week, f); for (int i = 1; i <= 7; i++) { - //System.out.printf(" ISO Dow: %s, WeekDOW ordinal: %s%n", day.getDayOfWeek(), day.get(f)); assertEquals(day.get(f), (7 + day.getDayOfWeek().getValue() - firstDayOfWeek.getValue()) % 7 + 1); day = day.plusDays(1); } @@ -139,7 +160,6 @@ WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField dowField = week.dayOfWeek(); TemporalField womField = week.weekOfMonth(); - //System.err.printf("%n Week: %s; dowField: %s, domField: %s%n", week, dowField, womField); DayOfWeek isoDOW = day.getDayOfWeek(); int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; @@ -152,23 +172,17 @@ // to reconstruct the same date. LocalDate day1 = day.withDayOfMonth(1); int offset = - (day1.get(dowField) - 1); - //System.err.printf(" refDay: %s%n", day1.plusDays(offset)); + int week1 = day1.get(womField); if (week1 == 0) { // week of the 1st is partial; start with first full week offset += 7; } - //System.err.printf(" refDay2: %s, offset: %d, week1: %d%n", day1.plusDays(offset), offset, week1); + offset += actualDOW - 1; - //System.err.printf(" refDay3: %s%n", day1.plusDays(offset)); offset += (actualWOM - 1) * 7; - //System.err.printf(" refDay4: %s%n", day1.plusDays(offset)); LocalDate result = day1.plusDays(offset); - if (!day.equals(result)) { - System.err.printf("FAIL ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", - day.getDayOfWeek(), offset, actualDOW, actualWOM, day, result); - } assertEquals(result, day, "Incorrect dayOfWeek or weekOfMonth: " + String.format("%s, ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", week, day.getDayOfWeek(), offset, actualDOW, actualWOM, day, result)); @@ -182,7 +196,6 @@ WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField dowField = week.dayOfWeek(); TemporalField woyField = week.weekOfYear(); - //System.err.printf("%n Year: %s; dowField: %s, woyField: %s%n", week, dowField, woyField); DayOfWeek isoDOW = day.getDayOfWeek(); int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; @@ -195,24 +208,15 @@ // to reconstruct the same date. LocalDate day1 = day.withDayOfYear(1); int offset = - (day1.get(dowField) - 1); - //System.err.printf(" refDay: %s%n", day1.plusDays(offset)); int week1 = day1.get(woyField); if (week1 == 0) { // week of the 1st is partial; start with first full week offset += 7; } - //System.err.printf(" refDay2: %s, offset: %d, week1: %d%n", day1.plusDays(offset), offset, week1); offset += actualDOW - 1; - //System.err.printf(" refDay3: %s%n", day1.plusDays(offset)); offset += (actualWOY - 1) * 7; - //System.err.printf(" refDay4: %s%n", day1.plusDays(offset)); LocalDate result = day1.plusDays(offset); - - if (!day.equals(result)) { - System.err.printf("FAIL ISO Dow: %s, offset: %s, actualDOW: %s, actualWOY: %s, expected: %s, result: %s%n", - day.getDayOfWeek(), offset, actualDOW, actualWOY, day, result); - } assertEquals(result, day, "Incorrect dayOfWeek or weekOfYear " + String.format("%s, ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", week, day.getDayOfWeek(), offset, actualDOW, actualWOY, day, result)); @@ -220,6 +224,48 @@ } } + /** + * Verify that the date can be reconstructed from the DOW, WeekOfWeekBasedYear, + * and WeekBasedYear for every combination of start of week + * and minimal days in week. + * @param firstDayOfWeek the first day of the week + * @param minDays the minimum number of days in the week + */ + @Test(dataProvider="weekFields") + public void test_weekOfWeekBasedYearField(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate day = LocalDate.of(2012, 12, 31); // Known to be ISO Monday + WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + + for (int i = 1; i <= 15; i++) { + int actualDOW = day.get(dowField); + int actualWOWBY = day.get(wowbyField); + int actualYOWBY = day.get(yowbyField); + + // Verify that the combination of day of week and week of month can be used + // to reconstruct the same date. + LocalDate day1 = LocalDate.of(actualYOWBY, 1, 1); + DayOfWeek isoDOW = day1.getDayOfWeek(); + int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; + + int weekStart = Math.floorMod(1 - dow, 7); + if (weekStart + 1 > weekDef.getMinimalDaysInFirstWeek()) { + // The previous week has the minimum days in the current month to be a 'week' + weekStart -= 7; + } + weekStart += actualDOW - 1; + weekStart += (actualWOWBY - 1) * 7; + LocalDate result = day1.plusDays(weekStart); + + assertEquals(result, day, "Incorrect dayOfWeek or weekOfYear " + + String.format("%s, ISO Dow: %s, weekStart: %s, actualDOW: %s, actualWOWBY: %s, YearOfWBY: %d, expected day: %s, result: %s%n", + weekDef, day.getDayOfWeek(), weekStart, actualDOW, actualWOWBY, actualYOWBY, day, result)); + day = day.plusDays(1); + } + } + @Test(dataProvider="weekFields") public void test_fieldRanges(DayOfWeek firstDayOfWeek, int minDays) { WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); @@ -272,24 +318,63 @@ int woy = day.get(woyField); for (int dow = 1; dow <= 7; dow++) { LocalDate result = day.with(dowField, dow); - if (result.get(dowField) != dow) { - System.err.printf(" DOW actual: %d, expected: %d, week:%s%n", - result.get(dowField), dow, week); - } - if (result.get(womField) != wom) { - System.err.printf(" WOM actual: %d, expected: %d, week:%s%n", - result.get(womField), wom, week); - } - if (result.get(woyField) != woy) { - System.err.printf(" WOY actual: %d, expected: %d, week:%s%n", - result.get(woyField), woy, week); - } assertEquals(result.get(dowField), dow, String.format("Incorrect new Day of week: %s", result)); assertEquals(result.get(womField), wom, "Week of Month should not change"); assertEquals(result.get(woyField), woy, "Week of Year should not change"); } } + @Test(dataProvider="weekFields") + public void test_rangeWeekOfWeekBasedYear(DayOfWeek firstDayOfWeek, int minDays) { + WeekFields weekFields = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = weekFields.dayOfWeek(); + TemporalField wowByField = weekFields.weekOfWeekBasedYear(); + + LocalDate day1 = LocalDate.of(2012, 1, weekFields.getMinimalDaysInFirstWeek()); + day1 = day1.with(wowByField, 1).with(dowField, 1); + + LocalDate day2 = LocalDate.of(2013, 1, weekFields.getMinimalDaysInFirstWeek()); + day2 = day2.with(wowByField, 1).with(dowField, 1); + + int expectedWeeks = (int)ChronoUnit.DAYS.between(day1, day2) / 7; + + ValueRange range = day1.range(wowByField); + assertEquals(range.getMaximum(), expectedWeeks, "Range incorrect"); + } + + @Test(dataProvider="weekFields") + public void test_withWeekOfWeekBasedYear(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate day = LocalDate.of(2012, 12, 31); + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = week.dayOfWeek(); + TemporalField wowbyField = week.weekOfWeekBasedYear(); + TemporalField yowbyField = week.weekBasedYear(); + + int dowExpected = (day.get(dowField) - 1) % 7 + 1; + LocalDate dowDate = day.with(dowField, dowExpected); + int dowResult = dowDate.get(dowField); + assertEquals(dowResult, dowExpected, "Localized DayOfWeek not correct; " + day + " -->" + dowDate); + + int weekExpected = day.get(wowbyField) + 1; + ValueRange range = day.range(wowbyField); + weekExpected = ((weekExpected - 1) % (int)range.getMaximum()) + 1; + LocalDate weekDate = day.with(wowbyField, weekExpected); + int weekResult = weekDate.get(wowbyField); + assertEquals(weekResult, weekExpected, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); + + int yearExpected = day.get(yowbyField) + 1; + + LocalDate yearDate = day.with(yowbyField, yearExpected); + int yearResult = yearDate.get(yowbyField); + assertEquals(yearResult, yearExpected, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); + + range = yearDate.range(wowbyField); + weekExpected = Math.min(day.get(wowbyField), (int)range.getMaximum()); + + int weekActual = yearDate.get(wowbyField); + assertEquals(weekActual, weekExpected, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); + } + //----------------------------------------------------------------------- @Test(dataProvider="weekFields") public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) { @@ -381,6 +466,29 @@ } } + @Test(dataProvider="weekFields") + public void test_parse_resolve_localizedWoWBY(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate date = LocalDate.of(2012, 12, 31); + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = week.dayOfWeek(); + TemporalField wowbyField = week.weekOfWeekBasedYear(); + TemporalField yowbyField = week.weekBasedYear(); + + for (int i = 1; i <= 60; i++) { + // Test that with dayOfWeek, week of year and year of week-based-year it computes the date + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(yowbyField).appendLiteral('-') + .appendValue(wowbyField).appendLiteral('-') + .appendValue(dowField).toFormatter(); + String str = date.get(yowbyField) + "-" + date.get(wowbyField) + "-" + + date.get(dowField); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, date, " :: " + str + " " + i); + + date = date.plusDays(1); + } + } + //----------------------------------------------------------------------- @Test(dataProvider="weekFields") public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException { @@ -401,4 +509,67 @@ return objects; } + //----------------------------------------------------------------------- + @DataProvider(name="WeekBasedYearData") + Object[][] provider_WeekBasedYearData() { + return new Object[][] { + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2008, 52, 7, LocalDate.of(2008, 12, 27)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 1, LocalDate.of(2008, 12, 28)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 2, LocalDate.of(2008, 12, 29)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 3, LocalDate.of(2008, 12, 30)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 4, LocalDate.of(2008, 12, 31)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 5, LocalDate.of(2009, 1, 1)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 1, LocalDate.of(2009, 1, 4)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 2, LocalDate.of(2009, 1, 5)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 3, LocalDate.of(2009, 1, 6)}, + }; + } + + @Test(dataProvider="WeekBasedYearData") + public void test_weekBasedYears(WeekFields weekDef, int weekBasedYear, + int weekOfWeekBasedYear, int dayOfWeek, LocalDate date) { + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + assertEquals(date.get(dowField), dayOfWeek, "DayOfWeek mismatch"); + assertEquals(date.get(wowbyField), weekOfWeekBasedYear, "Week of WeekBasedYear mismatch"); + assertEquals(date.get(yowbyField), weekBasedYear, "Year of WeekBasedYear mismatch"); + } + + + //----------------------------------------------------------------------- + @DataProvider(name="IsoWeekData") + Object[][] data_week() { + return new Object[][] { + {LocalDate.of(1969, 12, 29), DayOfWeek.MONDAY, 1, 1970}, + {LocalDate.of(2012, 12, 23), DayOfWeek.SUNDAY, 51, 2012}, + {LocalDate.of(2012, 12, 24), DayOfWeek.MONDAY, 52, 2012}, + {LocalDate.of(2012, 12, 27), DayOfWeek.THURSDAY, 52, 2012}, + {LocalDate.of(2012, 12, 28), DayOfWeek.FRIDAY, 52, 2012}, + {LocalDate.of(2012, 12, 29), DayOfWeek.SATURDAY, 52, 2012}, + {LocalDate.of(2012, 12, 30), DayOfWeek.SUNDAY, 52, 2012}, + {LocalDate.of(2012, 12, 31), DayOfWeek.MONDAY, 1, 2013}, + {LocalDate.of(2013, 1, 1), DayOfWeek.TUESDAY, 1, 2013}, + {LocalDate.of(2013, 1, 2), DayOfWeek.WEDNESDAY, 1, 2013}, + {LocalDate.of(2013, 1, 6), DayOfWeek.SUNDAY, 1, 2013}, + {LocalDate.of(2013, 1, 7), DayOfWeek.MONDAY, 2, 2013}, + }; + } + + //----------------------------------------------------------------------- + // WEEK_OF_WEEK_BASED_YEAR + // Validate with the same data used by IsoFields. + //----------------------------------------------------------------------- + @Test(dataProvider="IsoWeekData") + public void test_WOWBY(LocalDate date, DayOfWeek dow, int week, int wby) { + WeekFields weekDef = WeekFields.ISO; + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + + assertEquals(date.get(dowField), dow.getValue()); + assertEquals(date.get(wowbyField), week); + assertEquals(date.get(yowbyField), wby); + } + } --- old/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java 2013-04-11 23:17:47.000000000 -0700 +++ new/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java 2013-04-11 23:17:47.000000000 -0700 @@ -65,7 +65,6 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; - import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -108,7 +107,7 @@ //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -127,19 +126,19 @@ //----------------------------------------------------------------------- // basics //----------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getOffset(INSTANT), expectedOffset); assertEquals(test.getOffset((Instant) null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getOffset_LocalDateTime(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getOffset(LDT), expectedOffset); assertEquals(test.getOffset((LocalDateTime) null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getValidOffsets_LDT(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getValidOffsets(LDT).size(), 1); assertEquals(test.getValidOffsets(LDT).get(0), expectedOffset); @@ -147,13 +146,13 @@ assertEquals(test.getValidOffsets(null).get(0), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransition_LDT(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransition(LDT), null); assertEquals(test.getTransition(null), null); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_isValidOffset_LDT_ZO(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.isValidOffset(LDT, expectedOffset), true); assertEquals(test.isValidOffset(LDT, ZoneOffset.UTC), false); @@ -164,55 +163,55 @@ assertEquals(test.isValidOffset(null, null), false); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getStandardOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getStandardOffset(INSTANT), expectedOffset); assertEquals(test.getStandardOffset(null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getDaylightSavings(INSTANT), Duration.ZERO); assertEquals(test.getDaylightSavings(null), Duration.ZERO); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_isDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.isDaylightSavings(INSTANT), false); assertEquals(test.isDaylightSavings(null), false); } //------------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_nextTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.nextTransition(INSTANT), null); assertEquals(test.nextTransition(null), null); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_previousTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.previousTransition(INSTANT), null); assertEquals(test.previousTransition(null), null); } //------------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransitions(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransitions().size(), 0); } - @Test(expectedExceptions=UnsupportedOperationException.class, groups="tck") + @Test(expectedExceptions=UnsupportedOperationException.class) public void test_getTransitions_immutable() { ZoneRules test = make(OFFSET_PTWO); test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransitionRules(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransitionRules().size(), 0); } - @Test(expectedExceptions=UnsupportedOperationException.class, groups="tck") + @Test(expectedExceptions=UnsupportedOperationException.class) public void test_getTransitionRules_immutable() { ZoneRules test = make(OFFSET_PTWO); test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); @@ -221,7 +220,7 @@ //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equalsHashCode() { ZoneRules a = make(OFFSET_PONE); ZoneRules b = make(OFFSET_PTWO); --- old/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java 2013-04-11 23:17:48.000000000 -0700 +++ new/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java 2013-04-11 23:17:47.000000000 -0700 @@ -62,13 +62,14 @@ import static java.time.temporal.ChronoUnit.HOURS; import static org.testng.Assert.assertEquals; -import tck.java.time.AbstractTCKTest; import java.time.Duration; import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.Year; +import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; + import org.testng.annotations.Test; +import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransition. @@ -85,27 +86,27 @@ //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTransition() { ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetBefore() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_sameOffset() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_noNanos() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); } @@ -113,7 +114,7 @@ //----------------------------------------------------------------------- // getters //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getters_gap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); @@ -129,7 +130,7 @@ assertSerializable(test); } - @Test(groups={"tck"}) + @Test public void test_getters_overlap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); @@ -163,7 +164,7 @@ //----------------------------------------------------------------------- // isValidOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); @@ -174,7 +175,7 @@ assertEquals(test.isValidOffset(OFFSET_0400), false); } - @Test(groups={"tck"}) + @Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); @@ -188,7 +189,7 @@ //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L - 1, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); @@ -210,7 +211,7 @@ assertEquals(c.compareTo(c) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_sameInstant() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); @@ -235,7 +236,7 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); @@ -260,7 +261,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); @@ -276,14 +277,14 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); --- old/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java 2013-04-11 23:17:48.000000000 -0700 +++ new/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java 2013-04-11 23:17:48.000000000 -0700 @@ -61,7 +61,6 @@ import static org.testng.Assert.assertEquals; -import tck.java.time.AbstractTCKTest; import java.time.DayOfWeek; import java.time.LocalDateTime; import java.time.LocalTime; @@ -72,6 +71,7 @@ import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import org.testng.annotations.Test; +import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule. @@ -86,70 +86,70 @@ //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullMonth() { ZoneOffsetTransitionRule.of( null, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTime() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, null, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTimeDefinition() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, null, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullStandardOffset() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, null, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetBefore() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, null, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, null); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_tooSmall() { ZoneOffsetTransitionRule.of( Month.MARCH, -29, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_zero() { ZoneOffsetTransitionRule.of( Month.MARCH, 0, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_tooLarge() { ZoneOffsetTransitionRule.of( Month.MARCH, 32, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidMidnightFlag() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, true, TimeDefinition.WALL, @@ -239,7 +239,7 @@ //----------------------------------------------------------------------- // createTransition() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -249,7 +249,7 @@ assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -259,7 +259,7 @@ assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -269,7 +269,7 @@ assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_seventhLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -279,7 +279,7 @@ assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -289,7 +289,7 @@ assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, @@ -302,7 +302,7 @@ //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals_monthDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -316,7 +316,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfMonthDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -330,7 +330,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfWeekDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -344,7 +344,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfWeekDifferentNull() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -358,7 +358,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_localTimeDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -372,7 +372,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_endOfDayDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, @@ -386,7 +386,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_timeDefinitionDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -400,7 +400,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_standardOffsetDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -414,7 +414,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_offsetBeforeDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -428,7 +428,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_offsetAfterDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -442,7 +442,7 @@ assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -450,7 +450,7 @@ assertEquals(a.equals("TZDB"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -461,7 +461,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -472,7 +472,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_overlap_endOfDay_nullDayOfWeek() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -483,7 +483,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeekBackwards() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -494,7 +494,7 @@ assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_fixedDate() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, @@ -508,7 +508,7 @@ //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -516,7 +516,7 @@ assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -524,7 +524,7 @@ assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -532,7 +532,7 @@ assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -540,7 +540,7 @@ assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, --- old/test/java/time/tck/java/time/zone/TCKZoneRules.java 2013-04-11 23:17:49.000000000 -0700 +++ new/test/java/time/tck/java/time/zone/TCKZoneRules.java 2013-04-11 23:17:48.000000000 -0700 @@ -68,9 +68,6 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.util.Iterator; -import java.util.List; - import java.time.DayOfWeek; import java.time.Duration; import java.time.Instant; @@ -86,6 +83,8 @@ import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import java.time.zone.ZoneRules; +import java.util.Iterator; +import java.util.List; import org.testng.annotations.Test; --- old/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java 2013-04-11 23:17:49.000000000 -0700 +++ new/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java 2013-04-11 23:17:49.000000000 -0700 @@ -59,23 +59,21 @@ */ package tck.java.time.zone; -import java.time.ZoneId; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.zone.ZoneRules; +import java.time.zone.ZoneRulesException; +import java.time.zone.ZoneRulesProvider; import java.util.Collections; import java.util.HashSet; import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; -import java.time.ZoneOffset; -import java.time.zone.ZoneRules; -import java.time.zone.ZoneRulesException; -import java.time.zone.ZoneRulesProvider; - import org.testng.annotations.Test; /** @@ -172,7 +170,7 @@ //----------------------------------------------------------------------- // registerProvider() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_registerProvider() { Set pre = ZoneRulesProvider.getAvailableZoneIds(); assertEquals(pre.contains("FooLocation"), false); --- old/test/java/time/test/java/time/MockSimplePeriod.java 2013-04-11 23:17:50.000000000 -0700 +++ new/test/java/time/test/java/time/MockSimplePeriod.java 2013-04-11 23:17:50.000000000 -0700 @@ -59,19 +59,16 @@ */ package test.java.time; -import java.time.*; - import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.FOREVER; import static java.time.temporal.ChronoUnit.SECONDS; -import java.util.Objects; - +import java.time.DateTimeException; import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; import java.util.List; +import java.util.Objects; /** * Mock period of time measured using a single unit, such as {@code 3 Days}. --- old/test/java/time/test/java/time/TestClock_System.java 2013-04-11 23:17:50.000000000 -0700 +++ new/test/java/time/test/java/time/TestClock_System.java 2013-04-11 23:17:50.000000000 -0700 @@ -59,11 +59,12 @@ */ package test.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; +import java.time.Clock; +import java.time.ZoneId; + import org.testng.annotations.Test; /** --- old/test/java/time/test/java/time/TestDuration.java 2013-04-11 23:17:51.000000000 -0700 +++ new/test/java/time/test/java/time/TestDuration.java 2013-04-11 23:17:51.000000000 -0700 @@ -65,11 +65,9 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; - import java.time.Duration; import org.testng.annotations.Test; @@ -87,7 +85,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_interfaces() { assertTrue(Serializable.class.isAssignableFrom(Duration.class)); assertTrue(Comparable.class.isAssignableFrom(Duration.class)); @@ -96,7 +94,7 @@ //----------------------------------------------------------------------- // serialization //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_deserializationSingleton() throws Exception { Duration orginal = Duration.ZERO; ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -109,103 +107,103 @@ assertSame(ser, Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plus_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plus(Duration.ZERO), t); } - @Test(groups={"implementation"}) + @Test public void plus_zeroSingleton() { Duration t = Duration.ofSeconds(-1); assertSame(t.plus(Duration.ofSeconds(1)), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(0), t); } - @Test(groups={"implementation"}) + @Test public void plusSeconds_zeroSingleton() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(1), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusMillis(0), t); } - @Test(groups={"implementation"}) + @Test public void plusMillis_zeroSingleton() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusMillis(998), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusNanos_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusNanos(0), t); } - @Test(groups={"implementation"}) + @Test public void plusNanos_zeroSingleton() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusNanos(998000000), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minus_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minus(Duration.ZERO), t); } - @Test(groups={"implementation"}) + @Test public void minus_zeroSingleton() { Duration t = Duration.ofSeconds(1); assertSame(t.minus(Duration.ofSeconds(1)), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minusSeconds(0), t); } - @Test(groups={"implementation"}) + @Test public void minusSeconds_zeroSingleton() { Duration t = Duration.ofSeconds(1); assertSame(t.minusSeconds(1), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(0), t); } - @Test(groups={"implementation"}) + @Test public void minusMillis_zeroSingleton() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(1002), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusNanos_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusNanos(0), t); } - @Test(groups={"implementation"}) + @Test public void minusNanos_zeroSingleton() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusNanos(1002000000), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void test_abs_same() { Duration base = Duration.ofSeconds(12); assertSame(base.abs(), base); --- old/test/java/time/test/java/time/TestLocalDate.java 2013-04-11 23:17:52.000000000 -0700 +++ new/test/java/time/test/java/time/TestLocalDate.java 2013-04-11 23:17:51.000000000 -0700 @@ -80,7 +80,7 @@ private LocalDate TEST_2007_07_15; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); } @@ -117,55 +117,55 @@ return date.withDayOfMonth(date.getMonth().length(isIsoLeap(date.getYear()))); } - @Test(groups={"implementation"}) + @Test public void test_with_DateTimeField_long_noChange_same() { LocalDate t = TEST_2007_07_15.with(YEAR, 2007); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withYear_int_noChange_same() { LocalDate t = TEST_2007_07_15.withYear(2007); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChange_same() { LocalDate t = TEST_2007_07_15.withMonth(7); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange_same() { LocalDate t = TEST_2007_07_15.withDayOfMonth(15); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange_same() { LocalDate t = TEST_2007_07_15.withDayOfYear(31 + 28 + 31 + 30 + 31 + 30 + 15); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { LocalDate t = TEST_2007_07_15.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plus_longPeriodUnit_zero() { LocalDate t = TEST_2007_07_15.plus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_long_noChange_same() { LocalDate t = TEST_2007_07_15.plusYears(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_long_noChange_same() { LocalDate t = TEST_2007_07_15.plusMonths(0); assertSame(t, TEST_2007_07_15); @@ -206,7 +206,7 @@ }; } - @Test(dataProvider="samplePlusWeeksSymmetry", groups={"implementation"}) + @Test(dataProvider="samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.plusWeeks(weeks).plusWeeks(-weeks); @@ -217,7 +217,7 @@ } } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_noChange_same() { LocalDate t = TEST_2007_07_15.plusWeeks(0); assertSame(t, TEST_2007_07_15); @@ -258,7 +258,7 @@ }; } - @Test(dataProvider="samplePlusDaysSymmetry", groups={"implementation"}) + @Test(dataProvider="samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.plusDays(days).plusDays(-days); @@ -269,31 +269,31 @@ } } - @Test(groups={"implementation"}) + @Test public void test_plusDays_noChange_same() { LocalDate t = TEST_2007_07_15.plusDays(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { LocalDate t = TEST_2007_07_15.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minus_longPeriodUnit_zero() { LocalDate t = TEST_2007_07_15.minus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_long_noChange_same() { LocalDate t = TEST_2007_07_15.minusYears(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_long_noChange_same() { LocalDate t = TEST_2007_07_15.minusMonths(0); assertSame(t, TEST_2007_07_15); @@ -334,7 +334,7 @@ }; } - @Test(dataProvider="sampleMinusWeeksSymmetry", groups={"implementation"}) + @Test(dataProvider="sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.minusWeeks(weeks).minusWeeks(-weeks); @@ -345,7 +345,7 @@ } } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_noChange_same() { LocalDate t = TEST_2007_07_15.minusWeeks(0); assertSame(t, TEST_2007_07_15); @@ -386,7 +386,7 @@ }; } - @Test(dataProvider="sampleMinusDaysSymmetry", groups={"implementation"}) + @Test(dataProvider="sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.minusDays(days).minusDays(-days); @@ -397,13 +397,13 @@ } } - @Test(groups={"implementation"}) + @Test public void test_minusDays_noChange_same() { LocalDate t = TEST_2007_07_15.minusDays(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_toEpochDay_fromMJDays_symmetry() { long date_0000_01_01 = -678941 - 40587; --- old/test/java/time/test/java/time/TestLocalDateTime.java 2013-04-11 23:17:52.000000000 -0700 +++ new/test/java/time/test/java/time/TestLocalDateTime.java 2013-04-11 23:17:52.000000000 -0700 @@ -121,365 +121,365 @@ }; } - @Test(groups={"implementation"}) + @Test public void test_withYear_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withYear(2007); assertSame(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMonth(7); assertSame(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfMonth(15); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfYear(31 + 28 + 31 + 30 + 31 + 30 + 15); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withHour_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withHour(12); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withHour_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).withHour(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withHour_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).withHour(12); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMinute(30); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 1)).withMinute(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 1)).withMinute(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withSecond(40); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 1)).withSecond(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 1)).withSecond(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withNano(987654321); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 0, 1)).withNano(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 0, 1)).withNano(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plus_adjuster_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(Period.ZERO); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plus_longPeriodUnit_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(0); assertSame(TEST_2007_07_15_12_30_40_987654321, t); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusDays_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusHours(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 0)).plusHours(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 0)).plusHours(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(24 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59)).plusMinutes(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59)).plusMinutes(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59, 59)).plusSeconds(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59, 59)).plusSeconds(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59, 59, 999999999)).plusNanos(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59, 59, 999999999)).plusNanos(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minus_adjuster_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(Period.ZERO); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minus_longPeriodUnit_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusDays_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusHours(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).minusHours(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(13, 0)).minusHours(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(24 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 1)).minusMinutes(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 1)).minusMinutes(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(24 * 60 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 1)).minusSeconds(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 1)).minusSeconds(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 0, 1)).minusNanos(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 0, 1)).minusNanos(1); assertSame(t.toLocalTime(), LocalTime.NOON); @@ -488,7 +488,7 @@ //----------------------------------------------------------------------- // toLocalDate() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"implementation"}) + @Test(dataProvider="sampleDates") public void test_getDate(int year, int month, int day) { LocalDate d = LocalDate.of(year, month, day); LocalDateTime dt = LocalDateTime.of(d, LocalTime.MIDNIGHT); @@ -498,7 +498,7 @@ //----------------------------------------------------------------------- // toLocalTime() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"implementation"}) + @Test(dataProvider="sampleTimes") public void test_getTime(int h, int m, int s, int ns) { LocalTime t = LocalTime.of(h, m, s, ns); LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t); --- old/test/java/time/test/java/time/TestLocalTime.java 2013-04-11 23:17:53.000000000 -0700 +++ new/test/java/time/test/java/time/TestLocalTime.java 2013-04-11 23:17:53.000000000 -0700 @@ -87,51 +87,51 @@ } //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDNIGHT() { check(LocalTime.MIDNIGHT, 0, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIDNIGHT_same() { assertSame(LocalTime.MIDNIGHT, LocalTime.MIDNIGHT); assertSame(LocalTime.MIDNIGHT, LocalTime.of(0, 0)); } - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDDAY() { check(LocalTime.NOON, 12, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIDDAY_same() { assertSame(LocalTime.NOON, LocalTime.NOON); assertSame(LocalTime.NOON, LocalTime.of(12, 0)); } //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIN_TIME() { check(LocalTime.MIN, 0, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIN_TIME_same() { assertSame(LocalTime.MIN, LocalTime.of(0, 0)); } - @Test(groups={"tck","implementation"}) + @Test public void constant_MAX_TIME() { check(LocalTime.MAX, 23, 59, 59, 999999999); } - @Test(groups={"implementation"}) + @Test public void constant_MAX_TIME_same() { assertSame(LocalTime.NOON, LocalTime.NOON); assertSame(LocalTime.NOON, LocalTime.of(12, 0)); } - @Test(groups={"implementation"}) + @Test public void factory_time_2ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0); @@ -140,7 +140,7 @@ } } - @Test(groups={"implementation"}) + @Test public void factory_time_3ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0, 0); @@ -149,7 +149,7 @@ } } - @Test(groups={"implementation"}) + @Test public void factory_time_4ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0, 0, 0); @@ -158,7 +158,7 @@ } } - @Test(groups={"implementation"}) + @Test public void factory_ofSecondOfDay_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.ofSecondOfDay(i * 60L * 60L); @@ -167,7 +167,7 @@ } } - @Test(groups={"implementation"}) + @Test public void factory_ofNanoOfDay_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.ofNanoOfDay(i * 1000000000L * 60L * 60L); --- old/test/java/time/test/java/time/TestMonthDay.java 2013-04-11 23:17:53.000000000 -0700 +++ new/test/java/time/test/java/time/TestMonthDay.java 2013-04-11 23:17:53.000000000 -0700 @@ -78,7 +78,7 @@ private MonthDay TEST_07_15; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -95,24 +95,24 @@ assertEquals(test.getDayOfMonth(), d); } - @Test(groups={"implementation"}) + @Test public void test_with_Month_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.with(Month.JUNE), test); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.withMonth(6), test); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.withDayOfMonth(30), test); } - @Test(groups={"implementation"}) + @Test public void test_adjustDate_same() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 6, 30); --- old/test/java/time/test/java/time/TestOffsetDateTime.java 2013-04-11 23:17:54.000000000 -0700 +++ new/test/java/time/test/java/time/TestOffsetDateTime.java 2013-04-11 23:17:54.000000000 -0700 @@ -64,8 +64,8 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.ZoneOffset; import java.time.OffsetDateTime; +import java.time.ZoneOffset; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -81,7 +81,7 @@ private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); } @@ -104,7 +104,7 @@ }; } - @Test(dataProvider="sampleTimes", groups={"implementation"}) + @Test(dataProvider="sampleTimes") public void test_get_same(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -120,7 +120,7 @@ //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameLocal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PTWO); @@ -128,192 +128,192 @@ assertSame(test.getOffset(), OFFSET_PTWO); } - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameLocal_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PONE); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameInstant_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameInstant(OFFSET_PONE); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withYear_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withYear(2008); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMonth(6); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withDayOfMonth(30); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.withDayOfYear(31 + 29 + 31 + 30 + 31 + 30); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_withHour_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withHour(11); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMinute(30); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withSecond(59); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE); OffsetDateTime test = base.withNano(1); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusYears(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusMonths(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusWeeks(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusDays_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusDays(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusHours(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusMinutes(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusSeconds(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusNanos(0); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2007, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusYears(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusMonths(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusWeeks(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusDays_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusDays(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusHours(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusMinutes(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusSeconds(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusNanos(0); --- old/test/java/time/test/java/time/TestOffsetDateTime_instants.java 2013-04-11 23:17:55.000000000 -0700 +++ new/test/java/time/test/java/time/TestOffsetDateTime_instants.java 2013-04-11 23:17:54.000000000 -0700 @@ -59,17 +59,16 @@ */ package test.java.time; +import static org.testng.Assert.assertEquals; + import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.Month; -import java.time.ZoneOffset; - import java.time.OffsetDateTime; import java.time.Year; - -import static org.testng.Assert.assertEquals; +import java.time.ZoneOffset; import org.testng.annotations.Test; --- old/test/java/time/test/java/time/TestPeriod.java 2013-04-11 23:17:55.000000000 -0700 +++ new/test/java/time/test/java/time/TestPeriod.java 2013-04-11 23:17:55.000000000 -0700 @@ -80,6 +80,7 @@ //----------------------------------------------------------------------- // factories //----------------------------------------------------------------------- + @Test public void factory_zeroSingleton() { assertSame(Period.ZERO, Period.ZERO); assertSame(Period.ofYears(0), Period.ZERO); @@ -91,6 +92,7 @@ //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- + @Test public void test_hashCode() { Period test5 = Period.ofDays(5); Period test6 = Period.ofDays(6); --- old/test/java/time/test/java/time/TestZoneId.java 2013-04-11 23:17:56.000000000 -0700 +++ new/test/java/time/test/java/time/TestZoneId.java 2013-04-11 23:17:55.000000000 -0700 @@ -62,7 +62,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import java.lang.reflect.Field; @@ -82,7 +81,6 @@ import java.util.SimpleTimeZone; import java.util.TimeZone; -import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -121,7 +119,6 @@ assertEquals(test.getRules().isFixedOffset(), true); assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), ZoneOffset.UTC); checkOffset(test.getRules(), createLDT(2008, 6, 30), ZoneOffset.UTC, 1); - assertSame(test, ZoneId.of("UTC+00")); } //----------------------------------------------------------------------- @@ -129,9 +126,7 @@ //----------------------------------------------------------------------- public void test_systemDefault() { ZoneId test = ZoneId.systemDefault(); - assertEquals(test.getId(), TimeZone.getDefault() - .getID() - .replaceAll("GMT|UTC|UT", "Z")); + assertEquals(test.getId(), TimeZone.getDefault().getID()); } @Test(expectedExceptions = DateTimeException.class) @@ -157,58 +152,6 @@ } //----------------------------------------------------------------------- - @DataProvider(name="String_Fixed") - Object[][] data_of_string_Fixed() { - return new Object[][] { - {"+0", "Z"}, - {"+5", "+05:00"}, - {"+01", "+01:00"}, - {"+0100", "+01:00"},{"+01:00", "+01:00"}, - {"+010000", "+01:00"},{"+01:00:00", "+01:00"}, - {"+12", "+12:00"}, - {"+1234", "+12:34"},{"+12:34", "+12:34"}, - {"+123456", "+12:34:56"},{"+12:34:56", "+12:34:56"}, - {"-02", "-02:00"}, - {"-5", "-05:00"}, - {"-0200", "-02:00"},{"-02:00", "-02:00"}, - {"-020000", "-02:00"},{"-02:00:00", "-02:00"}, - }; - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_offset(String input, String id) { - ZoneId test = ZoneId.of(input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_FixedUTC(String input, String id) { - ZoneId test = ZoneId.of("UTC" + input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_FixedGMT(String input, String id) { - ZoneId test = ZoneId.of("GMT" + input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - - //----------------------------------------------------------------------- // Europe/London //----------------------------------------------------------------------- public void test_London() { --- old/test/java/time/test/java/time/chrono/TestExampleCode.java 2013-04-11 23:17:56.000000000 -0700 +++ new/test/java/time/test/java/time/chrono/TestExampleCode.java 2013-04-11 23:17:56.000000000 -0700 @@ -57,16 +57,20 @@ package test.java.time.chrono; +import static org.testng.Assert.assertEquals; + import java.time.LocalTime; -import java.time.chrono.HijrahDate; -import java.time.chrono.ThaiBuddhistDate; -import java.time.chrono.ChronoLocalDateTime; import java.time.chrono.ChronoLocalDate; +import java.time.chrono.ChronoLocalDateTime; import java.time.chrono.Chronology; +import java.time.chrono.HijrahDate; +import java.time.chrono.ThaiBuddhistDate; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; +import java.util.Locale; import java.util.Set; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -104,6 +108,30 @@ first, last); } + //----------------------------------------------------------------------- + // Data provider for Hijrah Variant names + //----------------------------------------------------------------------- + @DataProvider(name = "HijrahVariantNames") + Object[][] data_of_ummalqura() { + return new Object[][]{ + { "Hijrah-umalqura", "islamic", "umalqura"}, + }; + } + + @Test(dataProvider= "HijrahVariantNames") + public void test_HijrahVariantViaLocale(String calendarId, String calendarType, String variant) { + Locale.Builder builder = new Locale.Builder(); + builder.setLanguage("en").setRegion("US"); + builder.setUnicodeLocaleKeyword("ca", calendarType); + builder.setUnicodeLocaleKeyword("cv", variant); + Locale locale = builder.build(); + Chronology chrono = Chronology.ofLocale(locale); + System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n", + locale.toLanguageTag(), chrono, chrono.getCalendarType()); + Chronology expected = Chronology.of(calendarId); + assertEquals(chrono, expected, "Expected chronology not found"); + } + @Test public void test_calendarPackageExample() { --- old/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java 2013-04-11 23:17:57.000000000 -0700 +++ new/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java 2013-04-11 23:17:57.000000000 -0700 @@ -60,19 +60,16 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; - import static org.testng.Assert.assertEquals; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.TimeZone; - import java.time.DayOfWeek; import java.time.LocalDate; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.IsoChronology; import java.time.temporal.ChronoUnit; import java.time.temporal.WeekFields; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.TimeZone; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -86,15 +83,14 @@ @DataProvider(name = "RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][]{ - {LocalDate.of(1900, 1, 4), LocalDate.of(2100, 1, 8)}, - //{LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, + {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, }; } //----------------------------------------------------------------------- // Verify ISO Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(groups = {"implementation"}, dataProvider = "RangeVersusCalendar") + @Test(dataProvider = "RangeVersusCalendar") public void test_IsoChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); @@ -119,7 +115,7 @@ // Verify ISO Calendar matches java.util.Calendar // DayOfWeek, WeekOfMonth, WeekOfYear for range //----------------------------------------------------------------------- - @Test(groups = {"implementation"}, dataProvider = "RangeVersusCalendar") + @Test(dataProvider = "RangeVersusCalendar") public void test_DayOfWeek_IsoChronology_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); @@ -136,32 +132,31 @@ cal.set(Calendar.MONTH, isoDate.get(MONTH_OF_YEAR) - 1); cal.set(Calendar.DAY_OF_MONTH, isoDate.get(DAY_OF_MONTH)); + // For every date in the range while (isoDate.isBefore(isoEndDate)) { assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); - int jDOW = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; - int isoDOW = isoDate.get(weekDef.dayOfWeek()); - if (jDOW != isoDOW) { - System.err.printf(" DOW vs Calendar jdow: %s, isoDate(DOW): %s, isoDate: %s, WeekDef: %s%n", jDOW, isoDOW, isoDate, weekDef); - } - assertEquals(jDOW, isoDOW, "Calendar DayOfWeek does not match ISO DayOfWeek"); + + int jdow = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; + int dow = isoDate.get(weekDef.dayOfWeek()); + assertEquals(jdow, dow, "Calendar DayOfWeek does not match ISO DayOfWeek"); int jweekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); int isoWeekOfMonth = isoDate.get(weekDef.weekOfMonth()); - if (jweekOfMonth != isoWeekOfMonth) { - System.err.printf(" WeekOfMonth jWeekOfMonth: %s, isoWeekOfMonth: %s, isoDate: %s, %s%n", - jweekOfMonth, isoWeekOfMonth, isoDate, weekDef); - } assertEquals(jweekOfMonth, isoWeekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); int jweekOfYear = cal.get(Calendar.WEEK_OF_YEAR); - int isoWeekOfYear = isoDate.get(weekDef.weekOfYear()); - if (jweekOfYear != isoWeekOfYear) { - // TBD: Issue #186 Remove misleading output pending resolution - // System.err.printf(" Mismatch WeekOfYear jweekOfYear: %s, isoWeekOfYear: %s, isoDate: %s, WeekDef: %s%n", jweekOfYear, isoWeekOfYear, isoDate, weekDef); - } - //assertEquals(jweekOfYear, isoWeekOfYear, "Calendar WeekOfYear does not match ISO WeekOfYear"); + int weekOfYear = isoDate.get(weekDef.weekOfWeekBasedYear()); + assertEquals(jweekOfYear, weekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); + + int jWeekYear = cal.getWeekYear(); + int weekBasedYear = isoDate.get(weekDef.weekBasedYear()); + assertEquals(jWeekYear, weekBasedYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); + + int jweeksInWeekyear = cal.getWeeksInWeekYear(); + int weeksInWeekBasedYear = (int)isoDate.range(weekDef.weekOfWeekBasedYear()).getMaximum(); + assertEquals(jweeksInWeekyear, weeksInWeekBasedYear, "length of weekBasedYear"); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); --- old/test/java/time/test/java/time/chrono/TestServiceLoader.java 2013-04-11 23:17:57.000000000 -0700 +++ new/test/java/time/test/java/time/chrono/TestServiceLoader.java 2013-04-11 23:17:57.000000000 -0700 @@ -60,10 +60,11 @@ import static org.testng.Assert.assertNotNull; +import java.time.chrono.Chronology; import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; -import java.time.chrono.Chronology; + import org.testng.annotations.Test; /** @@ -73,7 +74,7 @@ @Test public class TestServiceLoader { - @Test(groups="implementation") + @Test public void test_copticServiceLoader() { Map chronos = new HashMap<>(); ServiceLoader loader = ServiceLoader.load(Chronology.class, null); --- old/test/java/time/test/java/time/format/AbstractTestPrinterParser.java 2013-04-11 23:17:58.000000000 -0700 +++ new/test/java/time/test/java/time/format/AbstractTestPrinterParser.java 2013-04-11 23:17:58.000000000 -0700 @@ -59,16 +59,18 @@ */ package test.java.time.format; -import java.time.format.*; - -import java.util.Locale; - import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.SignStyle; +import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -86,7 +88,7 @@ protected DateTimeFormatSymbols symbols; - @BeforeMethod(groups={"tck"}) + @BeforeMethod public void setUp() { buf = new StringBuilder(); builder = new DateTimeFormatterBuilder(); @@ -123,6 +125,10 @@ return builder.appendLiteral(s).toFormatter(locale).withSymbols(symbols); } + protected DateTimeFormatter getFormatter(TemporalField field) { + return builder.appendText(field).toFormatter(locale).withSymbols(symbols); + } + protected DateTimeFormatter getFormatter(TemporalField field, TextStyle style) { return builder.appendText(field, style).toFormatter(locale).withSymbols(symbols); } @@ -135,6 +141,10 @@ return builder.appendOffset(pattern, noOffsetText).toFormatter(locale).withSymbols(symbols); } + protected DateTimeFormatter getPatternFormatter(String pattern) { + return builder.appendPattern(pattern).toFormatter(locale).withSymbols(symbols); + } + protected static final TemporalAccessor EMPTY_DTA = new TemporalAccessor() { public boolean isSupported(TemporalField field) { return true; --- old/test/java/time/test/java/time/format/MockIOExceptionAppendable.java 2013-04-11 23:17:59.000000000 -0700 +++ new/test/java/time/test/java/time/format/MockIOExceptionAppendable.java 2013-04-11 23:17:58.000000000 -0700 @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import java.io.IOException; /** --- old/test/java/time/test/java/time/format/TestCharLiteralParser.java 2013-04-11 23:17:59.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestCharLiteralParser.java 2013-04-11 23:17:59.000000000 -0700 @@ -65,8 +65,8 @@ import static org.testng.Assert.fail; import java.text.ParsePosition; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ /** * Test CharLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestCharLiteralParser extends AbstractTestPrinterParser { @DataProvider(name="success") @@ -111,8 +111,8 @@ } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } --- old/test/java/time/test/java/time/format/TestCharLiteralPrinter.java 2013-04-11 23:18:00.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestCharLiteralPrinter.java 2013-04-11 23:17:59.000000000 -0700 @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; @@ -68,7 +66,7 @@ /** * Test CharLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestCharLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java 2013-04-11 23:18:00.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java 2013-04-11 23:18:00.000000000 -0700 @@ -59,10 +59,9 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertSame; +import java.time.format.DateTimeFormatSymbols; import java.util.Locale; import org.testng.annotations.Test; @@ -73,7 +72,7 @@ @Test public class TestDateTimeFormatSymbols { - @Test(groups={"implementation"}) + @Test public void test_of_Locale_cached() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.of(Locale.CANADA); DateTimeFormatSymbols loc2 = DateTimeFormatSymbols.of(Locale.CANADA); @@ -81,7 +80,7 @@ } //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_ofDefaultLocale_cached() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.ofDefaultLocale(); DateTimeFormatSymbols loc2 = DateTimeFormatSymbols.ofDefaultLocale(); --- old/test/java/time/test/java/time/format/TestDateTimeFormatter.java 2013-04-11 23:18:01.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestDateTimeFormatter.java 2013-04-11 23:18:01.000000000 -0700 @@ -59,14 +59,15 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static org.testng.Assert.assertSame; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.SignStyle; import java.util.Locale; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -74,14 +75,8 @@ */ @Test public class TestDateTimeFormatter { - // TODO these tests are not tck, as they refer to a non-public class - // rewrite whole test case to use BASIC_FORMATTER or similar - - @BeforeMethod(groups={"tck"}) - public void setUp() { - } - @Test(groups={"implementation"}) + @Test public void test_withLocale_same() throws Exception { DateTimeFormatter base = new DateTimeFormatterBuilder().appendLiteral("ONE") --- old/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java 2013-04-11 23:18:01.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java 2013-04-11 23:18:01.000000000 -0700 @@ -645,17 +645,23 @@ {"GGGG", "Text(Era)"}, {"GGGGG", "Text(Era,NARROW)"}, - {"y", "Value(Year)"}, - {"yy", "ReducedValue(Year,2,2000)"}, - {"yyy", "Value(Year,3,19,NORMAL)"}, - {"yyyy", "Value(Year,4,19,EXCEEDS_PAD)"}, - {"yyyyy", "Value(Year,5,19,EXCEEDS_PAD)"}, - -// {"Y", "Value(WeekBasedYear)"}, -// {"YY", "ReducedValue(WeekBasedYear,2,2000)"}, -// {"YYY", "Value(WeekBasedYear,3,19,NORMAL)"}, -// {"YYYY", "Value(WeekBasedYear,4,19,EXCEEDS_PAD)"}, -// {"YYYYY", "Value(WeekBasedYear,5,19,EXCEEDS_PAD)"}, + {"u", "Value(Year)"}, + {"uu", "ReducedValue(Year,2,2000)"}, + {"uuu", "Value(Year,3,19,NORMAL)"}, + {"uuuu", "Value(Year,4,19,EXCEEDS_PAD)"}, + {"uuuuu", "Value(Year,5,19,EXCEEDS_PAD)"}, + + {"y", "Value(YearOfEra)"}, + {"yy", "ReducedValue(YearOfEra,2,2000)"}, + {"yyy", "Value(YearOfEra,3,19,NORMAL)"}, + {"yyyy", "Value(YearOfEra,4,19,EXCEEDS_PAD)"}, + {"yyyyy", "Value(YearOfEra,5,19,EXCEEDS_PAD)"}, + + {"Y", "Localized(WeekBasedYear)"}, + {"YY", "Localized(ReducedValue(WeekBasedYear,2,2000))"}, + {"YYY", "Localized(WeekBasedYear,3,19,NORMAL)"}, + {"YYYY", "Localized(WeekBasedYear,4,19,EXCEEDS_PAD)"}, + {"YYYYY", "Localized(WeekBasedYear,5,19,EXCEEDS_PAD)"}, {"M", "Value(MonthOfYear)"}, {"MM", "Value(MonthOfYear,2)"}, @@ -663,17 +669,20 @@ {"MMMM", "Text(MonthOfYear)"}, {"MMMMM", "Text(MonthOfYear,NARROW)"}, + {"L", "Value(MonthOfYear)"}, + {"LL", "Value(MonthOfYear,2)"}, + {"LLL", "Text(MonthOfYear,SHORT_STANDALONE)"}, + {"LLLL", "Text(MonthOfYear,FULL_STANDALONE)"}, + {"LLLLL", "Text(MonthOfYear,NARROW_STANDALONE)"}, + {"D", "Value(DayOfYear)"}, {"DD", "Value(DayOfYear,2)"}, {"DDD", "Value(DayOfYear,3)"}, {"d", "Value(DayOfMonth)"}, {"dd", "Value(DayOfMonth,2)"}, - {"ddd", "Value(DayOfMonth,3)"}, - {"F", "Value(AlignedWeekOfMonth)"}, - {"FF", "Value(AlignedWeekOfMonth,2)"}, - {"FFF", "Value(AlignedWeekOfMonth,3)"}, + {"F", "Value(AlignedDayOfWeekInMonth)"}, {"Q", "Value(QuarterOfYear)"}, {"QQ", "Value(QuarterOfYear,2)"}, @@ -681,41 +690,48 @@ {"QQQQ", "Text(QuarterOfYear)"}, {"QQQQQ", "Text(QuarterOfYear,NARROW)"}, - {"E", "Value(DayOfWeek)"}, - {"EE", "Value(DayOfWeek,2)"}, + {"q", "Value(QuarterOfYear)"}, + {"qq", "Value(QuarterOfYear,2)"}, + {"qqq", "Text(QuarterOfYear,SHORT_STANDALONE)"}, + {"qqqq", "Text(QuarterOfYear,FULL_STANDALONE)"}, + {"qqqqq", "Text(QuarterOfYear,NARROW_STANDALONE)"}, + + {"E", "Text(DayOfWeek,SHORT)"}, + {"EE", "Text(DayOfWeek,SHORT)"}, {"EEE", "Text(DayOfWeek,SHORT)"}, {"EEEE", "Text(DayOfWeek)"}, {"EEEEE", "Text(DayOfWeek,NARROW)"}, + {"e", "Localized(DayOfWeek,1)"}, + {"ee", "Localized(DayOfWeek,2)"}, + {"eee", "Text(DayOfWeek,SHORT)"}, + {"eeee", "Text(DayOfWeek)"}, + {"eeeee", "Text(DayOfWeek,NARROW)"}, + + {"c", "Localized(DayOfWeek,1)"}, + {"ccc", "Text(DayOfWeek,SHORT_STANDALONE)"}, + {"cccc", "Text(DayOfWeek,FULL_STANDALONE)"}, + {"ccccc", "Text(DayOfWeek,NARROW_STANDALONE)"}, + {"a", "Text(AmPmOfDay,SHORT)"}, - {"aa", "Text(AmPmOfDay,SHORT)"}, - {"aaa", "Text(AmPmOfDay,SHORT)"}, - {"aaaa", "Text(AmPmOfDay)"}, - {"aaaaa", "Text(AmPmOfDay,NARROW)"}, {"H", "Value(HourOfDay)"}, {"HH", "Value(HourOfDay,2)"}, - {"HHH", "Value(HourOfDay,3)"}, {"K", "Value(HourOfAmPm)"}, {"KK", "Value(HourOfAmPm,2)"}, - {"KKK", "Value(HourOfAmPm,3)"}, {"k", "Value(ClockHourOfDay)"}, {"kk", "Value(ClockHourOfDay,2)"}, - {"kkk", "Value(ClockHourOfDay,3)"}, {"h", "Value(ClockHourOfAmPm)"}, {"hh", "Value(ClockHourOfAmPm,2)"}, - {"hhh", "Value(ClockHourOfAmPm,3)"}, {"m", "Value(MinuteOfHour)"}, {"mm", "Value(MinuteOfHour,2)"}, - {"mmm", "Value(MinuteOfHour,3)"}, {"s", "Value(SecondOfMinute)"}, {"ss", "Value(SecondOfMinute,2)"}, - {"sss", "Value(SecondOfMinute,3)"}, {"S", "Fraction(NanoOfSecond,1,1)"}, {"SS", "Fraction(NanoOfSecond,2,2)"}, @@ -760,22 +776,20 @@ {"ppH", "Pad(Value(HourOfDay),2)"}, {"pppDD", "Pad(Value(DayOfYear,2),3)"}, - {"yyyy[-MM[-dd", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, - {"yyyy[-MM[-dd]]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, - {"yyyy[-MM[]-dd]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)]"}, + {"yyyy[-MM[-dd", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, + {"yyyy[-MM[-dd]]", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, + {"yyyy[-MM[]-dd]", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)]"}, - {"yyyy-MM-dd'T'HH:mm:ss.SSS", "Value(Year,4,19,EXCEEDS_PAD)'-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)" + + {"yyyy-MM-dd'T'HH:mm:ss.SSS", "Value(YearOfEra,4,19,EXCEEDS_PAD)'-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)" + "'T'Value(HourOfDay,2)':'Value(MinuteOfHour,2)':'Value(SecondOfMinute,2)'.'Fraction(NanoOfSecond,3,3)"}, - {"e", "WeekBased(e1)"}, - {"w", "WeekBased(w1)"}, - {"W", "WeekBased(W1)"}, - {"WW", "WeekBased(W2)"}, - + {"w", "Localized(WeekOfWeekBasedYear,1)"}, + {"ww", "Localized(WeekOfWeekBasedYear,2)"}, + {"W", "Localized(WeekOfMonth,1)"}, }; } - @Test(dataProvider="validPatterns", groups={"implementation"}) + @Test(dataProvider="validPatterns") public void test_appendPattern_valid(String input, String expected) throws Exception { builder.appendPattern(input); DateTimeFormatter f = builder.toFormatter(); @@ -798,12 +812,34 @@ {"yyyy]MM"}, {"yyyy[MM]]"}, + {"aa"}, + {"aaa"}, + {"aaaa"}, + {"aaaaa"}, + {"aaaaaa"}, {"MMMMMM"}, + {"LLLLLL"}, {"QQQQQQ"}, + {"qqqqqq"}, {"EEEEEE"}, - {"aaaaaa"}, - {"ZZZZ"}, + {"eeeeee"}, + {"cc"}, + {"cccccc"}, + {"ddd"}, + {"DDDD"}, + {"FF"}, + {"FFF"}, + {"hhh"}, + {"HHH"}, + {"kkk"}, + {"KKK"}, + {"mmm"}, + {"sss"}, + {"OO"}, + {"OOO"}, + {"OOOOO"}, {"XXXXXX"}, + {"ZZZZZZ"}, {"zzzzz"}, {"V"}, {"VVV"}, @@ -823,9 +859,8 @@ {"fa"}, {"fM"}, - {"ww"}, - {"ee"}, - {"WWW"}, + {"www"}, + {"WW"}, }; } @@ -844,9 +879,9 @@ return new Object[][] { {"Q", date(2012, 2, 10), "1"}, {"QQ", date(2012, 2, 10), "01"}, -// {"QQQ", date(2012, 2, 10), "Q1"}, // TODO: data for quarters? -// {"QQQQ", date(2012, 2, 10), "Q1"}, -// {"QQQQQ", date(2012, 2, 10), "Q1"}, + {"QQQ", date(2012, 2, 10), "Q1"}, + {"QQQQ", date(2012, 2, 10), "1st quarter"}, + {"QQQQQ", date(2012, 2, 10), "1"}, }; } --- old/test/java/time/test/java/time/format/TestDateTimeTextProvider.java 2013-04-11 23:18:02.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestDateTimeTextProvider.java 2013-04-11 23:18:02.000000000 -0700 @@ -59,17 +59,16 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static org.testng.Assert.assertEquals; -import java.util.Locale; - import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.TextStyle; import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -77,7 +76,7 @@ /** * Test SimpleDateTimeTextProvider. */ -@Test(groups={"implementation"}) +@Test public class TestDateTimeTextProvider extends AbstractTestPrinterParser { Locale enUS = new Locale("en", "US"); --- old/test/java/time/test/java/time/format/TestFractionPrinterParser.java 2013-04-11 23:18:03.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestFractionPrinterParser.java 2013-04-11 23:18:02.000000000 -0700 @@ -78,7 +78,7 @@ /** * Test FractionPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestFractionPrinterParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) { --- old/test/java/time/test/java/time/format/TestNonIsoFormatter.java 2013-04-11 23:18:03.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestNonIsoFormatter.java 2013-04-11 23:18:03.000000000 -0700 @@ -22,16 +22,29 @@ */ package test.java.time.format; -import java.time.*; -import java.time.chrono.*; -import java.time.format.*; -import java.time.temporal.*; +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.format.FormatStyle; +import java.time.format.TextStyle; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; /** * Test DateTimeFormatter with non-ISO chronology. @@ -39,8 +52,9 @@ * Strings in test data are all dependent on CLDR data which may change * in future CLDR releases. */ -@Test(groups={"implementation"}) +@Test public class TestNonIsoFormatter { + private static final Chronology ISO8601 = IsoChronology.INSTANCE; private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; private static final Chronology HIJRAH = HijrahChronology.INSTANCE; private static final Chronology MINGUO = MinguoChronology.INSTANCE; @@ -50,7 +64,8 @@ private static final Locale ARABIC = new Locale("ar"); private static final Locale thTH = new Locale("th", "TH"); - private static final Locale thTHTH = new Locale("th", "TH", "TH"); + private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai"); + private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); @BeforeMethod public void setUp() { @@ -59,19 +74,22 @@ @DataProvider(name="format_data") Object[][] formatData() { return new Object[][] { - // Chronology, Locale, ChronoLocalDate, expected string - { JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate), - "\u5e73\u621025\u5e742\u670811\u65e5\u6708\u66dc\u65e5" }, // Japanese Heisei 25-02-11 (Mon) - { HIJRAH, ARABIC, HIJRAH.date(IsoDate), - "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 30 \u0631\u0628\u064a\u0639 " - + "\u0627\u0644\u0623\u0648\u0644 1434" }, // Hijrah AH 1434-03-30 (Mon) - { MINGUO, Locale.TAIWAN, MINGUO.date(IsoDate), + // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string + { JAPANESE, Locale.JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate), + "\u5e73\u621025\u5e742\u670811\u65e5" }, // Japanese Heisei 25-02-11 + { HIJRAH, ARABIC, ARABIC, HIJRAH.date(IsoDate), + "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 1 \u0631\u0628\u064a\u0639 " + + "\u0627\u0644\u0622\u062e\u0631 1434" }, // Hijrah AH 1434-04-01 (Mon) + { MINGUO, Locale.TAIWAN, Locale.TAIWAN, MINGUO.date(IsoDate), "\u6c11\u570b102\u5e742\u670811\u65e5\u661f\u671f\u4e00" }, // Minguo ROC 102-02-11 (Mon) - { BUDDHIST, thTH, BUDDHIST.date(IsoDate), + { BUDDHIST, thTH, thTH, BUDDHIST.date(IsoDate), "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48" + " 11 \u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c" + " \u0e1e.\u0e28. 2556" }, // ThaiBuddhist BE 2556-02-11 - // { BUDDHIST, thTHTH, BUDDHIST.date(IsoDate), "" }, // doesn't work + { BUDDHIST, thTH, thTHTH, BUDDHIST.date(IsoDate), + "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48 \u0e51\u0e51 " + + "\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c \u0e1e.\u0e28. " + + "\u0e52\u0e55\u0e55\u0e56" }, // ThaiBuddhist BE 2556-02-11 (with Thai digits) }; } @@ -79,23 +97,49 @@ Object[][] invalidText() { return new Object[][] { // TODO: currently fixed Chronology and Locale. - { "\u662d\u548c64\u5e741\u67089\u65e5\u6708\u66dc\u65e5" }, // S64.01.09 (Mon) + // line commented out, as S64.01.09 seems like a reasonable thing to parse + // (era "S" ended on S64.01.07, but a little leniency is a good thing +// { "\u662d\u548c64\u5e741\u67089\u65e5\u6708\u66dc\u65e5" }, // S64.01.09 (Mon) { "\u662d\u548c65\u5e741\u67081\u65e5\u6708\u66dc\u65e5" }, // S65.01.01 (Mon) }; } + @DataProvider(name="chrono_names") + Object[][] chronoNamesData() { + return new Object[][] { + // Chronology, Locale, Chronology Name + { ISO8601, Locale.ENGLISH, "ISO" }, // No data in CLDR; Use Id. + { BUDDHIST, Locale.ENGLISH, "Buddhist Calendar" }, + { HIJRAH, Locale.ENGLISH, "Hijrah-umalqura" }, // No data in CLDR; Use Id. + { JAPANESE, Locale.ENGLISH, "Japanese Calendar" }, + { MINGUO, Locale.ENGLISH, "Minguo Calendar" }, + + { ISO8601, Locale.JAPANESE, "ISO" }, // No data in CLDR; Use Id. + { JAPANESE, Locale.JAPANESE, "\u548c\u66a6" }, + { BUDDHIST, Locale.JAPANESE, "\u30bf\u30a4\u4ecf\u6559\u66a6" }, + + { ISO8601, thTH, "ISO" }, // No data in CLDR; Use Id. + { JAPANESE, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, + { BUDDHIST, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, + }; + } + @Test(dataProvider="format_data") - public void test_formatLocalizedDate(Chronology chrono, Locale locale, ChronoLocalDate date, String expected) { + public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, + ChronoLocalDate date, String expected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(chrono).withLocale(locale); + .withChronology(chrono).withLocale(formatLocale) + .withSymbols(DateTimeFormatSymbols.of(numberingLocale)); String text = dtf.format(date); assertEquals(text, expected); } @Test(dataProvider="format_data") - public void test_parseLocalizedText(Chronology chrono, Locale locale, ChronoLocalDate expected, String text) { + public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale, + ChronoLocalDate expected, String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(chrono).withLocale(locale); + .withChronology(chrono).withLocale(formatLocale) + .withSymbols(DateTimeFormatSymbols.of(numberingLocale)); TemporalAccessor temporal = dtf.parse(text); ChronoLocalDate date = chrono.date(temporal); assertEquals(date, expected); @@ -105,6 +149,17 @@ public void test_parseInvalidText(String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .withChronology(JAPANESE).withLocale(Locale.JAPANESE); - TemporalAccessor temporal = dtf.parse(text); + dtf.parse(text); + } + + @Test(dataProvider="chrono_names") + public void test_chronoNames(Chronology chrono, Locale locale, String expected) { + DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendChronologyText(TextStyle.SHORT) + .toFormatter(locale); + String text = dtf.format(chrono.dateNow()); + assertEquals(text, expected); + TemporalAccessor ta = dtf.parse(text); + Chronology cal = ta.query(TemporalQuery.chronology()); + assertEquals(cal, chrono); } } --- old/test/java/time/test/java/time/format/TestNumberParser.java 2013-04-11 23:18:04.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestNumberParser.java 2013-04-11 23:18:03.000000000 -0700 @@ -70,9 +70,9 @@ import java.text.ParsePosition; import java.time.format.DateTimeFormatter; import java.time.format.SignStyle; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -80,7 +80,7 @@ /** * Test NumberPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestNumberParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -178,8 +178,8 @@ assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_MONTH), expectedValue); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -198,8 +198,8 @@ assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_WEEK), expectedValue); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -313,8 +313,8 @@ } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -423,8 +423,8 @@ } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -514,8 +514,8 @@ } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -552,8 +552,8 @@ assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(MONTH_OF_YEAR), (long) parseMonth); assertEquals(parsed.getLong(DAY_OF_MONTH), (long) parsedDay); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } --- old/test/java/time/test/java/time/format/TestPadPrinterDecorator.java 2013-04-11 23:18:04.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestPadPrinterDecorator.java 2013-04-11 23:18:04.000000000 -0700 @@ -69,7 +69,7 @@ /** * Test PadPrinterDecorator. */ -@Test(groups={"implementation"}) +@Test public class TestPadPrinterDecorator extends AbstractTestPrinterParser { //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/format/TestReducedParser.java 2013-04-11 23:18:05.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestReducedParser.java 2013-04-11 23:18:05.000000000 -0700 @@ -75,7 +75,7 @@ /** * Test ReducedPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestReducedParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { --- old/test/java/time/test/java/time/format/TestReducedPrinter.java 2013-04-11 23:18:05.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestReducedPrinter.java 2013-04-11 23:18:05.000000000 -0700 @@ -59,24 +59,23 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalField; -import test.java.time.temporal.MockFieldValue; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.temporal.MockFieldValue; /** * Test ReducedPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestReducedPrinter extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { --- old/test/java/time/test/java/time/format/TestSettingsParser.java 2013-04-11 23:18:06.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestSettingsParser.java 2013-04-11 23:18:06.000000000 -0700 @@ -68,7 +68,7 @@ /** * Test SettingsParser. */ -@Test(groups={"implementation"}) +@Test public class TestSettingsParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/format/TestStringLiteralParser.java 2013-04-11 23:18:06.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestStringLiteralParser.java 2013-04-11 23:18:06.000000000 -0700 @@ -65,8 +65,8 @@ import static org.testng.Assert.fail; import java.text.ParsePosition; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ /** * Test StringLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestStringLiteralParser extends AbstractTestPrinterParser { @DataProvider(name="success") @@ -114,8 +114,8 @@ } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } --- old/test/java/time/test/java/time/format/TestStringLiteralPrinter.java 2013-04-11 23:18:07.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestStringLiteralPrinter.java 2013-04-11 23:18:07.000000000 -0700 @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; @@ -68,7 +66,7 @@ /** * Test StringLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestStringLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/format/TestTextParser.java 2013-04-11 23:18:08.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestTextParser.java 2013-04-11 23:18:07.000000000 -0700 @@ -62,10 +62,13 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.text.ParsePosition; +import java.time.DayOfWeek; +import java.time.format.DateTimeFormatter; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; @@ -77,8 +80,10 @@ /** * Test TextPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestTextParser extends AbstractTestPrinterParser { + static final Locale RUSSIAN = new Locale("ru"); + static final Locale FINNISH = new Locale("fi"); //----------------------------------------------------------------------- @DataProvider(name="error") @@ -165,6 +170,21 @@ {MONTH_OF_YEAR, TextStyle.SHORT, 1, "Jan"}, {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"}, + + {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"}, + + {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"}, + + {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"}, }; } @@ -183,6 +203,46 @@ }; } + // Test data is dependent on localized resources. + @DataProvider(name="parseStandaloneText") + Object[][] providerStandaloneText() { + // Locale, TemporalField, TextStyle, expected value, input text + return new Object[][] { + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 12, "\u0414\u0435\u043a\u0430\u0431\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 1, "\u042f\u043d\u0432."}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 12, "\u0414\u0435\u043a."}, + {FINNISH, DAY_OF_WEEK, TextStyle.FULL_STANDALONE, 2, "tiistai"}, + {FINNISH, DAY_OF_WEEK, TextStyle.SHORT_STANDALONE, 2, "ti"}, + }; + } + + @DataProvider(name="parseDayOfWeekText") + Object[][] providerDayOfWeekData() { + return new Object[][] { + // Locale, pattern, input text, expected DayOfWeek + {Locale.US, "e", "1", DayOfWeek.SUNDAY}, + {Locale.US, "ee", "01", DayOfWeek.SUNDAY}, + {Locale.US, "c", "1", DayOfWeek.SUNDAY}, + + {Locale.UK, "e", "1", DayOfWeek.MONDAY}, + {Locale.UK, "ee", "01", DayOfWeek.MONDAY}, + {Locale.UK, "c", "1", DayOfWeek.MONDAY}, + }; + } + + // Test data is dependent on localized resources. + @DataProvider(name="parseLenientText") + Object[][] providerLenientText() { + // Locale, TemporalField, expected value, input text + return new Object[][] { + {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432\u0430\u0440\u044f"}, // full format + {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"}, // full standalone + {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432"}, // short format + {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432."}, // short standalone + }; + } + @Test(dataProvider="parseText") public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); @@ -197,12 +257,32 @@ assertEquals(pos.getIndex(), input.length()); } + @Test(dataProvider="parseStandaloneText") + public void test_parseStandaloneText(Locale locale, TemporalField field, TextStyle style, int expectedValue, String input) { + DateTimeFormatter formatter = getFormatter(field, style).withLocale(locale); + ParsePosition pos = new ParsePosition(0); + assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); + assertEquals(pos.getIndex(), input.length()); + } + + @Test(dataProvider="parseDayOfWeekText") + public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { + DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); + ParsePosition pos = new ParsePosition(0); + assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); + assertEquals(pos.getIndex(), input.length()); + } + //----------------------------------------------------------------------- @Test(dataProvider="parseText") public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { + if (input.equals(input.toUpperCase(Locale.ROOT))) { + // Skip if the given input is all upper case (e.g., "Q1") + return; + } setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); - getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos); + getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos); assertEquals(pos.getErrorIndex(), 0); } @@ -210,16 +290,20 @@ public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos).getLong(field), (long) value); + assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field), (long) value); assertEquals(pos.getIndex(), input.length()); } //----------------------------------------------------------------------- @Test(dataProvider="parseText") public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { + if (input.equals(input.toLowerCase(Locale.ROOT))) { + // Skip if the given input is all lower case (e.g., "1st quarter") + return; + } setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); - getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos); + getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos); assertEquals(pos.getErrorIndex(), 0); } @@ -227,7 +311,7 @@ public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos).getLong(field), (long) value); + assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field), (long) value); assertEquals(pos.getIndex(), input.length()); } @@ -340,4 +424,13 @@ assertEquals(pos.getIndex(), 1); } + @Test(dataProvider="parseLenientText") + public void test_parseLenientText(Locale locale, TemporalField field, int expectedValue, String input) { + setStrict(false); + ParsePosition pos = new ParsePosition(0); + DateTimeFormatter formatter = getFormatter(field).withLocale(locale); + assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); + assertEquals(pos.getIndex(), input.length()); + } + } --- old/test/java/time/test/java/time/format/TestTextPrinter.java 2013-04-11 23:18:08.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestTextPrinter.java 2013-04-11 23:18:08.000000000 -0700 @@ -59,30 +59,33 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static org.testng.Assert.assertEquals; -import java.util.Locale; - import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.LocalDate; -import java.time.temporal.TemporalField; import java.time.chrono.JapaneseChronology; -import test.java.time.temporal.MockFieldValue; +import java.time.format.DateTimeFormatter; +import java.time.format.TextStyle; +import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestTextPrinter extends AbstractTestPrinterParser { + static final Locale RUSSIAN = new Locale("ru"); + static final Locale FINNISH = new Locale("fi"); //----------------------------------------------------------------------- @Test(expectedExceptions=DateTimeException.class) @@ -166,15 +169,57 @@ {MONTH_OF_YEAR, TextStyle.SHORT, 11, "Nov"}, {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 1, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 2, "F"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 3, "M"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 4, "A"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 5, "M"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 6, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 7, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 8, "A"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 9, "S"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 10, "O"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 11, "N"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 12, "D"}, + {ERA, TextStyle.FULL, 0, "Before Christ"}, {ERA, TextStyle.FULL, 1, "Anno Domini"}, {ERA, TextStyle.SHORT, 0, "BC"}, {ERA, TextStyle.SHORT, 1, "AD"}, {ERA, TextStyle.NARROW, 0, "B"}, {ERA, TextStyle.NARROW, 1, "A"}, + + {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"}, + + {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"}, + + {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"}, }; } + @DataProvider(name="print_DayOfWeekData") + Object[][] providerDayOfWeekData() { + return new Object[][] { + // Locale, pattern, expected text, input DayOfWeek + {Locale.US, "e", "1", DayOfWeek.SUNDAY}, + {Locale.US, "ee", "01", DayOfWeek.SUNDAY}, + {Locale.US, "c", "1", DayOfWeek.SUNDAY}, + + {Locale.UK, "e", "1", DayOfWeek.MONDAY}, + {Locale.UK, "ee", "01", DayOfWeek.MONDAY}, + {Locale.UK, "c", "1", DayOfWeek.MONDAY}, + }; + } + @DataProvider(name="print_JapaneseChronology") Object[][] provider_japaneseEra() { return new Object[][] { @@ -184,12 +229,32 @@ }; }; + // Test data is dependent on localized resources. + @DataProvider(name="print_standalone") + Object[][] provider_StandaloneNames() { + return new Object[][] { + // standalone names for 2013-01-01 (Tue) + // Locale, TemporalField, TextStyle, expected text + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, "\u042f\u043d\u0432\u0430\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, "\u042f\u043d\u0432."}, + {FINNISH, DAY_OF_WEEK, TextStyle.FULL_STANDALONE, "tiistai"}, + {FINNISH, DAY_OF_WEEK, TextStyle.SHORT_STANDALONE, "ti"}, + }; + } + @Test(dataProvider="print") public void test_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { getFormatter(field, style).formatTo(new MockFieldValue(field, value), buf); assertEquals(buf.toString(), expected); } + @Test(dataProvider="print_DayOfWeekData") + public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { + DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); + String text = formatter.format(dayOfWeek); + assertEquals(text, expected); + } + @Test(dataProvider="print_JapaneseChronology") public void test_formatJapaneseEra(TemporalField field, TextStyle style, int value, String expected) throws Exception { LocalDate ld = LocalDate.of(2013, 1, 31); @@ -197,6 +262,12 @@ assertEquals(buf.toString(), expected); } + @Test(dataProvider="print_standalone") + public void test_standaloneNames(Locale locale, TemporalField field, TextStyle style, String expected) { + getFormatter(field, style).withLocale(locale).formatTo(LocalDate.of(2013, 1, 1), buf); + assertEquals(buf.toString(), expected); + } + //----------------------------------------------------------------------- public void test_print_french_long() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.FULL).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); --- old/test/java/time/test/java/time/format/TestZoneOffsetParser.java 2013-04-11 23:18:09.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestZoneOffsetParser.java 2013-04-11 23:18:08.000000000 -0700 @@ -73,7 +73,7 @@ /** * Test ZoneOffsetPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestZoneOffsetParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java 2013-04-11 23:18:09.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java 2013-04-11 23:18:09.000000000 -0700 @@ -70,7 +70,7 @@ /** * Test ZoneOffsetPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { private static final ZoneOffset OFFSET_0130 = ZoneOffset.of("+01:30"); --- old/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java 2013-04-11 23:18:10.000000000 -0700 +++ new/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java 2013-04-11 23:18:10.000000000 -0700 @@ -23,7 +23,18 @@ package test.java.time.format; +import static org.testng.Assert.assertEquals; + import java.text.DateFormatSymbols; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalQuery; +import java.time.zone.ZoneRulesProvider; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -32,24 +43,13 @@ import java.util.Set; import java.util.TimeZone; -import java.time.ZonedDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.format.DateTimeFormatSymbols; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.TextStyle; -import java.time.zone.ZoneRulesProvider; - import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; /** * Test ZoneTextPrinterParser */ -@Test(groups={"implementation"}) +@Test public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { protected static DateTimeFormatter getFormatter(Locale locale, TextStyle style) { @@ -70,26 +70,23 @@ zdt = zdt.withDayOfYear(r.nextInt(365) + 1) .with(ChronoField.SECOND_OF_DAY, r.nextInt(86400)); for (String zid : zids) { - if (zid.equals("ROC") || - zid.startsWith("UTC") || - zid.startsWith("GMT") || zid.startsWith("Etc/GMT")) { - // UTC, GMT are treated as zone offset + if (zid.equals("ROC") || zid.startsWith("Etc/GMT")) { continue; // TBD: match jdk behavior? } zdt = zdt.withZoneSameLocal(ZoneId.of(zid)); TimeZone tz = TimeZone.getTimeZone(zid); boolean isDST = tz.inDaylightTime(new Date(zdt.toInstant().toEpochMilli())); for (Locale locale : locales) { - printText(locale, zdt, TextStyle.FULL, - tz.getDisplayName(isDST, TimeZone.LONG, locale)); - printText(locale, zdt, TextStyle.SHORT, - tz.getDisplayName(isDST, TimeZone.SHORT, locale)); + printText(locale, zdt, TextStyle.FULL, tz, + tz.getDisplayName(isDST, TimeZone.LONG, locale)); + printText(locale, zdt, TextStyle.SHORT, tz, + tz.getDisplayName(isDST, TimeZone.SHORT, locale)); } } } } - private void printText(Locale locale, ZonedDateTime zdt, TextStyle style, String expected) { + private void printText(Locale locale, ZonedDateTime zdt, TextStyle style, TimeZone zone, String expected) { String result = getFormatter(locale, style).format(zdt); if (!result.equals(expected)) { if (result.equals("FooLocation")) { // from rules provider test if same vm @@ -97,8 +94,8 @@ } System.out.println("----------------"); System.out.printf("tdz[%s]%n", zdt.toString()); - System.out.printf("[%-4s, %5s] :[%s]%n", locale.toString(), style.toString(),result); - System.out.printf("%4s, %5s :[%s]%n", "", "", expected); + System.out.printf("[%-5s, %5s] :[%s]%n", locale.toString(), style.toString(),result); + System.out.printf(" %5s, %5s :[%s] %s%n", "", "", expected, zone); } assertEquals(result, expected); } @@ -153,7 +150,7 @@ .toFormatter(locale) .withSymbols(DateTimeFormatSymbols.of(locale)); - String ret = fmt.parse(text, Queries.zone()).getId(); + String ret = fmt.parse(text, TemporalQuery.zone()).getId(); System.out.printf("[%-5s %s] %24s -> %s(%s)%n", locale.toString(), @@ -189,7 +186,7 @@ if (ci) { text = text.toUpperCase(); } - String ret = fmt.parse(text, Queries.zone()).getId(); + String ret = fmt.parse(text, TemporalQuery.zone()).getId(); // TBD: need an excluding list // assertEquals(...); if (ret.equals(expected) || --- old/test/java/time/test/java/time/format/ZoneName.java 2013-04-11 23:18:10.000000000 -0700 +++ new/test/java/time/test/java/time/format/ZoneName.java 2013-04-11 23:18:10.000000000 -0700 @@ -24,11 +24,8 @@ package test.java.time.format; import java.util.HashMap; -import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; class ZoneName { --- old/test/java/time/test/java/time/temporal/MockFieldValue.java 2013-04-11 23:18:11.000000000 -0700 +++ new/test/java/time/test/java/time/temporal/MockFieldValue.java 2013-04-11 23:18:11.000000000 -0700 @@ -59,10 +59,11 @@ */ package test.java.time.temporal; -import java.time.temporal.*; - -import java.time.DateTimeException; +import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; /** * Mock simple date-time with one field-value. @@ -88,7 +89,7 @@ if (isSupported(field)) { return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -98,7 +99,7 @@ if (this.field.equals(field)) { return value; } - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } --- old/test/java/time/test/java/time/temporal/TestChronoUnit.java 2013-04-11 23:18:11.000000000 -0700 +++ new/test/java/time/test/java/time/temporal/TestChronoUnit.java 2013-04-11 23:18:11.000000000 -0700 @@ -121,7 +121,11 @@ @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "yearsBetween") @@ -132,7 +136,11 @@ @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- @@ -186,7 +194,11 @@ @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "monthsBetween") @@ -197,7 +209,11 @@ @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- @@ -288,7 +304,11 @@ @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "daysBetween") @@ -299,7 +319,11 @@ @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- --- old/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java 2013-04-11 23:18:12.000000000 -0700 +++ new/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java 2013-04-11 23:18:12.000000000 -0700 @@ -67,8 +67,8 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -92,7 +92,7 @@ Object[][] data_combine() { return new Object[][] { {YEAR, 2012, MONTH_OF_YEAR, 6, DAY_OF_MONTH, 3, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, - {EPOCH_MONTH, (2012 - 1970) * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, + {PROLEPTIC_MONTH, 2012 * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 6, DAY_OF_WEEK, 3, null, null, LocalDate.class, LocalDate.of(2012, 2, 8)}, {YEAR, 2012, DAY_OF_YEAR, 155, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, // {ERA, 1, YEAR_OF_ERA, 2012, DAY_OF_YEAR, 155, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, @@ -176,9 +176,9 @@ {ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4L}, {ALIGNED_WEEK_OF_MONTH, 4, ALIGNED_WEEK_OF_MONTH, 4}, {ALIGNED_DAY_OF_WEEK_IN_MONTH, 3, ALIGNED_DAY_OF_WEEK_IN_MONTH, 3}, - {EPOCH_MONTH, 15, EPOCH_MONTH, null}, - {EPOCH_MONTH, 15, YEAR, 1971}, - {EPOCH_MONTH, 15, MONTH_OF_YEAR, 4}, + {PROLEPTIC_MONTH, 27, PROLEPTIC_MONTH, null}, + {PROLEPTIC_MONTH, 27, YEAR, 2}, + {PROLEPTIC_MONTH, 27, MONTH_OF_YEAR, 4}, }; } --- old/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java 2013-04-11 23:18:13.000000000 -0700 +++ new/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java 2013-04-11 23:18:12.000000000 -0700 @@ -65,7 +65,8 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; - +import java.time.DateTimeException; +import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; import org.testng.annotations.DataProvider; @@ -231,6 +232,42 @@ } //----------------------------------------------------------------------- + // checkValidValue + //----------------------------------------------------------------------- + @Test(dataProvider="valid") + public void test_of_checkValidValue(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + assertEquals(test.checkValidIntValue(sMin, null), sMin); + assertEquals(test.checkValidIntValue(lMin, null), lMin); + assertEquals(test.checkValidIntValue(sMax, null), sMax); + assertEquals(test.checkValidIntValue(lMax, null), lMax); + } + + @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + public void test_of_checkValidValueMinException(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(sMin-1, null); + } + + @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + public void test_of_checkValidValueMaxException(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(lMax+1, null); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_checkValidValueUnsupported_long_long() { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(0, (ChronoField)null); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_checkValidValueInvalid_long_long() { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + } + + //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- public void test_equals1() { --- old/test/java/time/test/java/time/zone/TestFixedZoneRules.java 2013-04-11 23:18:13.000000000 -0700 +++ new/test/java/time/test/java/time/zone/TestFixedZoneRules.java 2013-04-11 23:18:13.000000000 -0700 @@ -83,7 +83,7 @@ } //----------------------------------------------------------------------- - @Test(groups="implementation") + @Test public void test_data_nullInput() { ZoneRules test = make(OFFSET_PONE); assertEquals(test.getOffset((Instant) null), OFFSET_PONE); --- old/test/java/time/test/java/util/TestFormatter.java 2013-04-11 23:18:14.000000000 -0700 +++ new/test/java/time/test/java/util/TestFormatter.java 2013-04-11 23:18:13.000000000 -0700 @@ -35,7 +35,7 @@ /* @test * @summary Unit test for j.u.Formatter threeten date/time support */ -@Test(groups={"implementation"}) +@Test public class TestFormatter { // time --- old/test/java/util/Calendar/Bug8007038.java 2013-04-11 23:18:14.000000000 -0700 +++ new/test/java/util/Calendar/Bug8007038.java 2013-04-11 23:18:14.000000000 -0700 @@ -97,7 +97,7 @@ } private static void checkValueRange(String calType, int field, int value, int style, Locale l, boolean isNonNull) { - String ret = CalendarDataUtility.retrieveFieldValueName(calType, field, value, style, l); + String ret = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, value, style, l); System.out.print("retrieveFieldValueName("+calType+", "+field+", "+value+", "+style+", "+l+")"); if ((ret != null) == isNonNull) { System.out.println(" returned "+ret); --- old/test/java/util/Calendar/CldrFormatNamesTest.java 2013-04-11 23:18:15.000000000 -0700 +++ new/test/java/util/Calendar/CldrFormatNamesTest.java 2013-04-11 23:18:15.000000000 -0700 @@ -48,13 +48,13 @@ { Locale.JAPAN, "field.zone", "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3", - "cldr.japanese.DatePatterns", new String[] { + "java.time.japanese.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy\u5e74M\u6708d\u65e5", "Gyy/MM/dd", }, - "cldr.roc.DatePatterns", new String[] { + "java.time.roc.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy/MM/dd", @@ -65,7 +65,7 @@ { Locale.PRC, "field.zone", "\u533a\u57df", - "cldr.islamic.DatePatterns", new String[] { + "java.time.islamic.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy\u5e74M\u6708d\u65e5", @@ -76,7 +76,7 @@ { Locale.GERMANY, "field.dayperiod", "Tagesh\u00e4lfte", - "cldr.islamic.DatePatterns", new String[] { + "java.time.islamic.DatePatterns", new String[] { "EEEE d. MMMM y G", "d. MMMM y G", "d. MMM y G", @@ -119,7 +119,7 @@ for (Object[] data : CLDR_DATA) { Locale locale = (Locale) data[0]; ResourceBundle rb = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale).getFormatData(); + .getLocaleResources(locale).getJavaTimeFormatData(); for (int i = 1; i < data.length; ) { String key = (String) data[i++]; Object expected = data[i++]; @@ -167,7 +167,7 @@ int field, int style, String fieldName) { for (int i = 0; i < expected.length; i++) { String expt = expected[i]; - String name = CalendarDataUtility.retrieveFieldValueName(calType, field, i, style, locale); + String name = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, i, style, locale); if (!expt.equals(name)) { errors++; System.err.printf("error: wrong %s %s name in %s: value=%d, got='%s', expected='%s'%n", --- old/test/java/util/Calendar/JavatimeTest.java 2013-04-11 23:18:15.000000000 -0700 +++ new/test/java/util/Calendar/JavatimeTest.java 2013-04-11 23:18:15.000000000 -0700 @@ -108,17 +108,20 @@ // TBD: tzdt intergration if (zidStr.startsWith("SystemV") || zidStr.contains("Riyadh8") || - zidStr.equals("US/Pacific-New")) { + zidStr.equals("US/Pacific-New") || + zidStr.equals("EST") || + zidStr.equals("HST") || + zidStr.equals("MST")) { continue; } - ZoneId zid = ZoneId.of(zidStr, ZoneId.OLD_IDS_POST_2005); + ZoneId zid = ZoneId.of(zidStr, ZoneId.OLD_SHORT_IDS); if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) { throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr); } TimeZone tz = TimeZone.getTimeZone(zidStr); // no round-trip for alias and "GMT" if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) && - !ZoneId.OLD_IDS_POST_2005.containsKey(zidStr) && + !ZoneId.OLD_SHORT_IDS.containsKey(zidStr) && !zidStr.startsWith("GMT")) { throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr); } --- old/test/sun/text/resources/LocaleData 2013-04-11 23:18:16.000000000 -0700 +++ new/test/sun/text/resources/LocaleData 2013-04-11 23:18:16.000000000 -0700 @@ -7661,1139 +7661,5 @@ # bug 7195759 CurrencyNames//ZMW=ZMW -# rfe 8004489, 8006509 -FormatData//calendarname.buddhist=Buddhist Calendar -FormatData//calendarname.gregorian=Gregorian Calendar -FormatData//calendarname.gregory=Gregorian Calendar -FormatData//calendarname.islamic-civil=Islamic-Civil Calendar -FormatData//calendarname.islamic=Islamic Calendar -FormatData//calendarname.islamicc=Islamic-Civil Calendar -FormatData//calendarname.japanese=Japanese Calendar -FormatData//calendarname.roc=Minguo Calendar -FormatData//field.dayperiod=Dayperiod -FormatData//field.era=Era -FormatData//field.hour=Hour -FormatData//field.minute=Minute -FormatData//field.month=Month -FormatData//field.second=Second -FormatData//field.week=Week -FormatData//field.weekday=Day of the Week -FormatData//field.year=Year -FormatData//field.zone=Zone -FormatData//islamic.Eras/0= -FormatData//islamic.Eras/1=AH -FormatData//islamic.MonthNames/0=Muharram -FormatData//islamic.MonthNames/1=Safar -FormatData//islamic.MonthNames/2=Rabi\u02bb I -FormatData//islamic.MonthNames/3=Rabi\u02bb II -FormatData//islamic.MonthNames/4=Jumada I -FormatData//islamic.MonthNames/5=Jumada II -FormatData//islamic.MonthNames/6=Rajab -FormatData//islamic.MonthNames/7=Sha\u02bbban -FormatData//islamic.MonthNames/8=Ramadan -FormatData//islamic.MonthNames/9=Shawwal -FormatData//islamic.MonthNames/10=Dhu\u02bbl-Qi\u02bbdah -FormatData//islamic.MonthNames/11=Dhu\u02bbl-Hijjah -FormatData//islamic.MonthNames/12= -FormatData//islamic.MonthAbbreviations/0=Muh. -FormatData//islamic.MonthAbbreviations/1=Saf. -FormatData//islamic.MonthAbbreviations/2=Rab. I -FormatData//islamic.MonthAbbreviations/3=Rab. II -FormatData//islamic.MonthAbbreviations/4=Jum. I -FormatData//islamic.MonthAbbreviations/5=Jum. II -FormatData//islamic.MonthAbbreviations/6=Raj. -FormatData//islamic.MonthAbbreviations/7=Sha. -FormatData//islamic.MonthAbbreviations/8=Ram. -FormatData//islamic.MonthAbbreviations/9=Shaw. -FormatData//islamic.MonthAbbreviations/10=Dhu\u02bbl-Q. -FormatData//islamic.MonthAbbreviations/11=Dhu\u02bbl-H. -FormatData//islamic.MonthAbbreviations/12= -FormatData//islamic.DatePatterns/0=EEEE, MMMM d, y GGGG -FormatData//islamic.DatePatterns/1=MMMM d, y GGGG -FormatData//islamic.DatePatterns/2=MMM d, y GGGG -FormatData//islamic.DatePatterns/3=M/d/yy GGGG -FormatData//roc.Eras/0=Before R.O.C. -FormatData//roc.Eras/1=R.O.C. -FormatData//roc.DatePatterns/0=EEEE, GGGG y MMMM dd -FormatData//roc.DatePatterns/1=GGGG y MMMM d -FormatData//roc.DatePatterns/2=GGGG y MMM d -FormatData//roc.DatePatterns/3=G yyy-MM-dd -FormatData/ar/calendarname.buddhist=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a -FormatData/ar/calendarname.gregorian=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a -FormatData/ar/calendarname.gregory=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a -FormatData/ar/calendarname.islamic-civil=\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a -FormatData/ar/calendarname.islamic=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a -FormatData/ar/calendarname.islamicc=\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a -FormatData/ar/calendarname.japanese=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a -FormatData/ar/calendarname.roc=\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648 -FormatData/ar/field.dayperiod=\u0635/\u0645 -FormatData/ar/field.era=\u0627\u0644\u0639\u0635\u0631 -FormatData/ar/field.hour=\u0627\u0644\u0633\u0627\u0639\u0627\u062a -FormatData/ar/field.minute=\u0627\u0644\u062f\u0642\u0627\u0626\u0642 -FormatData/ar/field.month=\u0627\u0644\u0634\u0647\u0631 -FormatData/ar/field.second=\u0627\u0644\u062b\u0648\u0627\u0646\u064a -FormatData/ar/field.week=\u0627\u0644\u0623\u0633\u0628\u0648\u0639 -FormatData/ar/field.weekday=\u0627\u0644\u064a\u0648\u0645 -FormatData/ar/field.year=\u0627\u0644\u0633\u0646\u0629 -FormatData/ar/field.zone=\u0627\u0644\u062a\u0648\u0642\u064a\u062a -FormatData/ar/islamic.MonthNames/0=\u0645\u062d\u0631\u0645 -FormatData/ar/islamic.MonthNames/1=\u0635\u0641\u0631 -FormatData/ar/islamic.MonthNames/2=\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644 -FormatData/ar/islamic.MonthNames/3=\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631 -FormatData/ar/islamic.MonthNames/4=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649 -FormatData/ar/islamic.MonthNames/5=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629 -FormatData/ar/islamic.MonthNames/6=\u0631\u062c\u0628 -FormatData/ar/islamic.MonthNames/7=\u0634\u0639\u0628\u0627\u0646 -FormatData/ar/islamic.MonthNames/8=\u0631\u0645\u0636\u0627\u0646 -FormatData/ar/islamic.MonthNames/9=\u0634\u0648\u0627\u0644 -FormatData/ar/islamic.MonthNames/10=\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629 -FormatData/ar/islamic.MonthNames/11=\u0630\u0648 \u0627\u0644\u062d\u062c\u0629 -FormatData/ar/islamic.MonthNames/12= -FormatData/ar/islamic.MonthAbbreviations/0=\u0645\u062d\u0631\u0645 -FormatData/ar/islamic.MonthAbbreviations/1=\u0635\u0641\u0631 -FormatData/ar/islamic.MonthAbbreviations/2=\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644 -FormatData/ar/islamic.MonthAbbreviations/3=\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631 -FormatData/ar/islamic.MonthAbbreviations/4=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649 -FormatData/ar/islamic.MonthAbbreviations/5=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629 -FormatData/ar/islamic.MonthAbbreviations/6=\u0631\u062c\u0628 -FormatData/ar/islamic.MonthAbbreviations/7=\u0634\u0639\u0628\u0627\u0646 -FormatData/ar/islamic.MonthAbbreviations/8=\u0631\u0645\u0636\u0627\u0646 -FormatData/ar/islamic.MonthAbbreviations/9=\u0634\u0648\u0627\u0644 -FormatData/ar/islamic.MonthAbbreviations/10=\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629 -FormatData/ar/islamic.MonthAbbreviations/11=\u0630\u0648 \u0627\u0644\u062d\u062c\u0629 -FormatData/ar/islamic.MonthAbbreviations/12= -FormatData/ar/islamic.Eras/0= -FormatData/ar/islamic.Eras/1=\u0647\u0640 -FormatData//islamic.DatePatterns/0=EEEE, MMMM d, y GGGG -FormatData//islamic.DatePatterns/1=MMMM d, y GGGG -FormatData//islamic.DatePatterns/2=MMM d, y GGGG -FormatData//islamic.DatePatterns/3=M/d/yy GGGG -FormatData/ar/roc.DatePatterns/0=EEEE\u060c d MMMM\u060c y GGGG -FormatData/ar/roc.DatePatterns/1=d MMMM\u060c y GGGG -FormatData/ar/roc.DatePatterns/2=dd\u200f/MM\u200f/y GGGG -FormatData/ar/roc.DatePatterns/3=d\u200f/M\u200f/y GGGG -FormatData/be/calendarname.buddhist=\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.gregorian=\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.gregory=\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamic-civil=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamic=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamicc=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.japanese=\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/field.era=\u044d\u0440\u0430 -FormatData/be/field.hour=\u0433\u0430\u0434\u0437\u0456\u043d\u0430 -FormatData/be/field.minute=\u0445\u0432\u0456\u043b\u0456\u043d\u0430 -FormatData/be/field.month=\u043c\u0435\u0441\u044f\u0446 -FormatData/be/field.second=\u0441\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/be/field.week=\u0442\u044b\u0434\u0437\u0435\u043d\u044c -FormatData/be/field.weekday=\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f -FormatData/be/field.year=\u0433\u043e\u0434 -FormatData/bg/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamic-civil=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamic=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamicc=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439 -FormatData/bg/field.dayperiod=\u0434\u0435\u043d -FormatData/bg/field.era=\u0435\u0440\u0430 -FormatData/bg/field.hour=\u0447\u0430\u0441 -FormatData/bg/field.minute=\u043c\u0438\u043d\u0443\u0442\u0430 -FormatData/bg/field.month=\u043c\u0435\u0441\u0435\u0446 -FormatData/bg/field.second=\u0441\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/bg/field.week=\u0441\u0435\u0434\u043c\u0438\u0446\u0430 -FormatData/bg/field.weekday=\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430 -FormatData/bg/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/bg/field.zone=\u0437\u043e\u043d\u0430 -FormatData/bg/islamic.MonthNames/0=\u043c\u0443\u0445\u0430\u0440\u0430\u043c -FormatData/bg/islamic.MonthNames/1=\u0441\u0430\u0444\u0430\u0440 -FormatData/bg/islamic.MonthNames/2=\u0440\u0430\u0431\u0438-1 -FormatData/bg/islamic.MonthNames/3=\u0440\u0430\u0431\u0438-2 -FormatData/bg/islamic.MonthNames/4=\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1 -FormatData/bg/islamic.MonthNames/5=\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2 -FormatData/bg/islamic.MonthNames/6=\u0440\u0430\u0434\u0436\u0430\u0431 -FormatData/bg/islamic.MonthNames/7=\u0448\u0430\u0431\u0430\u043d -FormatData/bg/islamic.MonthNames/8=\u0440\u0430\u043c\u0430\u0437\u0430\u043d -FormatData/bg/islamic.MonthNames/9=\u0428\u0430\u0432\u0430\u043b -FormatData/bg/islamic.MonthNames/10=\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430 -FormatData/bg/islamic.MonthNames/11=\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430 -FormatData/bg/islamic.MonthNames/12= -FormatData/ca/calendarname.buddhist=calendari budista -FormatData/ca/calendarname.gregorian=calendari gregori\u00e0 -FormatData/ca/calendarname.gregory=calendari gregori\u00e0 -FormatData/ca/calendarname.islamic-civil=calendari civil isl\u00e0mic -FormatData/ca/calendarname.islamic=calendari musulm\u00e0 -FormatData/ca/calendarname.islamicc=calendari civil isl\u00e0mic -FormatData/ca/calendarname.japanese=calendari japon\u00e8s -FormatData/ca/calendarname.roc=calendari de la Rep\u00fablica de Xina -FormatData/ca/field.dayperiod=a.m./p.m. -FormatData/ca/field.era=era -FormatData/ca/field.hour=hora -FormatData/ca/field.minute=minut -FormatData/ca/field.month=mes -FormatData/ca/field.second=segon -FormatData/ca/field.week=setmana -FormatData/ca/field.weekday=dia de la setmana -FormatData/ca/field.year=any -FormatData/ca/field.zone=zona -FormatData/cs/calendarname.buddhist=Buddhistick\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.gregorian=Gregori\u00e1nsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.gregory=Gregori\u00e1nsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamic-civil=Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamic=Muslimsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamicc=Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.japanese=Japonsk\u00fd kalend\u00e1\u0159 -FormatData/cs/field.dayperiod=AM/PM -FormatData/cs/field.hour=Hodina -FormatData/cs/field.minute=Minuta -FormatData/cs/field.month=M\u011bs\u00edc -FormatData/cs/field.second=Sekunda -FormatData/cs/field.week=T\u00fdden -FormatData/cs/field.weekday=Den v t\u00fddnu -FormatData/cs/field.year=Rok -FormatData/cs/field.zone=\u010casov\u00e9 p\u00e1smo -FormatData/da/calendarname.buddhist=buddhistisk kalender -FormatData/da/calendarname.gregorian=gregoriansk kalender -FormatData/da/calendarname.gregory=gregoriansk kalender -FormatData/da/calendarname.islamic-civil=verdslig islamisk kalender -FormatData/da/calendarname.islamic=islamisk kalender -FormatData/da/calendarname.islamicc=verdslig islamisk kalender -FormatData/da/calendarname.japanese=japansk kalender -FormatData/da/calendarname.roc=kalender for Republikken Kina -FormatData/da/field.dayperiod=dagtid -FormatData/da/field.era=\u00e6ra -FormatData/da/field.hour=time -FormatData/da/field.minute=minut -FormatData/da/field.month=m\u00e5ned -FormatData/da/field.second=sekund -FormatData/da/field.week=uge -FormatData/da/field.weekday=ugedag -FormatData/da/field.year=\u00e5r -FormatData/da/field.zone=tidszone -FormatData/da/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/da/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/da/roc.DatePatterns/2=d. MMM y GGGG -FormatData/da/roc.DatePatterns/3=d/M/y G -FormatData/da/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/da/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/da/islamic.DatePatterns/2=d. MMM y GGGG -FormatData/da/islamic.DatePatterns/3=d/M/y GGGG -FormatData/de/calendarname.buddhist=Buddhistischer Kalender -FormatData/de/calendarname.gregorian=Gregorianischer Kalender -FormatData/de/calendarname.gregory=Gregorianischer Kalender -FormatData/de/calendarname.islamic-civil=B\u00fcrgerlicher islamischer Kalender -FormatData/de/calendarname.islamic=Islamischer Kalender -FormatData/de/calendarname.islamicc=B\u00fcrgerlicher islamischer Kalender -FormatData/de/calendarname.japanese=Japanischer Kalender -FormatData/de/calendarname.roc=Kalender der Republik China -FormatData/de/field.dayperiod=Tagesh\u00e4lfte -FormatData/de/field.era=Epoche -FormatData/de/field.hour=Stunde -FormatData/de/field.minute=Minute -FormatData/de/field.month=Monat -FormatData/de/field.second=Sekunde -FormatData/de/field.week=Woche -FormatData/de/field.weekday=Wochentag -FormatData/de/field.year=Jahr -FormatData/de/field.zone=Zone -FormatData/de/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/de/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/de/roc.DatePatterns/2=d. MMM y GGGG -FormatData/de/roc.DatePatterns/3=d.M.y G -FormatData/de/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/de/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/de/islamic.DatePatterns/2=d. MMM y GGGG -FormatData/de/islamic.DatePatterns/3=d.M.y GGGG -FormatData/el/calendarname.buddhist=\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.gregorian=\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.gregory=\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamic-civil=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamic=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamicc=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.japanese=\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.roc=\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2 -FormatData/el/field.dayperiod=\u03c0.\u03bc./\u03bc.\u03bc. -FormatData/el/field.era=\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2 -FormatData/el/field.hour=\u038f\u03c1\u03b1 -FormatData/el/field.minute=\u039b\u03b5\u03c0\u03c4\u03cc -FormatData/el/field.month=\u039c\u03ae\u03bd\u03b1\u03c2 -FormatData/el/field.second=\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf -FormatData/el/field.week=\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1 -FormatData/el/field.weekday=\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2 -FormatData/el/field.year=\u0388\u03c4\u03bf\u03c2 -FormatData/el/field.zone=\u0396\u03ce\u03bd\u03b7 -FormatData/el/roc.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/el/roc.DatePatterns/1=d MMMM, y GGGG -FormatData/el/roc.DatePatterns/2=d MMM, y GGGG -FormatData/el/roc.DatePatterns/3=d/M/y GGGG -FormatData/es/calendarname.buddhist=calendario budista -FormatData/es/calendarname.gregorian=calendario gregoriano -FormatData/es/calendarname.gregory=calendario gregoriano -FormatData/es/calendarname.islamic-civil=calendario civil isl\u00e1mico -FormatData/es/calendarname.islamic=calendario isl\u00e1mico -FormatData/es/calendarname.islamicc=calendario civil isl\u00e1mico -FormatData/es/calendarname.japanese=calendario japon\u00e9s -FormatData/es/calendarname.roc=calendario de la Rep\u00fablica de China -FormatData/es/field.dayperiod=periodo del d\u00eda -FormatData/es/field.era=era -FormatData/es/field.hour=hora -FormatData/es/field.minute=minuto -FormatData/es/field.month=mes -FormatData/es/field.second=segundo -FormatData/es/field.week=semana -FormatData/es/field.weekday=d\u00eda de la semana -FormatData/es/field.year=a\u00f1o -FormatData/es/field.zone=zona -FormatData/es/roc.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/es/roc.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/es/roc.DatePatterns/2=dd/MM/y GGGG -FormatData/es/roc.DatePatterns/3=dd/MM/y G -FormatData/es/islamic.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/es/islamic.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/es/islamic.DatePatterns/2=dd/MM/y GGGG -FormatData/es/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/et/calendarname.buddhist=budistlik kalender -FormatData/et/calendarname.gregorian=Gregoriuse kalender -FormatData/et/calendarname.gregory=Gregoriuse kalender -FormatData/et/calendarname.islamic-civil=islami ilmalik kalender -FormatData/et/calendarname.islamic=islamikalender -FormatData/et/calendarname.islamicc=islami ilmalik kalender -FormatData/et/calendarname.japanese=Jaapani kalender -FormatData/et/calendarname.roc=Hiina Vabariigi kalender -FormatData/et/field.dayperiod=enne/p\u00e4rast l\u00f5unat -FormatData/et/field.era=ajastu -FormatData/et/field.hour=tund -FormatData/et/field.minute=minut -FormatData/et/field.month=kuu -FormatData/et/field.second=sekund -FormatData/et/field.week=n\u00e4dal -FormatData/et/field.weekday=n\u00e4dalap\u00e4ev -FormatData/et/field.year=aasta -FormatData/et/field.zone=v\u00f6\u00f6nd -FormatData/fi/calendarname.buddhist=buddhalainen kalenteri -FormatData/fi/calendarname.gregorian=gregoriaaninen kalenteri -FormatData/fi/calendarname.gregory=gregoriaaninen kalenteri -FormatData/fi/calendarname.islamic-civil=islamilainen siviilikalenteri -FormatData/fi/calendarname.islamic=islamilainen kalenteri -FormatData/fi/calendarname.islamicc=islamilainen siviilikalenteri -FormatData/fi/calendarname.japanese=japanilainen kalenteri -FormatData/fi/calendarname.roc=Kiinan tasavallan kalenteri -FormatData/fi/field.dayperiod=vuorokaudenaika -FormatData/fi/field.era=aikakausi -FormatData/fi/field.hour=tunti -FormatData/fi/field.minute=minuutti -FormatData/fi/field.month=kuukausi -FormatData/fi/field.second=sekunti -FormatData/fi/field.week=viikko -FormatData/fi/field.weekday=viikonp\u00e4iv\u00e4 -FormatData/fi/field.year=vuosi -FormatData/fi/field.zone=aikavy\u00f6hyke -FormatData/fi/islamic.MonthNames/0=muharram -FormatData/fi/islamic.MonthNames/1=safar -FormatData/fi/islamic.MonthNames/2=rabi\u2019 al-awwal -FormatData/fi/islamic.MonthNames/3=rabi\u2019 al-akhir -FormatData/fi/islamic.MonthNames/4=d\u017eumada-l-ula -FormatData/fi/islamic.MonthNames/5=d\u017eumada-l-akhira -FormatData/fi/islamic.MonthNames/6=rad\u017eab -FormatData/fi/islamic.MonthNames/7=\u0161a\u2019ban -FormatData/fi/islamic.MonthNames/8=ramadan -FormatData/fi/islamic.MonthNames/9=\u0161awwal -FormatData/fi/islamic.MonthNames/10=dhu-l-qa\u2019da -FormatData/fi/islamic.MonthNames/11=dhu-l-hidd\u017ea -FormatData/fi/islamic.MonthNames/12= -FormatData/fi/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/fi/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/fi/roc.DatePatterns/2=d.M.y GGGG -FormatData/fi/roc.DatePatterns/3=d.M.y GGGG -FormatData/fi/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/fi/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/fi/islamic.DatePatterns/2=d.M.y GGGG -FormatData/fi/islamic.DatePatterns/3=d.M.y GGGG -FormatData/fr/calendarname.buddhist=Calendrier bouddhiste -FormatData/fr/calendarname.gregorian=Calendrier gr\u00e9gorien -FormatData/fr/calendarname.gregory=Calendrier gr\u00e9gorien -FormatData/fr/calendarname.islamic-civil=Calendrier civil musulman -FormatData/fr/calendarname.islamic=Calendrier musulman -FormatData/fr/calendarname.islamicc=Calendrier civil musulman -FormatData/fr/calendarname.japanese=Calendrier japonais -FormatData/fr/calendarname.roc=Calendrier r\u00e9publicain chinois -FormatData/fr/field.dayperiod=cadran -FormatData/fr/field.era=\u00e8re -FormatData/fr/field.hour=heure -FormatData/fr/field.minute=minute -FormatData/fr/field.month=mois -FormatData/fr/field.second=seconde -FormatData/fr/field.week=semaine -FormatData/fr/field.weekday=jour de la semaine -FormatData/fr/field.year=ann\u00e9e -FormatData/fr/field.zone=fuseau horaire -FormatData/fr/islamic.MonthNames/0=Mouharram -FormatData/fr/islamic.MonthNames/1=Safar -FormatData/fr/islamic.MonthNames/2=Rabi\u02bb-oul-Aououal -FormatData/fr/islamic.MonthNames/3=Rabi\u02bb-out-Tani -FormatData/fr/islamic.MonthNames/4=Djoumada-l-Oula -FormatData/fr/islamic.MonthNames/5=Djoumada-t-Tania -FormatData/fr/islamic.MonthNames/6=Radjab -FormatData/fr/islamic.MonthNames/7=Cha\u02bbban -FormatData/fr/islamic.MonthNames/8=Ramadan -FormatData/fr/islamic.MonthNames/9=Chaououal -FormatData/fr/islamic.MonthNames/10=Dou-l-Qa\u02bbda -FormatData/fr/islamic.MonthNames/11=Dou-l-Hidjja -FormatData/fr/islamic.MonthNames/12= -FormatData/fr/islamic.MonthAbbreviations/0=Mouh. -FormatData/fr/islamic.MonthAbbreviations/1=Saf. -FormatData/fr/islamic.MonthAbbreviations/2=Rabi\u02bb-oul-A. -FormatData/fr/islamic.MonthAbbreviations/3=Rabi\u02bb-out-T. -FormatData/fr/islamic.MonthAbbreviations/4=Djoum.-l-O. -FormatData/fr/islamic.MonthAbbreviations/5=Djoum.-t-T. -FormatData/fr/islamic.MonthAbbreviations/6=Radj. -FormatData/fr/islamic.MonthAbbreviations/7=Cha. -FormatData/fr/islamic.MonthAbbreviations/8=Ram. -FormatData/fr/islamic.MonthAbbreviations/9=Chaou. -FormatData/fr/islamic.MonthAbbreviations/10=Dou-l-Q. -FormatData/fr/islamic.MonthAbbreviations/11=Dou-l-H. -FormatData/fr/islamic.MonthAbbreviations/12= -FormatData/fr/islamic.Eras/0= -FormatData/fr/islamic.Eras/1=AH -FormatData/fr/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/fr/roc.DatePatterns/1=d MMMM y GGGG -FormatData/fr/roc.DatePatterns/2=d MMM, y GGGG -FormatData/fr/roc.DatePatterns/3=d/M/y G -FormatData/fr/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/fr/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/fr/islamic.DatePatterns/2=d MMM, y GGGG -FormatData/fr/islamic.DatePatterns/3=d/M/y GGGG -FormatData/hi_IN/calendarname.buddhist=\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.gregorian=\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.gregory=\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamic-civil=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamic=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamicc=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.japanese=\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.roc=\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/field.dayperiod=\u0938\u092e\u092f \u0905\u0935\u0927\u093f -FormatData/hi_IN/field.era=\u092f\u0941\u0917 -FormatData/hi_IN/field.hour=\u0918\u0902\u091f\u093e -FormatData/hi_IN/field.minute=\u092e\u093f\u0928\u091f -FormatData/hi_IN/field.month=\u092e\u093e\u0938 -FormatData/hi_IN/field.second=\u0938\u0947\u0915\u0947\u0902\u0921 -FormatData/hi_IN/field.week=\u0938\u092a\u094d\u0924\u093e\u0939 -FormatData/hi_IN/field.weekday=\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928 -FormatData/hi_IN/field.year=\u0935\u0930\u094d\u0937 -FormatData/hi_IN/field.zone=\u0915\u094d\u0937\u0947\u0924\u094d\u0930 -FormatData/hr/calendarname.buddhist=budisti\u010dki kalendar -FormatData/hr/calendarname.gregorian=gregorijanski kalendar -FormatData/hr/calendarname.gregory=gregorijanski kalendar -FormatData/hr/calendarname.islamic-civil=islamski civilni kalendar -FormatData/hr/calendarname.islamic=islamski kalendar -FormatData/hr/calendarname.islamicc=islamski civilni kalendar -FormatData/hr/calendarname.japanese=japanski kalendar -FormatData/hr/calendarname.roc=kalendar Republike Kine -FormatData/hr/field.dayperiod=dio dana -FormatData/hr/field.era=era -FormatData/hr/field.hour=sat -FormatData/hr/field.minute=minuta -FormatData/hr/field.month=mjesec -FormatData/hr/field.second=sekunda -FormatData/hr/field.week=tjedan -FormatData/hr/field.weekday=dan u tjednu -FormatData/hr/field.year=godina -FormatData/hr/field.zone=zona -FormatData/hr/roc.DatePatterns/0=EEEE, d. MMMM y. GGGG -FormatData/hr/roc.DatePatterns/1=d. MMMM y. GGGG -FormatData/hr/roc.DatePatterns/2=d. M. y. GGGG -FormatData/hr/roc.DatePatterns/3=d.M.y. GGGG -FormatData/hu/calendarname.buddhist=buddhista napt\u00e1r -FormatData/hu/calendarname.gregorian=Gergely-napt\u00e1r -FormatData/hu/calendarname.gregory=Gergely-napt\u00e1r -FormatData/hu/calendarname.islamic-civil=iszl\u00e1m civil napt\u00e1r -FormatData/hu/calendarname.islamic=iszl\u00e1m napt\u00e1r -FormatData/hu/calendarname.islamicc=iszl\u00e1m civil napt\u00e1r -FormatData/hu/calendarname.japanese=jap\u00e1n napt\u00e1r -FormatData/hu/calendarname.roc=K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r -FormatData/hu/field.dayperiod=napszak -FormatData/hu/field.era=\u00e9ra -FormatData/hu/field.hour=\u00f3ra -FormatData/hu/field.minute=perc -FormatData/hu/field.month=h\u00f3nap -FormatData/hu/field.second=m\u00e1sodperc -FormatData/hu/field.week=h\u00e9t -FormatData/hu/field.weekday=h\u00e9t napja -FormatData/hu/field.year=\u00e9v -FormatData/hu/field.zone=z\u00f3na -FormatData/hu/islamic.MonthNames/0=Moharrem -FormatData/hu/islamic.MonthNames/1=Safar -FormatData/hu/islamic.MonthNames/2=R\u00e9bi el avvel -FormatData/hu/islamic.MonthNames/3=R\u00e9bi el accher -FormatData/hu/islamic.MonthNames/4=Dsem\u00e1di el avvel -FormatData/hu/islamic.MonthNames/5=Dsem\u00e1di el accher -FormatData/hu/islamic.MonthNames/6=Redseb -FormatData/hu/islamic.MonthNames/7=Sab\u00e1n -FormatData/hu/islamic.MonthNames/8=Ramad\u00e1n -FormatData/hu/islamic.MonthNames/9=Sevv\u00e1l -FormatData/hu/islamic.MonthNames/10=Ds\u00fcl kade -FormatData/hu/islamic.MonthNames/11=Ds\u00fcl hedse -FormatData/hu/islamic.MonthNames/12= -FormatData/hu/islamic.Eras/0= -FormatData/hu/islamic.Eras/1=MF -FormatData/is/calendarname.buddhist=B\u00fadd\u00edskt dagatal -FormatData/is/calendarname.gregorian=Gregor\u00edskt dagatal -FormatData/is/calendarname.gregory=Gregor\u00edskt dagatal -FormatData/is/calendarname.islamic-civil=\u00cdslamskt borgaradagatal -FormatData/is/calendarname.islamic=\u00cdslamskt dagatal -FormatData/is/calendarname.islamicc=\u00cdslamskt borgaradagatal -FormatData/is/calendarname.japanese=Japanskt dagatal -FormatData/it/calendarname.buddhist=calendario buddista -FormatData/it/calendarname.gregorian=calendario gregoriano -FormatData/it/calendarname.gregory=calendario gregoriano -FormatData/it/calendarname.islamic-civil=calendario civile islamico -FormatData/it/calendarname.islamic=calendario islamico -FormatData/it/calendarname.islamicc=calendario civile islamico -FormatData/it/calendarname.japanese=calendario giapponese -FormatData/it/field.dayperiod=periodo del giorno -FormatData/it/field.era=era -FormatData/it/field.hour=ora -FormatData/it/field.minute=minuto -FormatData/it/field.month=mese -FormatData/it/field.second=secondo -FormatData/it/field.week=settimana -FormatData/it/field.weekday=giorno della settimana -FormatData/it/field.year=anno -FormatData/it/field.zone=zona -FormatData/it/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/it/roc.DatePatterns/1=dd MMMM y GGGG -FormatData/it/roc.DatePatterns/2=dd/MMM/y GGGG -FormatData/it/roc.DatePatterns/3=dd/MM/y GGGG -FormatData/it/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/it/islamic.DatePatterns/1=dd MMMM y GGGG -FormatData/it/islamic.DatePatterns/2=dd/MMM/y GGGG -FormatData/it/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/iw/calendarname.buddhist=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9 -FormatData/iw/calendarname.gregorian=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9 -FormatData/iw/calendarname.gregory=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9 -FormatData/iw/calendarname.islamic-civil=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9 -FormatData/iw/calendarname.islamic=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9 -FormatData/iw/calendarname.islamicc=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9 -FormatData/iw/calendarname.japanese=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9 -FormatData/iw/field.dayperiod=\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6 -FormatData/iw/field.era=\u05ea\u05e7\u05d5\u05e4\u05d4 -FormatData/iw/field.hour=\u05e9\u05e2\u05d4 -FormatData/iw/field.minute=\u05d3\u05e7\u05d4 -FormatData/iw/field.month=\u05d7\u05d5\u05d3\u05e9 -FormatData/iw/field.second=\u05e9\u05e0\u05d9\u05d9\u05d4 -FormatData/iw/field.week=\u05e9\u05d1\u05d5\u05e2 -FormatData/iw/field.weekday=\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2 -FormatData/iw/field.year=\u05e9\u05e0\u05d4 -FormatData/iw/field.zone=\u05d0\u05d6\u05d5\u05e8 -FormatData/iw/islamic.MonthNames/0=\u05de\u05d5\u05d7\u05e8\u05dd -FormatData/iw/islamic.MonthNames/1=\u05e1\u05e4\u05e8 -FormatData/iw/islamic.MonthNames/2=\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/3=\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9 -FormatData/iw/islamic.MonthNames/4=\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/5=\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9 -FormatData/iw/islamic.MonthNames/6=\u05e8\u05d2\u05f3\u05d0\u05d1 -FormatData/iw/islamic.MonthNames/7=\u05e9\u05e2\u05d1\u05d0\u05df -FormatData/iw/islamic.MonthNames/8=\u05e8\u05d0\u05de\u05d3\u05df -FormatData/iw/islamic.MonthNames/9=\u05e9\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/10=\u05d6\u05d5 \u05d0\u05dc-QI'DAH -FormatData/iw/islamic.MonthNames/11=\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4 -FormatData/iw/islamic.MonthNames/12= -FormatData/iw/islamic.Eras/0= -FormatData/iw/islamic.Eras/1=\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4 -FormatData/ja/calendarname.buddhist=\u30bf\u30a4\u4ecf\u6559\u66a6 -FormatData/ja/calendarname.gregorian=\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6] -FormatData/ja/calendarname.gregory=\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6] -FormatData/ja/calendarname.islamic-civil=\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.islamic=\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.islamicc=\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.japanese=\u548c\u66a6 -FormatData/ja/calendarname.roc=\u4e2d\u83ef\u6c11\u56fd\u66a6 -FormatData/ja/field.dayperiod=\u5348\u524d/\u5348\u5f8c -FormatData/ja/field.era=\u6642\u4ee3 -FormatData/ja/field.hour=\u6642 -FormatData/ja/field.minute=\u5206 -FormatData/ja/field.month=\u6708 -FormatData/ja/field.second=\u79d2 -FormatData/ja/field.week=\u9031 -FormatData/ja/field.weekday=\u66dc\u65e5 -FormatData/ja/field.year=\u5e74 -FormatData/ja/field.zone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 -FormatData/ja/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/ja/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/ja/roc.DatePatterns/2=GGGGy/MM/dd -FormatData/ja/roc.DatePatterns/3=GGGGy/MM/dd -FormatData/ko/calendarname.buddhist=\ubd88\uad50\ub825 -FormatData/ko/calendarname.gregorian=\ud0dc\uc591\ub825 -FormatData/ko/calendarname.gregory=\ud0dc\uc591\ub825 -FormatData/ko/calendarname.islamic-civil=\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825 -FormatData/ko/calendarname.islamic=\uc774\uc2ac\ub78c\ub825 -FormatData/ko/calendarname.islamicc=\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825 -FormatData/ko/calendarname.japanese=\uc77c\ubcf8\ub825 -FormatData/ko/calendarname.roc=\ub300\ub9cc\ub825 -FormatData/ko/field.dayperiod=\uc624\uc804/\uc624\ud6c4 -FormatData/ko/field.era=\uc5f0\ud638 -FormatData/ko/field.hour=\uc2dc -FormatData/ko/field.minute=\ubd84 -FormatData/ko/field.month=\uc6d4 -FormatData/ko/field.second=\ucd08 -FormatData/ko/field.week=\uc8fc -FormatData/ko/field.weekday=\uc694\uc77c -FormatData/ko/field.year=\ub144 -FormatData/ko/field.zone=\uc2dc\uac04\ub300 -FormatData/ko/roc.DatePatterns/0=GGGG y\ub144 M\uc6d4 d\uc77c EEEE -FormatData/ko/roc.DatePatterns/1=GGGG y\ub144 M\uc6d4 d\uc77c -FormatData/ko/roc.DatePatterns/2=GGGG y. M. d -FormatData/ko/roc.DatePatterns/3=GGGG y. M. d -FormatData/lt/calendarname.buddhist=Budist\u0173 kalendorius -FormatData/lt/calendarname.gregorian=Grigaliaus kalendorius -FormatData/lt/calendarname.gregory=Grigaliaus kalendorius -FormatData/lt/calendarname.islamic-civil=Pilietinis islamo kalendorius -FormatData/lt/calendarname.islamic=Islamo kalendorius -FormatData/lt/calendarname.islamicc=Pilietinis islamo kalendorius -FormatData/lt/calendarname.japanese=Japon\u0173 kalendorius -FormatData/lt/calendarname.roc=Kinijos Respublikos kalendorius -FormatData/lt/field.dayperiod=dienos metas -FormatData/lt/field.era=era -FormatData/lt/field.hour=valanda -FormatData/lt/field.minute=minut\u0117 -FormatData/lt/field.month=m\u0117nuo -FormatData/lt/field.second=sekund\u0117 -FormatData/lt/field.week=savait\u0117 -FormatData/lt/field.weekday=savait\u0117s diena -FormatData/lt/field.year=metai -FormatData/lt/field.zone=laiko juosta -FormatData/lv/calendarname.buddhist=budistu kalend\u0101rs -FormatData/lv/calendarname.gregorian=Gregora kalend\u0101rs -FormatData/lv/calendarname.gregory=Gregora kalend\u0101rs -FormatData/lv/calendarname.islamic-civil=isl\u0101ma pilso\u0146u kalend\u0101rs -FormatData/lv/calendarname.islamic=isl\u0101ma kalend\u0101rs -FormatData/lv/calendarname.islamicc=isl\u0101ma pilso\u0146u kalend\u0101rs -FormatData/lv/calendarname.japanese=jap\u0101\u0146u kalend\u0101rs -FormatData/lv/calendarname.roc=\u0136\u012bnas Republikas kalend\u0101rs -FormatData/lv/field.dayperiod=Dayperiod -FormatData/lv/field.era=\u0113ra -FormatData/lv/field.hour=Stundas -FormatData/lv/field.minute=Min\u016btes -FormatData/lv/field.month=M\u0113nesis -FormatData/lv/field.second=Sekundes -FormatData/lv/field.week=Ned\u0113\u013ca -FormatData/lv/field.weekday=Ned\u0113\u013cas diena -FormatData/lv/field.year=Gads -FormatData/lv/field.zone=Josla -FormatData/lv/islamic.MonthNames/0=muharams -FormatData/lv/islamic.MonthNames/1=safars -FormatData/lv/islamic.MonthNames/2=1. rab\u012b -FormatData/lv/islamic.MonthNames/3=2. rab\u012b -FormatData/lv/islamic.MonthNames/4=1. d\u017eum\u0101d\u0101 -FormatData/lv/islamic.MonthNames/5=2. d\u017eum\u0101d\u0101 -FormatData/lv/islamic.MonthNames/6=rad\u017eabs -FormatData/lv/islamic.MonthNames/7=\u0161abans -FormatData/lv/islamic.MonthNames/8=ramad\u0101ns -FormatData/lv/islamic.MonthNames/9=\u0161auvals -FormatData/lv/islamic.MonthNames/10=du al-kid\u0101 -FormatData/lv/islamic.MonthNames/11=du al-hid\u017e\u0101 -FormatData/lv/islamic.MonthNames/12= -FormatData/mk/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.gregorian=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.gregory=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.japanese=\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430 -FormatData/mk/field.dayperiod=\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435 -FormatData/mk/field.era=\u0415\u0440\u0430 -FormatData/mk/field.hour=\u0427\u0430\u0441 -FormatData/mk/field.minute=\u041c\u0438\u043d\u0443\u0442\u0430 -FormatData/mk/field.month=\u041c\u0435\u0441\u0435\u0446 -FormatData/mk/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/mk/field.week=\u041d\u0435\u0434\u0435\u043b\u0430 -FormatData/mk/field.weekday=\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430 -FormatData/mk/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/mk/field.zone=\u0437\u043e\u043d\u0430 -FormatData/ms/calendarname.buddhist=Kalendar Buddha -FormatData/ms/calendarname.gregorian=Kalendar Gregory -FormatData/ms/calendarname.gregory=Kalendar Gregory -FormatData/ms/calendarname.islamic-civil=Kalendar Sivil Islam -FormatData/ms/calendarname.islamic=Kalendar Islam -FormatData/ms/calendarname.islamicc=Kalendar Sivil Islam -FormatData/ms/calendarname.japanese=Kalendar Jepun -FormatData/ms/calendarname.roc=Kalendar Minguo -FormatData/ms/field.dayperiod=PG/PTG -FormatData/ms/field.hour=Jam -FormatData/ms/field.minute=Minit -FormatData/ms/field.month=Bulan -FormatData/ms/field.second=Kedua -FormatData/ms/field.week=Minggu -FormatData/ms/field.weekday=Hari dalam Minggu -FormatData/ms/field.year=Tahun -FormatData/ms/field.zone=Zon Waktu -FormatData/ms/roc.DatePatterns/0=EEEE, d MMMM y GGGG -FormatData/ms/roc.DatePatterns/1=d MMMM y GGGG -FormatData/ms/roc.DatePatterns/2=dd/MM/y GGGG -FormatData/ms/roc.DatePatterns/3=d/MM/y GGGG -FormatData/ms/islamic.DatePatterns/0=EEEE, d MMMM y GGGG -FormatData/ms/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/ms/islamic.DatePatterns/2=dd/MM/y GGGG -FormatData/ms/islamic.DatePatterns/3=d/MM/y GGGG -FormatData/mt/calendarname.buddhist=Kalendarju Buddist -FormatData/mt/calendarname.gregorian=Kalendarju Gregorjan -FormatData/mt/calendarname.gregory=Kalendarju Gregorjan -FormatData/mt/calendarname.islamic-civil=Kalendarju Islamiku-\u010aivili -FormatData/mt/calendarname.islamic=Kalendarju Islamiku -FormatData/mt/calendarname.islamicc=Kalendarju Islamiku-\u010aivili -FormatData/mt/calendarname.japanese=Kalendarju \u0120appuni\u017c -FormatData/mt/field.era=Epoka -FormatData/mt/field.hour=Sieg\u0127a -FormatData/mt/field.minute=Minuta -FormatData/mt/field.month=Xahar -FormatData/mt/field.second=Sekonda -FormatData/mt/field.week=\u0120img\u0127a -FormatData/mt/field.weekday=Jum tal-\u0120img\u0127a -FormatData/mt/field.year=Sena -FormatData/mt/field.zone=\u017bona -FormatData/nl/calendarname.buddhist=Boeddhistische kalender -FormatData/nl/calendarname.gregorian=Gregoriaanse kalender -FormatData/nl/calendarname.gregory=Gregoriaanse kalender -FormatData/nl/calendarname.islamic-civil=Islamitische kalender (cyclisch) -FormatData/nl/calendarname.islamic=Islamitische kalender -FormatData/nl/calendarname.islamicc=Islamitische kalender (cyclisch) -FormatData/nl/calendarname.japanese=Japanse kalender -FormatData/nl/calendarname.roc=Kalender van de Chinese Republiek -FormatData/nl/field.dayperiod=AM/PM -FormatData/nl/field.era=Tijdperk -FormatData/nl/field.hour=Uur -FormatData/nl/field.minute=Minuut -FormatData/nl/field.month=Maand -FormatData/nl/field.second=Seconde -FormatData/nl/field.weekday=Dag van de week -FormatData/nl/field.year=Jaar -FormatData/nl/field.zone=Zone -FormatData/nl/islamic.MonthNames/0=Moeharram -FormatData/nl/islamic.MonthNames/1=Safar -FormatData/nl/islamic.MonthNames/2=Rabi\u02bba al awal -FormatData/nl/islamic.MonthNames/3=Rabi\u02bba al thani -FormatData/nl/islamic.MonthNames/4=Joemad\u02bbal awal -FormatData/nl/islamic.MonthNames/5=Joemad\u02bbal thani -FormatData/nl/islamic.MonthNames/6=Rajab -FormatData/nl/islamic.MonthNames/7=Sja\u02bbaban -FormatData/nl/islamic.MonthNames/8=Ramadan -FormatData/nl/islamic.MonthNames/9=Sjawal -FormatData/nl/islamic.MonthNames/10=Doe al ka\u02bbaba -FormatData/nl/islamic.MonthNames/11=Doe al hizja -FormatData/nl/islamic.MonthNames/12= -FormatData/nl/islamic.MonthAbbreviations/0=Moeh. -FormatData/nl/islamic.MonthAbbreviations/1=Saf. -FormatData/nl/islamic.MonthAbbreviations/2=Rab. I -FormatData/nl/islamic.MonthAbbreviations/3=Rab. II -FormatData/nl/islamic.MonthAbbreviations/4=Joem. I -FormatData/nl/islamic.MonthAbbreviations/5=Joem. II -FormatData/nl/islamic.MonthAbbreviations/6=Raj. -FormatData/nl/islamic.MonthAbbreviations/7=Sja. -FormatData/nl/islamic.MonthAbbreviations/8=Ram. -FormatData/nl/islamic.MonthAbbreviations/9=Sjaw. -FormatData/nl/islamic.MonthAbbreviations/10=Doe al k. -FormatData/nl/islamic.MonthAbbreviations/11=Doe al h. -FormatData/nl/islamic.MonthAbbreviations/12= -FormatData/nl/islamic.Eras/0= -FormatData/nl/islamic.Eras/1=Sa\u02bbna Hizjria -FormatData/nl/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/nl/roc.DatePatterns/1=d MMMM y GGGG -FormatData/nl/roc.DatePatterns/2=d MMM y GGGG -FormatData/nl/roc.DatePatterns/3=dd-MM-yy G -FormatData/nl/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/nl/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/nl/islamic.DatePatterns/2=d MMM y GGGG -FormatData/nl/islamic.DatePatterns/3=dd-MM-yy GGGG -FormatData/pl/calendarname.buddhist=kalendarz buddyjski -FormatData/pl/calendarname.gregorian=kalendarz gregoria\u0144ski -FormatData/pl/calendarname.gregory=kalendarz gregoria\u0144ski -FormatData/pl/calendarname.islamic-civil=kalendarz islamski (metoda obliczeniowa) -FormatData/pl/calendarname.islamic=kalendarz islamski (metoda wzrokowa) -FormatData/pl/calendarname.islamicc=kalendarz islamski (metoda obliczeniowa) -FormatData/pl/calendarname.japanese=kalendarz japo\u0144ski -FormatData/pl/calendarname.roc=kalendarz Republiki Chi\u0144skiej -FormatData/pl/field.era=Era -FormatData/pl/field.hour=Godzina -FormatData/pl/field.minute=Minuta -FormatData/pl/field.month=Miesi\u0105c -FormatData/pl/field.second=Sekunda -FormatData/pl/field.week=Tydzie\u0144 -FormatData/pl/field.weekday=Dzie\u0144 tygodnia -FormatData/pl/field.year=Rok -FormatData/pl/field.zone=Strefa -FormatData/pl/roc.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/pl/roc.DatePatterns/1=d MMMM, y GGGG -FormatData/pl/roc.DatePatterns/2=d MMM y GGGG -FormatData/pl/roc.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/pl/islamic.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/pl/islamic.DatePatterns/1=d MMMM, y GGGG -FormatData/pl/islamic.DatePatterns/2=d MMM y GGGG -FormatData/pl/islamic.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/pt/calendarname.buddhist=Calend\u00e1rio Budista -FormatData/pt/calendarname.gregorian=Calend\u00e1rio Gregoriano -FormatData/pt/calendarname.gregory=Calend\u00e1rio Gregoriano -FormatData/pt/calendarname.islamic-civil=Calend\u00e1rio Civil Isl\u00e2mico -FormatData/pt/calendarname.islamic=Calend\u00e1rio Isl\u00e2mico -FormatData/pt/calendarname.islamicc=Calend\u00e1rio Civil Isl\u00e2mico -FormatData/pt/calendarname.japanese=Calend\u00e1rio Japon\u00eas -FormatData/pt/calendarname.roc=Calend\u00e1rio da Rep\u00fablica da China -FormatData/pt/field.dayperiod=Per\u00edodo do dia -FormatData/pt/field.era=Era -FormatData/pt/field.hour=Hora -FormatData/pt/field.minute=Minuto -FormatData/pt/field.month=M\u00eas -FormatData/pt/field.second=Segundo -FormatData/pt/field.week=Semana -FormatData/pt/field.weekday=Dia da semana -FormatData/pt/field.year=Ano -FormatData/pt/field.zone=Fuso -FormatData/pt/roc.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/pt/roc.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/pt/roc.DatePatterns/2=dd/MM/yyyy GGGG -FormatData/pt/roc.DatePatterns/3=d/M/yyyy -FormatData/pt/islamic.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/pt/islamic.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/pt/islamic.DatePatterns/2=dd/MM/yyyy GGGG -FormatData/pt/islamic.DatePatterns/3=d/M/yyyy -FormatData/ro/calendarname.buddhist=calendar budist -FormatData/ro/calendarname.gregorian=calendar gregorian -FormatData/ro/calendarname.gregory=calendar gregorian -FormatData/ro/calendarname.islamic-civil=calendar islamic civil -FormatData/ro/calendarname.islamic=calendar islamic -FormatData/ro/calendarname.islamicc=calendar islamic civil -FormatData/ro/calendarname.japanese=calendar japonez -FormatData/ro/calendarname.roc=calendar al Republicii Chineze -FormatData/ro/field.dayperiod=perioada zilei -FormatData/ro/field.era=er\u0103 -FormatData/ro/field.hour=or\u0103 -FormatData/ro/field.minute=minut -FormatData/ro/field.month=lun\u0103 -FormatData/ro/field.second=secund\u0103 -FormatData/ro/field.week=s\u0103pt\u0103m\u00e2n\u0103 -FormatData/ro/field.weekday=zi a s\u0103pt\u0103m\u00e2nii -FormatData/ro/field.year=an -FormatData/ro/field.zone=zon\u0103 -FormatData/ru/calendarname.buddhist=\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.roc=\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/field.era=\u042d\u0440\u0430 -FormatData/ru/field.hour=\u0427\u0430\u0441 -FormatData/ru/field.minute=\u041c\u0438\u043d\u0443\u0442\u0430 -FormatData/ru/field.month=\u041c\u0435\u0441\u044f\u0446 -FormatData/ru/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/ru/field.week=\u041d\u0435\u0434\u0435\u043b\u044f -FormatData/ru/field.weekday=\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 -FormatData/ru/field.year=\u0413\u043e\u0434 -FormatData/ru/field.zone=\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 -FormatData/ru/islamic.MonthNames/0=\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c -FormatData/ru/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/ru/islamic.MonthNames/2=\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/3=\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440 -FormatData/ru/islamic.MonthNames/4=\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/5=\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440 -FormatData/ru/islamic.MonthNames/6=\u0420\u0430\u0434\u0436\u0430\u0431 -FormatData/ru/islamic.MonthNames/7=\u0428\u0430\u0430\u0431\u0430\u043d -FormatData/ru/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/ru/islamic.MonthNames/9=\u0428\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/10=\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430 -FormatData/ru/islamic.MonthNames/11=\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430 -FormatData/ru/islamic.MonthNames/12= -FormatData/ru/roc.DatePatterns/0=EEEE, d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/roc.DatePatterns/1=d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/roc.DatePatterns/2=dd.MM.yyyy GGGG -FormatData/ru/roc.DatePatterns/3=dd.MM.yy GGGG -FormatData/ru/islamic.DatePatterns/0=EEEE, d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/islamic.DatePatterns/1=d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/islamic.DatePatterns/2=dd.MM.yyyy GGGG -FormatData/ru/islamic.DatePatterns/3=dd.MM.yy GGGG -FormatData/sk/calendarname.buddhist=Buddhistick\u00fd kalend\u00e1r -FormatData/sk/calendarname.gregorian=Gregori\u00e1nsky kalend\u00e1r -FormatData/sk/calendarname.gregory=Gregori\u00e1nsky kalend\u00e1r -FormatData/sk/calendarname.islamic-civil=Islamsk\u00fd ob\u010diansky kalend\u00e1r -FormatData/sk/calendarname.islamic=Islamsk\u00fd kalend\u00e1r -FormatData/sk/calendarname.islamicc=Islamsk\u00fd ob\u010diansky kalend\u00e1r -FormatData/sk/calendarname.japanese=Japonsk\u00fd kalend\u00e1r -FormatData/sk/field.dayperiod=\u010cas\u0165 d\u0148a -FormatData/sk/field.era=\u00c9ra -FormatData/sk/field.hour=Hodina -FormatData/sk/field.minute=Min\u00fata -FormatData/sk/field.month=Mesiac -FormatData/sk/field.second=Sekunda -FormatData/sk/field.week=T\u00fd\u017ede\u0148 -FormatData/sk/field.weekday=De\u0148 v t\u00fd\u017edni -FormatData/sk/field.year=Rok -FormatData/sk/field.zone=P\u00e1smo -FormatData/sl/calendarname.buddhist=budisti\u010dni koledar -FormatData/sl/calendarname.gregorian=gregorijanski koledar -FormatData/sl/calendarname.gregory=gregorijanski koledar -FormatData/sl/calendarname.islamic-civil=islamski civilni koledar -FormatData/sl/calendarname.islamic=islamski koledar -FormatData/sl/calendarname.islamicc=islamski civilni koledar -FormatData/sl/calendarname.japanese=japonski koledar -FormatData/sl/calendarname.roc=kitajski dr\u017eavni koledar -FormatData/sl/field.dayperiod=\u010cas dneva -FormatData/sl/field.era=Doba -FormatData/sl/field.hour=Ura -FormatData/sl/field.minute=Minuta -FormatData/sl/field.month=Mesec -FormatData/sl/field.second=Sekunda -FormatData/sl/field.week=Teden -FormatData/sl/field.weekday=Dan v tednu -FormatData/sl/field.year=Leto -FormatData/sl/field.zone=Obmo\u010dje -FormatData/sr/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.gregorian=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.gregory=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.japanese=\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435 -FormatData/sr/field.dayperiod=\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435 -FormatData/sr/field.era=\u0435\u0440\u0430 -FormatData/sr/field.hour=\u0447\u0430\u0441 -FormatData/sr/field.minute=\u043c\u0438\u043d\u0443\u0442 -FormatData/sr/field.month=\u043c\u0435\u0441\u0435\u0446 -FormatData/sr/field.second=\u0441\u0435\u043a\u0443\u043d\u0434 -FormatData/sr/field.week=\u043d\u0435\u0434\u0435\u0459\u0430 -FormatData/sr/field.weekday=\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438 -FormatData/sr/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/sr/field.zone=\u0437\u043e\u043d\u0430 -FormatData/sr/islamic.MonthNames/0=\u041c\u0443\u0440\u0430\u0445\u0430\u043c -FormatData/sr/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/sr/islamic.MonthNames/2=\u0420\u0430\u0431\u0438\u02bb I -FormatData/sr/islamic.MonthNames/3=\u0420\u0430\u0431\u0438\u02bb II -FormatData/sr/islamic.MonthNames/4=\u0408\u0443\u043c\u0430\u0434\u0430 I -FormatData/sr/islamic.MonthNames/5=\u0408\u0443\u043c\u0430\u0434\u0430 II -FormatData/sr/islamic.MonthNames/6=\u0420\u0430\u0452\u0430\u0431 -FormatData/sr/islamic.MonthNames/7=\u0428\u0430\u02bb\u0431\u0430\u043d -FormatData/sr/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/sr/islamic.MonthNames/9=\u0428\u0430\u0432\u0430\u043b -FormatData/sr/islamic.MonthNames/10=\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430 -FormatData/sr/islamic.MonthNames/11=\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430 -FormatData/sr/islamic.MonthNames/12= -FormatData/sr/islamic.Eras/0= -FormatData/sr/islamic.Eras/1=\u0410\u0425 -FormatData/sv/calendarname.buddhist=buddistisk kalender -FormatData/sv/calendarname.gregorian=gregoriansk kalender -FormatData/sv/calendarname.gregory=gregoriansk kalender -FormatData/sv/calendarname.islamic-civil=islamisk civil kalender -FormatData/sv/calendarname.islamic=islamisk kalender -FormatData/sv/calendarname.islamicc=islamisk civil kalender -FormatData/sv/calendarname.japanese=japansk kalender -FormatData/sv/calendarname.roc=kinesiska republikens kalender -FormatData/sv/field.dayperiod=fm/em -FormatData/sv/field.era=era -FormatData/sv/field.hour=timme -FormatData/sv/field.minute=minut -FormatData/sv/field.month=m\u00e5nad -FormatData/sv/field.second=sekund -FormatData/sv/field.week=vecka -FormatData/sv/field.weekday=veckodag -FormatData/sv/field.year=\u00e5r -FormatData/sv/field.zone=tidszon -FormatData/sv/roc.Eras/0=f\u00f6re R.K. -FormatData/sv/roc.Eras/1=R.K. -FormatData/sv/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/sv/roc.DatePatterns/1=d MMMM y GGGG -FormatData/sv/roc.DatePatterns/2=d MMM y GGGG -FormatData/sv/roc.DatePatterns/3=GGGG y-MM-dd -FormatData/sv/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/sv/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/sv/islamic.DatePatterns/2=d MMM y GGGG -FormatData/sv/islamic.DatePatterns/3=GGGG y-MM-dd -FormatData/th/calendarname.buddhist=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18 -FormatData/th/calendarname.gregorian=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19 -FormatData/th/calendarname.gregory=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19 -FormatData/th/calendarname.islamic-civil=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25 -FormatData/th/calendarname.islamic=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21 -FormatData/th/calendarname.islamicc=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25 -FormatData/th/calendarname.japanese=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19 -FormatData/th/calendarname.roc=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19 -FormatData/th/field.dayperiod=\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19 -FormatData/th/field.era=\u0e2a\u0e21\u0e31\u0e22 -FormatData/th/field.hour=\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07 -FormatData/th/field.minute=\u0e19\u0e32\u0e17\u0e35 -FormatData/th/field.month=\u0e40\u0e14\u0e37\u0e2d\u0e19 -FormatData/th/field.second=\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35 -FormatData/th/field.week=\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c -FormatData/th/field.weekday=\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c -FormatData/th/field.year=\u0e1b\u0e35 -FormatData/th/field.zone=\u0e40\u0e02\u0e15 -FormatData/th/islamic.MonthNames/0=\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21 -FormatData/th/islamic.MonthNames/1=\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c -FormatData/th/islamic.MonthNames/2=\u0e23\u0e2d\u0e1a\u0e35 I -FormatData/th/islamic.MonthNames/3=\u0e23\u0e2d\u0e1a\u0e35 II -FormatData/th/islamic.MonthNames/4=\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I -FormatData/th/islamic.MonthNames/5=\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II -FormatData/th/islamic.MonthNames/6=\u0e23\u0e2d\u0e08\u0e31\u0e1a -FormatData/th/islamic.MonthNames/7=\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19 -FormatData/th/islamic.MonthNames/8=\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19 -FormatData/th/islamic.MonthNames/9=\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25 -FormatData/th/islamic.MonthNames/10=\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c -FormatData/th/islamic.MonthNames/11=\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c -FormatData/th/islamic.MonthNames/12= -FormatData/th/islamic.long.Eras/0= -FormatData/th/islamic.long.Eras/1=\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a -FormatData/th/islamic.Eras/0= -FormatData/th/islamic.Eras/1=\u0e2e.\u0e28. -FormatData/th/roc.DatePatterns/0=EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y -FormatData/th/roc.DatePatterns/1=d MMMM \u0e1b\u0e35GGGG y -FormatData/th/roc.DatePatterns/2=d MMM GGGG y -FormatData/th/roc.DatePatterns/3=d/M/yy -FormatData/tr/calendarname.buddhist=Budist Takvimi -FormatData/tr/calendarname.gregorian=Miladi Takvim -FormatData/tr/calendarname.gregory=Miladi Takvim -FormatData/tr/calendarname.islamic-civil=Arap Takvimi -FormatData/tr/calendarname.islamic=Hicri Takvim -FormatData/tr/calendarname.islamicc=Arap Takvimi -FormatData/tr/calendarname.japanese=Japon Takvimi -FormatData/tr/calendarname.roc=\u00c7in Cumhuriyeti Takvimi -FormatData/tr/field.dayperiod=AM/PM -FormatData/tr/field.era=Miladi D\u00f6nem -FormatData/tr/field.hour=Saat -FormatData/tr/field.minute=Dakika -FormatData/tr/field.month=Ay -FormatData/tr/field.second=Saniye -FormatData/tr/field.week=Hafta -FormatData/tr/field.weekday=Haftan\u0131n G\u00fcn\u00fc -FormatData/tr/field.year=Y\u0131l -FormatData/tr/field.zone=Saat Dilimi -FormatData/tr/islamic.MonthNames/0=Muharrem -FormatData/tr/islamic.MonthNames/1=Safer -FormatData/tr/islamic.MonthNames/2=Rebi\u00fclevvel -FormatData/tr/islamic.MonthNames/3=Rebi\u00fclahir -FormatData/tr/islamic.MonthNames/4=Cemaziyelevvel -FormatData/tr/islamic.MonthNames/5=Cemaziyelahir -FormatData/tr/islamic.MonthNames/6=Recep -FormatData/tr/islamic.MonthNames/7=\u015eaban -FormatData/tr/islamic.MonthNames/8=Ramazan -FormatData/tr/islamic.MonthNames/9=\u015eevval -FormatData/tr/islamic.MonthNames/10=Zilkade -FormatData/tr/islamic.MonthNames/11=Zilhicce -FormatData/tr/islamic.MonthNames/12= -FormatData/tr/roc.DatePatterns/0=dd MMMM y GGGG EEEE -FormatData/tr/roc.DatePatterns/1=dd MMMM y GGGG -FormatData/tr/roc.DatePatterns/2=dd MMM y GGGG -FormatData/tr/roc.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/tr/islamic.DatePatterns/0=dd MMMM y GGGG EEEE -FormatData/tr/islamic.DatePatterns/1=dd MMMM y GGGG -FormatData/tr/islamic.DatePatterns/2=dd MMM y GGGG -FormatData/tr/islamic.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/uk/calendarname.buddhist=\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamic-civil=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamic=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamicc=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.roc=\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 -FormatData/uk/field.dayperiod=\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438 -FormatData/uk/field.era=\u0415\u0440\u0430 -FormatData/uk/field.hour=\u0413\u043e\u0434\u0438\u043d\u0430 -FormatData/uk/field.minute=\u0425\u0432\u0438\u043b\u0438\u043d\u0430 -FormatData/uk/field.month=\u041c\u0456\u0441\u044f\u0446\u044c -FormatData/uk/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/uk/field.week=\u0422\u0438\u0436\u0434\u0435\u043d\u044c -FormatData/uk/field.weekday=\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f -FormatData/uk/field.year=\u0420\u0456\u043a -FormatData/uk/field.zone=\u0417\u043e\u043d\u0430 -FormatData/uk/islamic.MonthNames/0=\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c -FormatData/uk/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/uk/islamic.MonthNames/2=\u0420\u0430\u0431\u0456 I -FormatData/uk/islamic.MonthNames/3=\u0420\u0430\u0431\u0456 II -FormatData/uk/islamic.MonthNames/4=\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I -FormatData/uk/islamic.MonthNames/5=\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II -FormatData/uk/islamic.MonthNames/6=\u0420\u0430\u0434\u0436\u0430\u0431 -FormatData/uk/islamic.MonthNames/7=\u0428\u0430\u0430\u0431\u0430\u043d -FormatData/uk/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/uk/islamic.MonthNames/9=\u0414\u0430\u0432\u0432\u0430\u043b -FormatData/uk/islamic.MonthNames/10=\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430 -FormatData/uk/islamic.MonthNames/11=\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430 -FormatData/uk/islamic.MonthNames/12= -FormatData/vi/calendarname.buddhist=L\u1ecbch Ph\u1eadt Gi\u00e1o -FormatData/vi/calendarname.gregorian=L\u1ecbch Gregory -FormatData/vi/calendarname.gregory=L\u1ecbch Gregory -FormatData/vi/calendarname.islamic-civil=L\u1ecbch Islamic-Civil -FormatData/vi/calendarname.islamic=L\u1ecbch Islamic -FormatData/vi/calendarname.islamicc=L\u1ecbch Islamic-Civil -FormatData/vi/calendarname.japanese=L\u1ecbch Nh\u1eadt B\u1ea3n -FormatData/vi/calendarname.roc=L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c -FormatData/vi/field.dayperiod=SA/CH -FormatData/vi/field.era=Th\u1eddi \u0111\u1ea1i -FormatData/vi/field.hour=Gi\u1edd -FormatData/vi/field.minute=Ph\u00fat -FormatData/vi/field.month=Th\u00e1ng -FormatData/vi/field.second=Gi\u00e2y -FormatData/vi/field.week=Tu\u1ea7n -FormatData/vi/field.weekday=Ng\u00e0y trong tu\u1ea7n -FormatData/vi/field.year=N\u0103m -FormatData/vi/field.zone=M\u00fai gi\u1edd -FormatData/vi/roc.DatePatterns/0=EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG -FormatData/vi/roc.DatePatterns/1='Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG -FormatData/vi/roc.DatePatterns/2=dd-MM-y GGGG -FormatData/vi/roc.DatePatterns/3=dd/MM/y GGGG -FormatData/vi/islamic.DatePatterns/0=EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG -FormatData/vi/islamic.DatePatterns/1='Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG -FormatData/vi/islamic.DatePatterns/2=dd-MM-y GGGG -FormatData/vi/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/zh/calendarname.buddhist=\u4f5b\u6559\u65e5\u5386 -FormatData/zh/calendarname.gregorian=\u516c\u5386 -FormatData/zh/calendarname.gregory=\u516c\u5386 -FormatData/zh/calendarname.islamic-civil=\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386 -FormatData/zh/calendarname.islamic=\u4f0a\u65af\u5170\u65e5\u5386 -FormatData/zh/calendarname.islamicc=\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386 -FormatData/zh/calendarname.japanese=\u65e5\u672c\u65e5\u5386 -FormatData/zh/calendarname.roc=\u6c11\u56fd\u65e5\u5386 -FormatData/zh/field.dayperiod=\u4e0a\u5348/\u4e0b\u5348 -FormatData/zh/field.era=\u65f6\u671f -FormatData/zh/field.hour=\u5c0f\u65f6 -FormatData/zh/field.minute=\u5206\u949f -FormatData/zh/field.month=\u6708 -FormatData/zh/field.second=\u79d2\u949f -FormatData/zh/field.week=\u5468 -FormatData/zh/field.weekday=\u5468\u5929 -FormatData/zh/field.year=\u5e74 -FormatData/zh/field.zone=\u533a\u57df -FormatData/zh/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/roc.DatePatterns/2=GGGGy-M-d -FormatData/zh/roc.DatePatterns/3=GGGGy-M-d -FormatData/zh/islamic.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh/islamic.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/islamic.DatePatterns/2=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/islamic.DatePatterns/3=GGGGyy-MM-dd -FormatData/zh_TW/calendarname.buddhist=\u4f5b\u6559\u66c6\u6cd5 -FormatData/zh_TW/calendarname.gregorian=\u516c\u66c6 -FormatData/zh_TW/calendarname.gregory=\u516c\u66c6 -FormatData/zh_TW/calendarname.islamic-civil=\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5 -FormatData/zh_TW/calendarname.islamic=\u4f0a\u65af\u862d\u66c6\u6cd5 -FormatData/zh_TW/calendarname.islamicc=\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5 -FormatData/zh_TW/calendarname.japanese=\u65e5\u672c\u66c6\u6cd5 -FormatData/zh_TW/calendarname.roc=\u6c11\u570b\u66c6 -FormatData/zh_TW/field.dayperiod=\u4e0a\u5348/\u4e0b\u5348 -FormatData/zh_TW/field.era=\u5e74\u4ee3 -FormatData/zh_TW/field.hour=\u5c0f\u6642 -FormatData/zh_TW/field.minute=\u5206\u9418 -FormatData/zh_TW/field.month=\u6708 -FormatData/zh_TW/field.second=\u79d2 -FormatData/zh_TW/field.week=\u9031 -FormatData/zh_TW/field.weekday=\u9031\u5929 -FormatData/zh_TW/field.year=\u5e74 -FormatData/zh_TW/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh_TW/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh_TW/roc.DatePatterns/2=GGGGy/M/d -FormatData/zh_TW/roc.DatePatterns/3=GGGGy/M/d -FormatData/zh_TW/islamic.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh_TW/islamic.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh_TW/islamic.DatePatterns/2=GGGGy/M/d -FormatData/zh_TW/islamic.DatePatterns/3=GGGGy/M/d - # bug 7114053 LocaleNames/sq/sq=shqip --- old/test/sun/util/calendar/zi/TestZoneInfo310.java 2013-04-11 23:18:17.000000000 -0700 +++ new/test/sun/util/calendar/zi/TestZoneInfo310.java 2013-04-11 23:18:17.000000000 -0700 @@ -68,8 +68,8 @@ } System.out.println("Compiling tz files!"); Main.main(alist.toArray(new String[alist.size()])); - ////////////////////////////////// + ////////////////////////////////// System.out.println("testing!"); ZoneInfoFile.ziDir = zidir; long t0, t1; @@ -97,10 +97,26 @@ Arrays.sort(zids_old); t0 = System.nanoTime(); - ZoneId.of("America/Los_Angeles").getRules(); + String[] alias_old = ZoneInfoOld.getAliasTable() + .keySet().toArray(new String[0]); t1 = System.nanoTime(); - System.out.printf("NEW.getTimeZone()[1]=%d%n", (t1 - t0) / 1000); + System.out.printf("OLD.getAliasTable()=%d, total=%d%n", + (t1 - t0) / 1000, alias_old.length); + Arrays.sort(alias_old); + + t0 = System.currentTimeMillis(); + for (String zid : zids_old) { + ZoneInfoOld.getTimeZone(zid); + } + t1 = System.currentTimeMillis(); + System.out.printf("OLD.TotalTZ()=%d (ms)%n", t1 - t0); +/* + t0 = System.nanoTime(); + ZoneId.of("America/Los_Angeles").getRules(); + t1 = System.nanoTime(); + System.out.printf("NEW.ZoneId.of()[1]=%d%n", (t1 - t0) / 1000); +*/ t0 = System.nanoTime(); TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); t1 = System.nanoTime(); @@ -123,6 +139,14 @@ (t1 - t0) / 1000, zids_new.length); Arrays.sort(zids_new); + t0 = System.nanoTime(); + String[] alias_new = sun.util.calendar.ZoneInfo.getAliasTable() + .keySet().toArray(new String[0]); + t1 = System.nanoTime(); + System.out.printf("NEW.getAliasTable()=%d, total=%d%n", + (t1 - t0) / 1000, alias_new.length); + Arrays.sort(alias_new); + t0 = System.currentTimeMillis(); for (String zid : zids_new) { TimeZone.getTimeZone(zid); @@ -130,16 +154,14 @@ t1 = System.currentTimeMillis(); System.out.printf("NEW.TotalTZ()=%d (ms)%n", t1 - t0); - t0 = System.currentTimeMillis(); - for (String zid : zids_old) { - ZoneInfoOld.getTimeZone(zid); - } - t1 = System.currentTimeMillis(); - System.out.printf("OLD.TotalTZ()=%d (ms)%n", t1 - t0); - if (!Arrays.equals(zids_old, zids_new)) { throw new RuntimeException(" FAILED: availableIds don't match"); } + + if (!Arrays.equals(alias_old, alias_new)) { + throw new RuntimeException(" FAILED: aliases don't match"); + } + for (String zid : zids_new) { ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/java/time/format/Parsed.java 2013-04-11 23:18:17.000000000 -0700 @@ -0,0 +1,482 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.format; + +import static java.time.temporal.ChronoField.AMPM_OF_DAY; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; +import static java.time.temporal.ChronoField.HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.HOUR_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_SECOND; +import static java.time.temporal.ChronoField.MILLI_OF_DAY; +import static java.time.temporal.ChronoField.MILLI_OF_SECOND; +import static java.time.temporal.ChronoField.MINUTE_OF_DAY; +import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.SECOND_OF_DAY; +import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; + +/** + * A store of parsed data. + *

    + * This class is used during parsing to collect the data. Part of the parsing process + * involves handling optional blocks and multiple copies of the data get created to + * support the necessary backtracking. + *

    + * Once parsing is completed, this class can be used as the resultant {@code TemporalAccessor}. + * In most cases, it is only exposed once the fields have been resolved. + * + *

    Specification for implementors

    + * This class is a mutable context intended for use from a single thread. + * Usage of the class is thread-safe within standard parsing as a new instance of this class + * is automatically created for each parse and parsing is single-threaded + * + * @since 1.8 + */ +final class Parsed implements TemporalAccessor { + // some fields are accessed using package scope from DateTimeParseContext + + /** + * The parsed fields. + */ + final Map fieldValues = new HashMap<>(); + /** + * The parsed zone. + */ + ZoneId zone; + /** + * The parsed chronology. + */ + Chronology chrono; + /** + * The effective chronology. + */ + Chronology effectiveChrono; + /** + * The resolver style to use. + */ + private ResolverStyle resolverStyle; + /** + * The resolved date. + */ + private ChronoLocalDate date; + /** + * The resolved time. + */ + private LocalTime time; + + /** + * Creates an instance. + */ + Parsed() { + } + + /** + * Creates a copy. + */ + Parsed copy() { + // only copy fields used in parsing stage + Parsed cloned = new Parsed(); + cloned.fieldValues.putAll(this.fieldValues); + cloned.zone = this.zone; + cloned.chrono = this.chrono; + return cloned; + } + + //----------------------------------------------------------------------- + @Override + public boolean isSupported(TemporalField field) { + if (fieldValues.containsKey(field) || + (date != null && date.isSupported(field)) || + (time != null && time.isSupported(field))) { + return true; + } + return field != null && (field instanceof ChronoField == false) && field.isSupportedBy(this); + } + + @Override + public long getLong(TemporalField field) { + Objects.requireNonNull(field, "field"); + Long value = fieldValues.get(field); + if (value != null) { + return value; + } + if (date != null && date.isSupported(field)) { + return date.getLong(field); + } + if (time != null && time.isSupported(field)) { + return time.getLong(field); + } + if (field instanceof ChronoField) { + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); + } + return field.getFrom(this); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId()) { + return (R) zone; + } else if (query == TemporalQuery.chronology()) { + return (R) chrono; + } else if (query == TemporalQuery.localDate()) { + return (R) (date != null ? LocalDate.from(date) : null); + } else if (query == TemporalQuery.localTime()) { + return (R) time; + } else if (query == TemporalQuery.zone() || query == TemporalQuery.offset()) { + return query.queryFrom(this); + } else if (query == TemporalQuery.precision()) { + return null; // not a complete date/time + } + // inline TemporalAccessor.super.query(query) as an optimization + // non-JDK classes are not permitted to make this optimization + return query.queryFrom(this); + } + + //----------------------------------------------------------------------- + /** + * Resolves the fields in this context. + * + * @param resolverStyle the resolver style, not null + * @param resolverFields the fields to use for resolving, null for all fields + * @return this, for method chaining + * @throws DateTimeException if resolving one field results in a value for + * another field that is in conflict + */ + TemporalAccessor resolve(ResolverStyle resolverStyle, Set resolverFields) { + if (resolverFields != null) { + fieldValues.keySet().retainAll(resolverFields); + } + this.resolverStyle = resolverStyle; + chrono = effectiveChrono; + resolveFields(); + resolveTimeLenient(); + crossCheck(); + return this; + } + + //----------------------------------------------------------------------- + private void resolveFields() { + // resolve ChronoField + resolveDateFields(); + resolveTimeFields(); + + // if any other fields, handle them + // any lenient date resolution should return epoch-day + if (fieldValues.size() > 0) { + boolean changed = false; + outer: + while (true) { + for (Map.Entry entry : fieldValues.entrySet()) { + TemporalField targetField = entry.getKey(); + Map changes = targetField.resolve(this, entry.getValue(), resolverStyle); + if (changes != null) { + changed = true; + resolveFieldsMakeChanges(targetField, changes); + fieldValues.remove(targetField); // helps avoid infinite loops + continue outer; // have to restart to avoid concurrent modification + } + } + break; + } + // if something changed then have to redo ChronoField resolve + if (changed) { + resolveDateFields(); + resolveTimeFields(); + } + } + } + + private void resolveFieldsMakeChanges(TemporalField targetField, Map changes) { + for (Map.Entry change : changes.entrySet()) { + TemporalField changeField = change.getKey(); + Long changeValue = change.getValue(); + Objects.requireNonNull(changeField, "changeField"); + if (changeValue != null) { + updateCheckConflict(targetField, changeField, changeValue); + } else { + fieldValues.remove(changeField); + } + } + } + + private void updateCheckConflict(TemporalField targetField, TemporalField changeField, Long changeValue) { + Long old = fieldValues.put(changeField, changeValue); + if (old != null && old.longValue() != changeValue.longValue()) { + throw new DateTimeException("Conflict found: " + changeField + " " + old + + " differs from " + changeField + " " + changeValue + + " while resolving " + targetField); + } + } + + //----------------------------------------------------------------------- + private void resolveDateFields() { + updateCheckConflict(chrono.resolveDate(fieldValues, resolverStyle)); + } + + private void updateCheckConflict(ChronoLocalDate cld) { + if (date != null) { + if (cld != null && date.equals(cld) == false) { + throw new DateTimeException("Conflict found: Fields resolved to two different dates: " + date + " " + cld); + } + } else { + date = cld; + } + } + + //----------------------------------------------------------------------- + private void resolveTimeFields() { + // simplify fields + if (fieldValues.containsKey(CLOCK_HOUR_OF_DAY)) { + long ch = fieldValues.remove(CLOCK_HOUR_OF_DAY); + updateCheckConflict(CLOCK_HOUR_OF_DAY, HOUR_OF_DAY, ch == 24 ? 0 : ch); + } + if (fieldValues.containsKey(CLOCK_HOUR_OF_AMPM)) { + long ch = fieldValues.remove(CLOCK_HOUR_OF_AMPM); + updateCheckConflict(CLOCK_HOUR_OF_AMPM, HOUR_OF_AMPM, ch == 12 ? 0 : ch); + } + if (fieldValues.containsKey(AMPM_OF_DAY) && fieldValues.containsKey(HOUR_OF_AMPM)) { + long ap = fieldValues.remove(AMPM_OF_DAY); + long hap = fieldValues.remove(HOUR_OF_AMPM); + updateCheckConflict(AMPM_OF_DAY, HOUR_OF_DAY, ap * 12 + hap); + } + if (fieldValues.containsKey(MICRO_OF_DAY)) { + long cod = fieldValues.remove(MICRO_OF_DAY); + updateCheckConflict(MICRO_OF_DAY, SECOND_OF_DAY, cod / 1_000_000L); + updateCheckConflict(MICRO_OF_DAY, MICRO_OF_SECOND, cod % 1_000_000L); + } + if (fieldValues.containsKey(MILLI_OF_DAY)) { + long lod = fieldValues.remove(MILLI_OF_DAY); + updateCheckConflict(MILLI_OF_DAY, SECOND_OF_DAY, lod / 1_000); + updateCheckConflict(MILLI_OF_DAY, MILLI_OF_SECOND, lod % 1_000); + } + if (fieldValues.containsKey(SECOND_OF_DAY)) { + long sod = fieldValues.remove(SECOND_OF_DAY); + updateCheckConflict(SECOND_OF_DAY, HOUR_OF_DAY, sod / 3600); + updateCheckConflict(SECOND_OF_DAY, MINUTE_OF_HOUR, (sod / 60) % 60); + updateCheckConflict(SECOND_OF_DAY, SECOND_OF_MINUTE, sod % 60); + } + if (fieldValues.containsKey(MINUTE_OF_DAY)) { + long mod = fieldValues.remove(MINUTE_OF_DAY); + updateCheckConflict(MINUTE_OF_DAY, HOUR_OF_DAY, mod / 60); + updateCheckConflict(MINUTE_OF_DAY, MINUTE_OF_HOUR, mod % 60); + } + + // combine partial second fields strictly, leaving lenient expansion to later + if (fieldValues.containsKey(NANO_OF_SECOND)) { + long nos = fieldValues.get(NANO_OF_SECOND); + if (fieldValues.containsKey(MICRO_OF_SECOND)) { + long cos = fieldValues.remove(MICRO_OF_SECOND); + nos = cos * 1000 + (nos % 1000); + updateCheckConflict(MICRO_OF_SECOND, NANO_OF_SECOND, nos); + } + if (fieldValues.containsKey(MILLI_OF_SECOND)) { + long los = fieldValues.remove(MILLI_OF_SECOND); + updateCheckConflict(MILLI_OF_SECOND, NANO_OF_SECOND, los * 1_000_000L + (nos % 1_000_000L)); + } + } + + // convert to time if possible + if (fieldValues.containsKey(NANO_OF_DAY)) { + long nod = fieldValues.remove(NANO_OF_DAY); + updateCheckConflict(LocalTime.ofNanoOfDay(nod)); + } + if (fieldValues.containsKey(HOUR_OF_DAY) && fieldValues.containsKey(MINUTE_OF_HOUR) && + fieldValues.containsKey(SECOND_OF_MINUTE) && fieldValues.containsKey(NANO_OF_SECOND)) { + int hodVal = HOUR_OF_DAY.checkValidIntValue(fieldValues.remove(HOUR_OF_DAY)); + int mohVal = MINUTE_OF_HOUR.checkValidIntValue(fieldValues.remove(MINUTE_OF_HOUR)); + int somVal = SECOND_OF_MINUTE.checkValidIntValue(fieldValues.remove(SECOND_OF_MINUTE)); + int nosVal = NANO_OF_SECOND.checkValidIntValue(fieldValues.remove(NANO_OF_SECOND)); + updateCheckConflict(LocalTime.of(hodVal, mohVal, somVal, nosVal)); + } + } + + private void resolveTimeLenient() { + // leniently create a time from incomplete information + // done after everything else as it creates information from nothing + // which would break updateCheckConflict(field) + + if (time == null) { + // can only get here if NANO_OF_SECOND not present + if (fieldValues.containsKey(MILLI_OF_SECOND)) { + long los = fieldValues.remove(MILLI_OF_SECOND); + if (fieldValues.containsKey(MICRO_OF_SECOND)) { + // merge milli-of-second and micro-of-second for better error message + long cos = los * 1_000 + (fieldValues.get(MICRO_OF_SECOND) % 1_000); + updateCheckConflict(MILLI_OF_SECOND, MICRO_OF_SECOND, cos); + fieldValues.remove(MICRO_OF_SECOND); + fieldValues.put(NANO_OF_SECOND, cos * 1_000L); + } else { + // convert milli-of-second to nano-of-second + fieldValues.put(NANO_OF_SECOND, los * 1_000_000L); + } + } else if (fieldValues.containsKey(MICRO_OF_SECOND)) { + // convert micro-of-second to nano-of-second + long cos = fieldValues.remove(MICRO_OF_SECOND); + fieldValues.put(NANO_OF_SECOND, cos * 1_000L); + } + } + + // merge hour/minute/second/nano leniently + Long hod = fieldValues.get(HOUR_OF_DAY); + if (hod != null) { + int hodVal = HOUR_OF_DAY.checkValidIntValue(hod); + Long moh = fieldValues.get(MINUTE_OF_HOUR); + Long som = fieldValues.get(SECOND_OF_MINUTE); + Long nos = fieldValues.get(NANO_OF_SECOND); + + // check for invalid combinations that cannot be defaulted + if (time == null) { + if ((moh == null && (som != null || nos != null)) || + (moh != null && som == null && nos != null)) { + return; + } + } + + // default as necessary and build time + int mohVal = (moh != null ? MINUTE_OF_HOUR.checkValidIntValue(moh) : (time != null ? time.getMinute() : 0)); + int somVal = (som != null ? SECOND_OF_MINUTE.checkValidIntValue(som) : (time != null ? time.getSecond() : 0)); + int nosVal = (nos != null ? NANO_OF_SECOND.checkValidIntValue(nos) : (time != null ? time.getNano() : 0)); + updateCheckConflict(LocalTime.of(hodVal, mohVal, somVal, nosVal)); + fieldValues.remove(HOUR_OF_DAY); + fieldValues.remove(MINUTE_OF_HOUR); + fieldValues.remove(SECOND_OF_MINUTE); + fieldValues.remove(NANO_OF_SECOND); + } + } + + private void updateCheckConflict(LocalTime lt) { + if (time != null) { + if (lt != null && time.equals(lt) == false) { + throw new DateTimeException("Conflict found: Fields resolved to two different times: " + time + " " + lt); + } + } else { + time = lt; + } + } + + //----------------------------------------------------------------------- + private void crossCheck() { + // only cross-check date, time and date-time + // avoid object creation if possible + if (date != null) { + crossCheck(date); + } + if (time != null) { + crossCheck(time); + if (date != null && fieldValues.size() > 0) { + crossCheck(date.atTime(time)); + } + } + } + + private void crossCheck(TemporalAccessor target) { + for (Iterator> it = fieldValues.entrySet().iterator(); it.hasNext(); ) { + Entry entry = it.next(); + TemporalField field = entry.getKey(); + long val1; + try { + val1 = target.getLong(field); + } catch (RuntimeException ex) { + continue; + } + long val2 = entry.getValue(); + if (val1 != val2) { + throw new DateTimeException("Conflict found: Field " + field + " " + val1 + + " differs from " + field + " " + val2 + " derived from " + target); + } + it.remove(); + } + } + + //----------------------------------------------------------------------- + @Override + public String toString() { + String str = fieldValues.toString() + "," + chrono + "," + zone; + if (date != null || time != null) { + str += " resolved to " + date + "," + time; + } + return str; + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/java/time/format/ResolverStyle.java 2013-04-11 23:18:18.000000000 -0700 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.format; + +/** + * Enumeration of different ways to resolve dates and times. + *

    + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * This style is used to control how phase 2, resolving, happens. + * + *

    Specification for implementors

    + * This is an immutable and thread-safe enum. + * + * @since 1.8 + */ +public enum ResolverStyle { + + /** + * Style to resolve dates and times strictly. + *

    + * Using strict resolution will ensure that all parsed values are within + * the outer range of valid values for the field. Individual fields may + * be further processed for strictness. + *

    + * For example, resolving year-month and day-of-month in the ISO calendar + * system using strict mode will ensure that the day-of-month is valid + * for the year-month, rejecting invalid values. + */ + STRICT, + /** + * Style to resolve dates and times in a smart, or intelligent, manner. + *

    + * Using smart resolution will perform the sensible default for each + * field, which may be the same as strict, the same as lenient, or a third + * behavior. Individual fields will interpret this differently. + *

    + * For example, resolving year-month and day-of-month in the ISO calendar + * system using smart mode will ensure that the day-of-month is valid + * for the year-month, rejecting invalid values, with the exception that + * February 29th in a year other than a leap year will be converted to + * February 28th. + */ + SMART, + /** + * Style to resolve dates and times leniently. + *

    + * Using lenient resolution will resolve the values in an appropriate + * lenient manner. Individual fields will interpret this differently. + *

    + * For example, lenient mode allows the month in the ISO calendar system + * to be outside the range 1 to 12. + */ + LENIENT; + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/java/time/temporal/TemporalAdjusters.java 2013-04-11 23:18:18.000000000 -0700 @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2012-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.temporal; + +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.YEARS; + +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.util.Objects; +import java.util.function.UnaryOperator; + +/** + * Implementations of the static methods in {@code TemporalAdjuster} + * + * @since 1.8 + */ +final class TemporalAdjusters { + // work around compiler bug not allowing lambdas in static methods + + private TemporalAdjusters() { + } + + //----------------------------------------------------------------------- + /** + * Obtains a {@code TemporalAdjuster} that wraps a date adjuster. + *

    + * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. + * This method allows an adjustment from {@code LocalDate} to {@code LocalDate} + * to be wrapped to match the temporal-based interface. + * This is provided for convenience to make user-written adjusters simpler. + *

    + * In general, user-written adjusters should be static constants: + *

    +     *  public static TemporalAdjuster TWO_DAYS_LATER = TemporalAdjuster.ofDateAdjuster(
    +     *    date -> date.plusDays(2));
    +     * 
    + * + * @param dateBasedAdjuster the date-based adjuster, not null + * @return the temporal adjuster wrapping on the date adjuster, not null + */ + static TemporalAdjuster ofDateAdjuster(UnaryOperator dateBasedAdjuster) { + Objects.requireNonNull(dateBasedAdjuster, "dateBasedAdjuster"); + return (temporal) -> { + LocalDate input = LocalDate.from(temporal); + LocalDate output = dateBasedAdjuster.apply(input); + return temporal.with(output); + }; + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of month" adjuster, which returns a new date set to + * the first day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-02-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1);
    +     * 
    + * + * @return the first day-of-month adjuster, not null + */ + static TemporalAdjuster firstDayOfMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, 1); + } + + /** + * Returns the "last day of month" adjuster, which returns a new date set to + * the last day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-31.
    + * The input 2011-02-15 will return 2011-02-28.
    + * The input 2012-02-15 will return 2012-02-29 (leap year).
    + * The input 2011-04-15 will return 2011-04-30. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_MONTH).getMaximum();
    +     *  temporal.with(DAY_OF_MONTH, lastDay);
    +     * 
    + * + * @return the last day-of-month adjuster, not null + */ + static TemporalAdjuster lastDayOfMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); + } + + /** + * Returns the "first day of next month" adjuster, which returns a new date set to + * the first day of the next month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-02-01.
    + * The input 2011-02-15 will return 2011-03-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS); + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of year" adjuster, which returns a new date set to + * the first day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-01-01.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1);
    +     * 
    + * + * @return the first day-of-year adjuster, not null + */ + static TemporalAdjuster firstDayOfYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, 1); + } + + /** + * Returns the "last day of year" adjuster, which returns a new date set to + * the last day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-12-31.
    + * The input 2011-02-15 will return 2011-12-31.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_YEAR).getMaximum();
    +     *  temporal.with(DAY_OF_YEAR, lastDay);
    +     * 
    + * + * @return the last day-of-year adjuster, not null + */ + static TemporalAdjuster lastDayOfYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum()); + } + + /** + * Returns the "first day of next year" adjuster, which returns a new date set to + * the first day of the next year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2012-01-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS); + } + + //----------------------------------------------------------------------- + /** + * Returns the first in month adjuster, which returns a new date + * in the same month with the first matching day-of-week. + * This is used for expressions like 'first Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-05.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-02.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(1, dayOfWeek); + } + + /** + * Returns the last in month adjuster, which returns a new date + * in the same month with the last matching day-of-week. + * This is used for expressions like 'last Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-26.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-30.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(-1, dayOfWeek); + } + + /** + * Returns the day-of-week in month adjuster, which returns a new date + * in the same month with the ordinal day-of-week. + * This is used for expressions like the 'second Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (1,TUESDAY) will return 2011-12-06.
    + * The input 2011-12-15 for (2,TUESDAY) will return 2011-12-13.
    + * The input 2011-12-15 for (3,TUESDAY) will return 2011-12-20.
    + * The input 2011-12-15 for (4,TUESDAY) will return 2011-12-27.
    + * The input 2011-12-15 for (5,TUESDAY) will return 2012-01-03.
    + * The input 2011-12-15 for (-1,TUESDAY) will return 2011-12-27 (last in month).
    + * The input 2011-12-15 for (-4,TUESDAY) will return 2011-12-06 (3 weeks before last in month).
    + * The input 2011-12-15 for (-5,TUESDAY) will return 2011-11-29 (4 weeks before last in month).
    + * The input 2011-12-15 for (0,TUESDAY) will return 2011-11-29 (last in previous month).
    + *

    + * For a positive or zero ordinal, the algorithm is equivalent to finding the first + * day-of-week that matches within the month and then adding a number of weeks to it. + * For a negative ordinal, the algorithm is equivalent to finding the last + * day-of-week that matches within the month and then subtracting a number of weeks to it. + * The ordinal number of weeks is not validated and is interpreted leniently + * according to this algorithm. This definition means that an ordinal of zero finds + * the last matching day-of-week in the previous month. + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param ordinal the week within the month, unbounded but typically from -5 to 5 + * @param dayOfWeek the day-of-week, not null + * @return the day-of-week in month adjuster, not null + */ + static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) { + Objects.requireNonNull(dayOfWeek, "dayOfWeek"); + int dowValue = dayOfWeek.getValue(); + if (ordinal >= 0) { + return (temporal) -> { + Temporal temp = temporal.with(DAY_OF_MONTH, 1); + int curDow = temp.get(DAY_OF_WEEK); + int dowDiff = (dowValue - curDow + 7) % 7; + dowDiff += (ordinal - 1L) * 7L; // safe from overflow + return temp.plus(dowDiff, DAYS); + }; + } else { + return (temporal) -> { + Temporal temp = temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); + int curDow = temp.get(DAY_OF_WEEK); + int daysDiff = dowValue - curDow; + daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff)); + daysDiff -= (-ordinal - 1L) * 7L; // safe from overflow + return temp.plus(daysDiff, DAYS); + }; + } + } + + //----------------------------------------------------------------------- + /** + * Returns the next day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-22 (seven days later). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the next day-of-week adjuster, not null + */ + static TemporalAdjuster next(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + int daysDiff = calDow - dowValue; + return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; + } + + /** + * Returns the next-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the next-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + if (calDow == dowValue) { + return temporal; + } + int daysDiff = calDow - dowValue; + return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; + } + + /** + * Returns the previous day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-08 (seven days earlier). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the previous day-of-week adjuster, not null + */ + static TemporalAdjuster previous(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + int daysDiff = dowValue - calDow; + return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; + } + + /** + * Returns the previous-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the previous-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + if (calDow == dowValue) { + return temporal; + } + int daysDiff = dowValue - calDow; + return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/java/time/temporal/TemporalQueries.java 2013-04-11 23:18:19.000000000 -0700 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.temporal; + +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.OFFSET_SECONDS; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.chrono.Chronology; + +/** + * Common implementations of {@code TemporalQuery}. + *

    + * This class provides common implementations of {@link TemporalQuery}. + * These are defined here as they must be constants, and the definition + * of lambdas does not guarantee that. By assigning them once here, + * they become 'normal' Java constants. + * + * @since 1.8 + */ +final class TemporalQueries { + // note that it is vital that each method supplies a constant, not a + // calculated value, as they will be checked for using == + // it is also vital that each constant is different (due to the == checking) + // as such, alterations to this code must be done with care + + /** + * Private constructor since this is a utility class. + */ + private TemporalQueries() { + } + + //----------------------------------------------------------------------- + /** + * A strict query for the {@code ZoneId}. + */ + static final TemporalQuery ZONE_ID = (temporal) -> { + return temporal.query(ZONE_ID); + }; + + /** + * A query for the {@code Chronology}. + */ + static final TemporalQuery CHRONO = (temporal) -> { + return temporal.query(CHRONO); + }; + + /** + * A query for the smallest supported unit. + */ + static final TemporalQuery PRECISION = (temporal) -> { + return temporal.query(PRECISION); + }; + + //----------------------------------------------------------------------- + /** + * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. + */ + static final TemporalQuery ZONE = (temporal) -> { + ZoneId zone = temporal.query(ZONE_ID); + return (zone != null ? zone : temporal.query(OFFSET)); + }; + + /** + * A query for {@code ZoneOffset} returning null if not found. + */ + static final TemporalQuery OFFSET = (temporal) -> { + if (temporal.isSupported(OFFSET_SECONDS)) { + return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS)); + } + return null; + }; + + /** + * A query for {@code LocalDate} returning null if not found. + */ + static final TemporalQuery LOCAL_DATE = (temporal) -> { + if (temporal.isSupported(EPOCH_DAY)) { + return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY)); + } + return null; + }; + + /** + * A query for {@code LocalTime} returning null if not found. + */ + static final TemporalQuery LOCAL_TIME = (temporal) -> { + if (temporal.isSupported(NANO_OF_DAY)) { + return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY)); + } + return null; + }; + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/java/time/temporal/UnsupportedTemporalTypeException.java 2013-04-11 23:18:19.000000000 -0700 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.temporal; + +import java.time.DateTimeException; + +/** + * UnsupportedTemporalTypeException indicates that a ChronoField or ChronoUnit is + * not supported for a Temporal class. + * + *

    Specification for implementors

    + * This class is intended for use in a single thread. + * + * @since 1.8 + */ +public class UnsupportedTemporalTypeException extends DateTimeException { + + /** + * Serialization version. + */ + private static final long serialVersionUID = -6158898438688206006L; + + /** + * Constructs a new UnsupportedTemporalTypeException with the specified message. + * + * @param message the message to use for this exception, may be null + */ + public UnsupportedTemporalTypeException(String message) { + super(message); + } + + /** + * Constructs a new UnsupportedTemporalTypeException with the specified message and cause. + * + * @param message the message to use for this exception, may be null + * @param cause the cause of the exception, may be null + */ + public UnsupportedTemporalTypeException(String message, Throwable cause) { + super(message, cause); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/JavaTimeSupplementary.java 2013-04-11 23:18:20.000000000 -0700 @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhist Calendar" }, + { "calendarname.gregorian", + "Gregorian Calendar" }, + { "calendarname.gregory", + "Gregorian Calendar" }, + { "calendarname.islamic", + "Islamic Calendar" }, + { "calendarname.islamic-civil", + "Islamic-Civil Calendar" }, + { "calendarname.islamicc", + "Islamic-Civil Calendar" }, + { "calendarname.japanese", + "Japanese Calendar" }, + { "calendarname.roc", + "Minguo Calendar" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "Era" }, + { "field.hour", + "Hour" }, + { "field.minute", + "Minute" }, + { "field.month", + "Month" }, + { "field.second", + "Second" }, + { "field.week", + "Week" }, + { "field.weekday", + "Day of the Week" }, + { "field.year", + "Year" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Shaw.", + "Dhu\u02bbl-Q.", + "Dhu\u02bbl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabi\u02bb I", + "Rabi\u02bb II", + "Jumada I", + "Jumada II", + "Rajab", + "Sha\u02bbban", + "Ramadan", + "Shawwal", + "Dhu\u02bbl-Qi\u02bbdah", + "Dhu\u02bbl-Hijjah", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "AH", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, G y MMMM dd", + "G y MMMM d", + "G y MMM d", + "GGGGG yyyy-MM-dd", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "B.E.", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "G y MMMM d (EEEE)", + "G y MMMM d", + "G y MMM d", + "GGGGGy.MM.dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "", + "Meiji", + "Taisho", + "Showa", + "Heisei", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "", + "Meiji", + "Taisho", + "Showa", + "Heisei", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, G y MMMM dd", + "G y MMMM d", + "G y MMM d", + "GGGGG yyy-MM-dd", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "AD", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, GGGG y MMMM dd", + "GGGG y MMMM d", + "GGGG y MMM d", + "G yyy-MM-dd", + } + }, + { "roc.Eras", + new String[] { + "Before R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "Before R.O.C.", + "R.O.C.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ar/JavaTimeSupplementary_ar.java 2013-04-11 23:18:20.000000000 -0700 @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ar; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ar extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u062b\u0627\u0646\u064a", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u062b\u0627\u0644\u062b", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u0631\u0627\u0628\u0639", + } + }, + { "QuarterNarrows", + new String[] { + "\u0661", + "\u0662", + "\u0663", + "\u0664", + } + }, + { "calendarname.buddhist", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a" }, + { "calendarname.gregorian", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, + { "calendarname.gregory", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, + { "calendarname.islamic", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a" }, + { "calendarname.islamic-civil", + "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, + { "calendarname.islamicc", + "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, + { "calendarname.japanese", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a" }, + { "calendarname.roc", + "\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648" }, + { "field.dayperiod", + "\u0635/\u0645" }, + { "field.era", + "\u0627\u0644\u0639\u0635\u0631" }, + { "field.hour", + "\u0627\u0644\u0633\u0627\u0639\u0627\u062a" }, + { "field.minute", + "\u0627\u0644\u062f\u0642\u0627\u0626\u0642" }, + { "field.month", + "\u0627\u0644\u0634\u0647\u0631" }, + { "field.second", + "\u0627\u0644\u062b\u0648\u0627\u0646\u064a" }, + { "field.week", + "\u0627\u0644\u0623\u0633\u0628\u0648\u0639" }, + { "field.weekday", + "\u0627\u0644\u064a\u0648\u0645" }, + { "field.year", + "\u0627\u0644\u0633\u0646\u0629" }, + { "field.zone", + "\u0627\u0644\u062a\u0648\u0642\u064a\u062a" }, + { "islamic.DatePatterns", + new String[] { + "EEEE\u060c d MMMM y", + "d MMMM y", + "d MMM\u060c y GGGG", + "d\u200f/M\u200f/yyyy", + } + }, + { "islamic.Eras", + new String[] { + "", + "\u0647\u0640", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "\u0645\u062d\u0631\u0645", + "\u0635\u0641\u0631", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", + "\u0631\u062c\u0628", + "\u0634\u0639\u0628\u0627\u0646", + "\u0631\u0645\u0636\u0627\u0646", + "\u0634\u0648\u0627\u0644", + "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", + "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u0645\u062d\u0631\u0645", + "\u0635\u0641\u0631", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", + "\u0631\u062c\u0628", + "\u0634\u0639\u0628\u0627\u0646", + "\u0631\u0645\u0636\u0627\u0646", + "\u0634\u0648\u0627\u0644", + "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", + "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "\u0661", + "\u0662", + "\u0663", + "\u0664", + "\u0665", + "\u0666", + "\u0667", + "\u0668", + "\u0669", + "\u0661\u0660", + "\u0661\u0661", + "\u0661\u0662", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0647\u0640", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE\u060c d MMMM y", + "d MMMM y", + "d MMM\u060c y G", + "d\u200f/M\u200f/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0642\u0628\u0644 \u0627\u0644\u0645\u064a\u0644\u0627\u062f", + "\u0645\u064a\u0644\u0627\u062f\u064a", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0642.\u0645", + "\u0645", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y GGGG", + "d MMMM\u060c y GGGG", + "dd\u200f/MM\u200f/y GGGG", + "d\u200f/M\u200f/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "Before R.O.C.", + "\u062c\u0645\u0647\u0648\u0631\u064a\u0629 \u0627\u0644\u0635\u064a", + } + }, + { "roc.short.Eras", + new String[] { + "Before R.O.C.", + "\u062c\u0645\u0647\u0648\u0631\u064a\u0629 \u0627\u0644\u0635\u064a", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/be/JavaTimeSupplementary_be.java 2013-04-11 23:18:21.000000000 -0700 @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.be; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_be extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1-\u0448\u044b \u043a\u0432.", + "2-\u0433\u0456 \u043a\u0432.", + "3-\u0446\u0456 \u043a\u0432.", + "4-\u0442\u044b \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0448\u044b \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "2-\u0433\u0456 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "3-\u0446\u0456 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "4-\u0442\u044b \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "calendarname.buddhist", + "\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "field.dayperiod", + "\u0414\u041f/\u041f\u041f" }, + { "field.era", + "\u044d\u0440\u0430" }, + { "field.hour", + "\u0433\u0430\u0434\u0437\u0456\u043d\u0430" }, + { "field.minute", + "\u0445\u0432\u0456\u043b\u0456\u043d\u0430" }, + { "field.month", + "\u043c\u0435\u0441\u044f\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0442\u044b\u0434\u0437\u0435\u043d\u044c" }, + { "field.weekday", + "\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f" }, + { "field.year", + "\u0433\u043e\u0434" }, + { "field.zone", + "Zone" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "d.M.yy", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u0430 \u043d.\u0435.", + "\u043d.\u0435.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/bg/JavaTimeSupplementary_bg.java 2013-04-11 23:18:21.000000000 -0700 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.bg; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_bg extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I \u0442\u0440\u0438\u043c.", + "II \u0442\u0440\u0438\u043c.", + "III \u0442\u0440\u0438\u043c.", + "IV \u0442\u0440\u0438\u043c.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0432\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "2-\u0440\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "3-\u0442\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "4-\u0442\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439" }, + { "field.dayperiod", + "\u0434\u0435\u043d" }, + { "field.era", + "\u0435\u0440\u0430" }, + { "field.hour", + "\u0447\u0430\u0441" }, + { "field.minute", + "\u043c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u043c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0441\u0435\u0434\u043c\u0438\u0446\u0430" }, + { "field.weekday", + "\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "islamic.MonthNames", + new String[] { + "\u043c\u0443\u0445\u0430\u0440\u0430\u043c", + "\u0441\u0430\u0444\u0430\u0440", + "\u0440\u0430\u0431\u0438-1", + "\u0440\u0430\u0431\u0438-2", + "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1", + "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2", + "\u0440\u0430\u0434\u0436\u0430\u0431", + "\u0448\u0430\u0431\u0430\u043d", + "\u0440\u0430\u043c\u0430\u0437\u0430\u043d", + "\u0428\u0430\u0432\u0430\u043b", + "\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430", + "\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "\u043f\u0440.\u0425\u0440.", + "\u0441\u043b.\u0425\u0440.", + } + }, + { "java.time.short.Eras", + new String[] { + "\u043f\u0440.\u043d.\u0435.", + "\u043d.\u0435.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ca/JavaTimeSupplementary_ca.java 2013-04-11 23:18:22.000000000 -0700 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ca; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ca extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1T", + "2T", + "3T", + "4T", + } + }, + { "QuarterNames", + new String[] { + "1r trimestre", + "2n trimestre", + "3r trimestre", + "4t trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "calendari budista" }, + { "calendarname.gregorian", + "calendari gregori\u00e0" }, + { "calendarname.gregory", + "calendari gregori\u00e0" }, + { "calendarname.islamic", + "calendari musulm\u00e0" }, + { "calendarname.islamic-civil", + "calendari civil isl\u00e0mic" }, + { "calendarname.islamicc", + "calendari civil isl\u00e0mic" }, + { "calendarname.japanese", + "calendari japon\u00e8s" }, + { "calendarname.roc", + "calendari de la Rep\u00fablica de Xina" }, + { "field.dayperiod", + "a.m./p.m." }, + { "field.era", + "era" }, + { "field.hour", + "hora" }, + { "field.minute", + "minut" }, + { "field.month", + "mes" }, + { "field.second", + "segon" }, + { "field.week", + "setmana" }, + { "field.weekday", + "dia de la setmana" }, + { "field.year", + "any" }, + { "field.zone", + "zona" }, + { "java.time.short.Eras", + new String[] { + "aC", + "dC", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/cs/JavaTimeSupplementary_cs.java 2013-04-11 23:18:22.000000000 -0700 @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.cs; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_cs extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u010dtvrtlet\u00ed", + "2. \u010dtvrtlet\u00ed", + "3. \u010dtvrtlet\u00ed", + "4. \u010dtvrtlet\u00ed", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistick\u00fd kalend\u00e1\u0159" }, + { "calendarname.gregorian", + "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.gregory", + "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamic", + "Muslimsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamic-civil", + "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamicc", + "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, + { "calendarname.japanese", + "Japonsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.roc", + "Kalend\u00e1\u0159 \u010c\u00ednsk\u00e9 republiky" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Letopo\u010det" }, + { "field.hour", + "Hodina" }, + { "field.minute", + "Minuta" }, + { "field.month", + "M\u011bs\u00edc" }, + { "field.second", + "Sekunda" }, + { "field.week", + "T\u00fdden" }, + { "field.weekday", + "Den v t\u00fddnu" }, + { "field.year", + "Rok" }, + { "field.zone", + "\u010casov\u00e9 p\u00e1smo" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "p\u0159. n. l.", + "n. l.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "p\u0159.Kr.", + "po Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. M. y GGGG", + "dd.MM.yy G", + } + }, + { "roc.Eras", + new String[] { + "P\u0159ed R. O. C.", + "", + } + }, + { "roc.short.Eras", + new String[] { + "P\u0159ed R. O. C.", + "", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/da/JavaTimeSupplementary_da.java 2013-04-11 23:18:23.000000000 -0700 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.da; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_da extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamisk kalender" }, + { "calendarname.islamic-civil", + "verdslig islamisk kalender" }, + { "calendarname.islamicc", + "verdslig islamisk kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kalender for Republikken Kina" }, + { "field.dayperiod", + "dagtid" }, + { "field.era", + "\u00e6ra" }, + { "field.hour", + "time" }, + { "field.minute", + "minut" }, + { "field.month", + "m\u00e5ned" }, + { "field.second", + "sekund" }, + { "field.week", + "uge" }, + { "field.weekday", + "ugedag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "tidszone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d/M/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d/M/y G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/de/JavaTimeSupplementary_de.java 2013-04-11 23:18:23.000000000 -0700 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.de; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_de extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. Quartal", + "2. Quartal", + "3. Quartal", + "4. Quartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistischer Kalender" }, + { "calendarname.gregorian", + "Gregorianischer Kalender" }, + { "calendarname.gregory", + "Gregorianischer Kalender" }, + { "calendarname.islamic", + "Islamischer Kalender" }, + { "calendarname.islamic-civil", + "B\u00fcrgerlicher islamischer Kalender" }, + { "calendarname.islamicc", + "B\u00fcrgerlicher islamischer Kalender" }, + { "calendarname.japanese", + "Japanischer Kalender" }, + { "calendarname.roc", + "Kalender der Republik China" }, + { "field.dayperiod", + "Tagesh\u00e4lfte" }, + { "field.era", + "Epoche" }, + { "field.hour", + "Stunde" }, + { "field.minute", + "Minute" }, + { "field.month", + "Monat" }, + { "field.second", + "Sekunde" }, + { "field.week", + "Woche" }, + { "field.weekday", + "Wochentag" }, + { "field.year", + "Jahr" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M.y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M.y G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/el/JavaTimeSupplementary_el.java 2013-04-11 23:18:24.000000000 -0700 @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.el; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_el extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u03a41", + "\u03a42", + "\u03a43", + "\u03a44", + } + }, + { "QuarterNames", + new String[] { + "1\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "2\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "3\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "4\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.gregorian", + "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.gregory", + "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamic", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamic-civil", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamicc", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.japanese", + "\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.roc", + "\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2" }, + { "field.dayperiod", + "\u03c0.\u03bc./\u03bc.\u03bc." }, + { "field.era", + "\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2" }, + { "field.hour", + "\u038f\u03c1\u03b1" }, + { "field.minute", + "\u039b\u03b5\u03c0\u03c4\u03cc" }, + { "field.month", + "\u039c\u03ae\u03bd\u03b1\u03c2" }, + { "field.second", + "\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf" }, + { "field.week", + "\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1" }, + { "field.weekday", + "\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2" }, + { "field.year", + "\u0388\u03c4\u03bf\u03c2" }, + { "field.zone", + "\u0396\u03ce\u03bd\u03b7" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u03c0.\u03a7.", + "\u03bc.\u03a7.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM, y GGGG", + "d/M/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "\u03a0\u03c1\u03b9\u03bd R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "\u03a0\u03c1\u03b9\u03bd R.O.C.", + "R.O.C.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en.java 2013-04-11 23:18:24.000000000 -0700 @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1st quarter", + "2nd quarter", + "3rd quarter", + "4th quarter", + } + }, + { "calendarname.buddhist", + "Buddhist Calendar" }, + { "calendarname.gregorian", + "Gregorian Calendar" }, + { "calendarname.gregory", + "Gregorian Calendar" }, + { "calendarname.islamic", + "Islamic Calendar" }, + { "calendarname.islamic-civil", + "Islamic-Civil Calendar" }, + { "calendarname.islamicc", + "Islamic-Civil Calendar" }, + { "calendarname.japanese", + "Japanese Calendar" }, + { "calendarname.roc", + "Minguo Calendar" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Era" }, + { "field.hour", + "Hour" }, + { "field.minute", + "Minute" }, + { "field.month", + "Month" }, + { "field.second", + "Second" }, + { "field.week", + "Week" }, + { "field.weekday", + "Day of the Week" }, + { "field.year", + "Year" }, + { "field.zone", + "Time Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "Before Christ", + "Anno Domini", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "AD", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_GB.java 2013-04-11 23:18:25.000000000 -0700 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en_GB extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y GGGGG", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd/MM/y G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_SG.java 2013-04-11 23:18:26.000000000 -0700 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en_SG extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM, y GGGG", + "d/M/yy G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/es/JavaTimeSupplementary_es.java 2013-04-11 23:18:26.000000000 -0700 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.es; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_es extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1er trimestre", + "2\u00ba trimestre", + "3er trimestre", + "4\u00ba trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1T", + "2T", + "3T", + "4T", + } + }, + { "calendarname.buddhist", + "calendario budista" }, + { "calendarname.gregorian", + "calendario gregoriano" }, + { "calendarname.gregory", + "calendario gregoriano" }, + { "calendarname.islamic", + "calendario isl\u00e1mico" }, + { "calendarname.islamic-civil", + "calendario civil isl\u00e1mico" }, + { "calendarname.islamicc", + "calendario civil isl\u00e1mico" }, + { "calendarname.japanese", + "calendario japon\u00e9s" }, + { "calendarname.roc", + "calendario de la Rep\u00fablica de China" }, + { "field.dayperiod", + "periodo del d\u00eda" }, + { "field.era", + "era" }, + { "field.hour", + "hora" }, + { "field.minute", + "minuto" }, + { "field.month", + "mes" }, + { "field.second", + "segundo" }, + { "field.week", + "semana" }, + { "field.weekday", + "d\u00eda de la semana" }, + { "field.year", + "a\u00f1o" }, + { "field.zone", + "zona" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/y GGGG", + "dd/MM/y G", + } + }, + { "roc.Eras", + new String[] { + "antes de R.O.C.", + "", + } + }, + { "roc.short.Eras", + new String[] { + "antes de R.O.C.", + "", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/et/JavaTimeSupplementary_et.java 2013-04-11 23:18:27.000000000 -0700 @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.et; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_et extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "budistlik kalender" }, + { "calendarname.gregorian", + "Gregoriuse kalender" }, + { "calendarname.gregory", + "Gregoriuse kalender" }, + { "calendarname.islamic", + "islamikalender" }, + { "calendarname.islamic-civil", + "islami ilmalik kalender" }, + { "calendarname.islamicc", + "islami ilmalik kalender" }, + { "calendarname.japanese", + "Jaapani kalender" }, + { "calendarname.roc", + "Hiina Vabariigi kalender" }, + { "field.dayperiod", + "enne/p\u00e4rast l\u00f5unat" }, + { "field.era", + "ajastu" }, + { "field.hour", + "tund" }, + { "field.minute", + "minut" }, + { "field.month", + "kuu" }, + { "field.second", + "sekund" }, + { "field.week", + "n\u00e4dal" }, + { "field.weekday", + "n\u00e4dalap\u00e4ev" }, + { "field.year", + "aasta" }, + { "field.zone", + "v\u00f6\u00f6nd" }, + { "java.time.long.Eras", + new String[] { + "enne meie aega", + "meie aja j\u00e4rgi", + } + }, + { "java.time.short.Eras", + new String[] { + "e.m.a.", + "m.a.j.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/fi/JavaTimeSupplementary_fi.java 2013-04-11 23:18:27.000000000 -0700 @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.fi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_fi extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1. nelj.", + "2. nelj.", + "3. nelj.", + "4. nelj.", + } + }, + { "QuarterNames", + new String[] { + "1. nelj\u00e4nnes", + "2. nelj\u00e4nnes", + "3. nelj\u00e4nnes", + "4. nelj\u00e4nnes", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhalainen kalenteri" }, + { "calendarname.gregorian", + "gregoriaaninen kalenteri" }, + { "calendarname.gregory", + "gregoriaaninen kalenteri" }, + { "calendarname.islamic", + "islamilainen kalenteri" }, + { "calendarname.islamic-civil", + "islamilainen siviilikalenteri" }, + { "calendarname.islamicc", + "islamilainen siviilikalenteri" }, + { "calendarname.japanese", + "japanilainen kalenteri" }, + { "calendarname.roc", + "Kiinan tasavallan kalenteri" }, + { "field.dayperiod", + "vuorokaudenaika" }, + { "field.era", + "aikakausi" }, + { "field.hour", + "tunti" }, + { "field.minute", + "minuutti" }, + { "field.month", + "kuukausi" }, + { "field.second", + "sekunti" }, + { "field.week", + "viikko" }, + { "field.weekday", + "viikonp\u00e4iv\u00e4" }, + { "field.year", + "vuosi" }, + { "field.zone", + "aikavy\u00f6hyke" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d.M.y GGGG", + "d.M.y GGGG", + } + }, + { "islamic.MonthNames", + new String[] { + "muharram", + "safar", + "rabi\u2019 al-awwal", + "rabi\u2019 al-akhir", + "d\u017eumada-l-ula", + "d\u017eumada-l-akhira", + "rad\u017eab", + "\u0161a\u2019ban", + "ramadan", + "\u0161awwal", + "dhu-l-qa\u2019da", + "dhu-l-hidd\u017ea", + "", + } + }, + { "java.time.DatePatterns", + new String[] { + "cccc, d. MMMM y", + "d. MMMM y", + "d.M.yyyy", + "d.M.yyyy", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.long.Eras", + new String[] { + "ennen Kristuksen syntym\u00e4\u00e4", + "j\u00e4lkeen Kristuksen syntym\u00e4n", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.short.Eras", + new String[] { + "eKr.", + "jKr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d.M.y GGGG", + "d.M.y GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/fr/JavaTimeSupplementary_fr.java 2013-04-11 23:18:28.000000000 -0700 @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.fr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_fr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1er trimestre", + "2e trimestre", + "3e trimestre", + "4e trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "calendarname.buddhist", + "Calendrier bouddhiste" }, + { "calendarname.gregorian", + "Calendrier gr\u00e9gorien" }, + { "calendarname.gregory", + "Calendrier gr\u00e9gorien" }, + { "calendarname.islamic", + "Calendrier musulman" }, + { "calendarname.islamic-civil", + "Calendrier civil musulman" }, + { "calendarname.islamicc", + "Calendrier civil musulman" }, + { "calendarname.japanese", + "Calendrier japonais" }, + { "calendarname.roc", + "Calendrier r\u00e9publicain chinois" }, + { "field.dayperiod", + "cadran" }, + { "field.era", + "\u00e8re" }, + { "field.hour", + "heure" }, + { "field.minute", + "minute" }, + { "field.month", + "mois" }, + { "field.second", + "seconde" }, + { "field.week", + "semaine" }, + { "field.weekday", + "jour de la semaine" }, + { "field.year", + "ann\u00e9e" }, + { "field.zone", + "fuseau horaire" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM, y GGGG", + "d/M/y GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Mouh.", + "Saf.", + "Rabi\u02bb-oul-A.", + "Rabi\u02bb-out-T.", + "Djoum.-l-O.", + "Djoum.-t-T.", + "Radj.", + "Cha.", + "Ram.", + "Chaou.", + "Dou-l-Q.", + "Dou-l-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Mouharram", + "Safar", + "Rabi\u02bb-oul-Aououal", + "Rabi\u02bb-out-Tani", + "Djoumada-l-Oula", + "Djoumada-t-Tania", + "Radjab", + "Cha\u02bbban", + "Ramadan", + "Chaououal", + "Dou-l-Qa\u02bbda", + "Dou-l-Hidjja", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "AH", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "avant J\u00e9sus-Christ", + "apr\u00e8s J\u00e9sus-Christ", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "ap. J.-C.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM, y GGGG", + "d/M/y G", + } + }, + { "roc.Eras", + new String[] { + "avant RdC", + "RdC", + } + }, + { "roc.short.Eras", + new String[] { + "avant RdC", + "RdC", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ga/JavaTimeSupplementary_ga.java 2013-04-11 23:18:28.000000000 -0700 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ga; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ga extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "R1", + "R2", + "R3", + "R4", + } + }, + { "QuarterNames", + new String[] { + "1\u00fa r\u00e1ithe", + "2\u00fa r\u00e1ithe", + "3\u00fa r\u00e1ithe", + "4\u00fa r\u00e1ithe", + } + }, + { "java.time.short.Eras", + new String[] { + "RC", + "AD", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java 2013-04-11 23:18:29.000000000 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hi_IN extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u0924\u093f\u092e\u093e\u0939\u0940", + "\u0926\u0942\u0938\u0930\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + "\u0924\u0940\u0938\u0930\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + "\u091a\u094c\u0925\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.gregorian", + "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.gregory", + "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamic", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamic-civil", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamicc", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.japanese", + "\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.roc", + "\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "field.dayperiod", + "\u0938\u092e\u092f \u0905\u0935\u0927\u093f" }, + { "field.era", + "\u092f\u0941\u0917" }, + { "field.hour", + "\u0918\u0902\u091f\u093e" }, + { "field.minute", + "\u092e\u093f\u0928\u091f" }, + { "field.month", + "\u092e\u093e\u0938" }, + { "field.second", + "\u0938\u0947\u0915\u0947\u0902\u0921" }, + { "field.week", + "\u0938\u092a\u094d\u0924\u093e\u0939" }, + { "field.weekday", + "\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928" }, + { "field.year", + "\u0935\u0930\u094d\u0937" }, + { "field.zone", + "\u0915\u094d\u0937\u0947\u0924\u094d\u0930" }, + { "islamic.MonthNames", + new String[] { + "\u092e\u0941\u0939\u0930\u094d\u0930\u092e", + "\u0938\u092b\u0930", + "\u0930\u093e\u092c\u0940 \u092a\u094d\u0930\u0925\u092e", + "\u0930\u093e\u092c\u0940 \u0926\u094d\u0935\u093f\u0924\u0940\u092f", + "\u091c\u0941\u092e\u094d\u0921\u093e \u092a\u094d\u0930\u0925\u092e", + "\u091c\u0941\u092e\u094d\u0921\u093e \u0926\u094d\u0935\u093f\u0924\u0940\u092f", + "\u0930\u091c\u092c", + "\u0936\u093e\u0935\u0928", + "\u0930\u092e\u091c\u093e\u0928", + "\u0936\u0935\u094d\u0935\u094d\u0932", + "Dhu\u02bbl-Qi\u02bbdah", + "Dhu\u02bbl-Hijjah", + "", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0938\u0928", + "\u092e\u0947\u091c\u0940", + "\u0924\u093e\u0908\u0936\u094b", + "\u0936\u094b\u0935\u093e", + "\u0939\u0947\u0908\u0938\u0947\u0908", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0938\u0928", + "\u092e\u0947\u091c\u0940", + "\u0924\u093e\u0908\u0936\u094b", + "\u0936\u094b\u0935\u093e", + "\u0939\u0947\u0908\u0938\u0947\u0908", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0908\u0938\u093e\u092a\u0942\u0930\u094d\u0935", + "\u0938\u0928", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java 2013-04-11 23:18:29.000000000 -0700 @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1kv", + "2kv", + "3kv", + "4kv", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "budisti\u010dki kalendar" }, + { "calendarname.gregorian", + "gregorijanski kalendar" }, + { "calendarname.gregory", + "gregorijanski kalendar" }, + { "calendarname.islamic", + "islamski kalendar" }, + { "calendarname.islamic-civil", + "islamski civilni kalendar" }, + { "calendarname.islamicc", + "islamski civilni kalendar" }, + { "calendarname.japanese", + "japanski kalendar" }, + { "calendarname.roc", + "kalendar Republike Kine" }, + { "field.dayperiod", + "dio dana" }, + { "field.era", + "era" }, + { "field.hour", + "sat" }, + { "field.minute", + "minuta" }, + { "field.month", + "mjesec" }, + { "field.second", + "sekunda" }, + { "field.week", + "tjedan" }, + { "field.weekday", + "dan u tjednu" }, + { "field.year", + "godina" }, + { "field.zone", + "zona" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y.", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y. G", + } + }, + { "java.time.long.Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y. G", + } + }, + { "java.time.short.Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y. GGGG", + "d. MMMM y. GGGG", + "d. M. y. GGGG", + "d.M.y. GGGG", + } + }, + { "roc.Eras", + new String[] { + "prije R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "prije R.O.C.", + "R.O.C.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/hu/JavaTimeSupplementary_hu.java 2013-04-11 23:18:30.000000000 -0700 @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hu; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hu extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "N1", + "N2", + "N3", + "N4", + } + }, + { "QuarterNames", + new String[] { + "I. negyed\u00e9v", + "II. negyed\u00e9v", + "III. negyed\u00e9v", + "IV. negyed\u00e9v", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhista napt\u00e1r" }, + { "calendarname.gregorian", + "Gergely-napt\u00e1r" }, + { "calendarname.gregory", + "Gergely-napt\u00e1r" }, + { "calendarname.islamic", + "iszl\u00e1m napt\u00e1r" }, + { "calendarname.islamic-civil", + "iszl\u00e1m civil napt\u00e1r" }, + { "calendarname.islamicc", + "iszl\u00e1m civil napt\u00e1r" }, + { "calendarname.japanese", + "jap\u00e1n napt\u00e1r" }, + { "calendarname.roc", + "K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r" }, + { "field.dayperiod", + "napszak" }, + { "field.era", + "\u00e9ra" }, + { "field.hour", + "\u00f3ra" }, + { "field.minute", + "perc" }, + { "field.month", + "h\u00f3nap" }, + { "field.second", + "m\u00e1sodperc" }, + { "field.week", + "h\u00e9t" }, + { "field.weekday", + "h\u00e9t napja" }, + { "field.year", + "\u00e9v" }, + { "field.zone", + "z\u00f3na" }, + { "islamic.DatePatterns", + new String[] { + "y. MMMM d., EEEE", + "y. MMMM d.", + "yyyy.MM.dd.", + "yyyy.MM.dd.", + } + }, + { "islamic.Eras", + new String[] { + "", + "MF", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Shaw.", + "Ds\u00fcl-Q.", + "Ds\u00fcl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Moharrem", + "Safar", + "R\u00e9bi el avvel", + "R\u00e9bi el accher", + "Dsem\u00e1di el avvel", + "Dsem\u00e1di el accher", + "Redseb", + "Sab\u00e1n", + "Ramad\u00e1n", + "Sevv\u00e1l", + "Ds\u00fcl kade", + "Ds\u00fcl hedse", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "MF", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "BK", + } + }, + { "java.time.long.Eras", + new String[] { + "id\u0151sz\u00e1m\u00edt\u00e1sunk el\u0151tt", + "id\u0151sz\u00e1m\u00edt\u00e1sunk szerint", + } + }, + { "java.time.short.Eras", + new String[] { + "i.e.", + "i.u.", + } + }, + { "roc.Eras", + new String[] { + "R.O.C. el\u0151tt", + "", + } + }, + { "roc.short.Eras", + new String[] { + "R.O.C. el\u0151tt", + "", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/is/JavaTimeSupplementary_is.java 2013-04-11 23:18:30.000000000 -0700 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.is; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_is extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "F1", + "F2", + "F3", + "F4", + } + }, + { "QuarterNames", + new String[] { + "1st fj\u00f3r\u00f0ungur", + "2nd fj\u00f3r\u00f0ungur", + "3rd fj\u00f3r\u00f0ungur", + "4th fj\u00f3r\u00f0ungur", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "B\u00fadd\u00edskt dagatal" }, + { "calendarname.gregorian", + "Gregor\u00edskt dagatal" }, + { "calendarname.gregory", + "Gregor\u00edskt dagatal" }, + { "calendarname.islamic", + "\u00cdslamskt dagatal" }, + { "calendarname.islamic-civil", + "\u00cdslamskt borgaradagatal" }, + { "calendarname.islamicc", + "\u00cdslamskt borgaradagatal" }, + { "calendarname.japanese", + "Japanskt dagatal" }, + { "calendarname.roc", + "k\u00ednverskt dagatal" }, + { "field.dayperiod", + "f.h./e.h." }, + { "field.era", + "t\u00edmabil" }, + { "field.hour", + "klukkustund" }, + { "field.minute", + "m\u00edn\u00fata" }, + { "field.month", + "m\u00e1nu\u00f0ur" }, + { "field.second", + "sek\u00fanda" }, + { "field.week", + "vika" }, + { "field.weekday", + "vikudagur" }, + { "field.year", + "\u00e1r" }, + { "field.zone", + "sv\u00e6\u00f0i" }, + { "java.time.short.Eras", + new String[] { + "fyrir Krist", + "eftir Krist", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/it/JavaTimeSupplementary_it.java 2013-04-11 23:18:31.000000000 -0700 @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.it; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_it extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1o trimestre", + "2o trimestre", + "3o trimestre", + "4o trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "calendario buddista" }, + { "calendarname.gregorian", + "calendario gregoriano" }, + { "calendarname.gregory", + "calendario gregoriano" }, + { "calendarname.islamic", + "calendario islamico" }, + { "calendarname.islamic-civil", + "calendario civile islamico" }, + { "calendarname.islamicc", + "calendario civile islamico" }, + { "calendarname.japanese", + "calendario giapponese" }, + { "calendarname.roc", + "Calendario Minguo" }, + { "field.dayperiod", + "periodo del giorno" }, + { "field.era", + "era" }, + { "field.hour", + "ora" }, + { "field.minute", + "minuto" }, + { "field.month", + "mese" }, + { "field.second", + "secondo" }, + { "field.week", + "settimana" }, + { "field.weekday", + "giorno della settimana" }, + { "field.year", + "anno" }, + { "field.zone", + "zona" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "dd MMMM y GGGG", + "dd/MMM/y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "EB", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.long.Eras", + new String[] { + "a.C.", + "d.C", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "dopo Cristo", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "dd MMMM y GGGG", + "dd/MMM/y GGGG", + "dd/MM/y GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw.java 2013-04-11 23:18:31.000000000 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.iw; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_iw extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u05e8\u05d1\u05e2\u05d5\u05df 1", + "\u05e8\u05d1\u05e2\u05d5\u05df 2", + "\u05e8\u05d1\u05e2\u05d5\u05df 3", + "\u05e8\u05d1\u05e2\u05d5\u05df 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, + { "calendarname.gregorian", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.gregory", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.islamic", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, + { "calendarname.islamic-civil", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.islamicc", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.japanese", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, + { "calendarname.roc", + "\u05dc\u05d5\u05d7 \u05d4\u05e9\u05e0\u05d4 \u05d4\u05e1\u05d9\u05e0\u05d9 Minguo" }, + { "field.dayperiod", + "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, + { "field.era", + "\u05ea\u05e7\u05d5\u05e4\u05d4" }, + { "field.hour", + "\u05e9\u05e2\u05d4" }, + { "field.minute", + "\u05d3\u05e7\u05d4" }, + { "field.month", + "\u05d7\u05d5\u05d3\u05e9" }, + { "field.second", + "\u05e9\u05e0\u05d9\u05d9\u05d4" }, + { "field.week", + "\u05e9\u05d1\u05d5\u05e2" }, + { "field.weekday", + "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, + { "field.year", + "\u05e9\u05e0\u05d4" }, + { "field.zone", + "\u05d0\u05d6\u05d5\u05e8" }, + { "islamic.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "islamic.MonthNames", + new String[] { + "\u05de\u05d5\u05d7\u05e8\u05dd", + "\u05e1\u05e4\u05e8", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05e8\u05d2\u05f3\u05d0\u05d1", + "\u05e9\u05e2\u05d1\u05d0\u05df", + "\u05e8\u05d0\u05de\u05d3\u05df", + "\u05e9\u05d5\u05d5\u05d0\u05dc", + "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", + "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "java.time.long.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d9 \u05d4\u05e1\u05e4\u05d9\u05e8\u05d4", + "\u05dc\u05e1\u05e4\u05d9\u05e8\u05d4", + } + }, + { "java.time.short.Eras", + new String[] { + "\u05dc\u05e1\u05d4\"\u05e0", + "\u05dc\u05e4\u05e1\u05d4\"\u05e0", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java 2013-04-11 23:18:32.000000000 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.iw; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_iw_IL extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u05e8\u05d1\u05e2\u05d5\u05df 1", + "\u05e8\u05d1\u05e2\u05d5\u05df 2", + "\u05e8\u05d1\u05e2\u05d5\u05df 3", + "\u05e8\u05d1\u05e2\u05d5\u05df 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, + { "calendarname.gregorian", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.gregory", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.islamic", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, + { "calendarname.islamic-civil", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.islamicc", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.japanese", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, + { "calendarname.roc", + "\u05dc\u05d5\u05d7 \u05d4\u05e9\u05e0\u05d4 \u05d4\u05e1\u05d9\u05e0\u05d9 Minguo" }, + { "field.dayperiod", + "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, + { "field.era", + "\u05ea\u05e7\u05d5\u05e4\u05d4" }, + { "field.hour", + "\u05e9\u05e2\u05d4" }, + { "field.minute", + "\u05d3\u05e7\u05d4" }, + { "field.month", + "\u05d7\u05d5\u05d3\u05e9" }, + { "field.second", + "\u05e9\u05e0\u05d9\u05d9\u05d4" }, + { "field.week", + "\u05e9\u05d1\u05d5\u05e2" }, + { "field.weekday", + "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, + { "field.year", + "\u05e9\u05e0\u05d4" }, + { "field.zone", + "\u05d0\u05d6\u05d5\u05e8" }, + { "islamic.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "islamic.MonthNames", + new String[] { + "\u05de\u05d5\u05d7\u05e8\u05dd", + "\u05e1\u05e4\u05e8", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05e8\u05d2\u05f3\u05d0\u05d1", + "\u05e9\u05e2\u05d1\u05d0\u05df", + "\u05e8\u05d0\u05de\u05d3\u05df", + "\u05e9\u05d5\u05d5\u05d0\u05dc", + "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", + "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "java.time.long.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d9 \u05d4\u05e1\u05e4\u05d9\u05e8\u05d4", + "\u05dc\u05e1\u05e4\u05d9\u05e8\u05d4", + } + }, + { "java.time.short.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d4\u05f4\u05e1", + "\u05dc\u05e1\u05d4\u05f4\u05e0", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java 2013-04-11 23:18:32.000000000 -0700 @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ja; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ja extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u7b2c1\u56db\u534a\u671f", + "\u7b2c2\u56db\u534a\u671f", + "\u7b2c3\u56db\u534a\u671f", + "\u7b2c4\u56db\u534a\u671f", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u30bf\u30a4\u4ecf\u6559\u66a6" }, + { "calendarname.gregorian", + "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, + { "calendarname.gregory", + "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, + { "calendarname.islamic", + "\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.islamic-civil", + "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.islamicc", + "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.japanese", + "\u548c\u66a6" }, + { "calendarname.roc", + "\u4e2d\u83ef\u6c11\u56fd\u66a6" }, + { "field.dayperiod", + "\u5348\u524d/\u5348\u5f8c" }, + { "field.era", + "\u6642\u4ee3" }, + { "field.hour", + "\u6642" }, + { "field.minute", + "\u5206" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2" }, + { "field.week", + "\u9031" }, + { "field.weekday", + "\u66dc\u65e5" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3" }, + { "islamic.MonthAbbreviations", + new String[] { + "\u30e0\u30cf\u30c3\u30e9\u30e0", + "\u30b5\u30d5\u30a2\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30c3\u30fb\u30b5\u30fc\u30cb\u30fc", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30c3\u30b5\u30fc\u30cb\u30fc", + "\u30e9\u30b8\u30e3\u30d6", + "\u30b7\u30e3\u30a2\u30d0\u30fc\u30f3", + "\u30e9\u30de\u30c0\u30fc\u30f3", + "\u30b7\u30e3\u30a6\u30ef\u30fc\u30eb", + "\u30ba\u30eb\u30fb\u30ab\u30a4\u30c0", + "\u30ba\u30eb\u30fb\u30d2\u30c3\u30b8\u30e3", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u30e0\u30cf\u30c3\u30e9\u30e0", + "\u30b5\u30d5\u30a2\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30c3\u30fb\u30b5\u30fc\u30cb\u30fc", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30c3\u30b5\u30fc\u30cb\u30fc", + "\u30e9\u30b8\u30e3\u30d6", + "\u30b7\u30e3\u30a2\u30d0\u30fc\u30f3", + "\u30e9\u30de\u30c0\u30fc\u30f3", + "\u30b7\u30e3\u30a6\u30ef\u30fc\u30eb", + "\u30ba\u30eb\u30fb\u30ab\u30a4\u30c0", + "\u30ba\u30eb\u30fb\u30d2\u30c3\u30b8\u30e3", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "Gy/MM/dd", + "Gy/MM/dd", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u4ecf\u66a6", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u4ecf\u66a6", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy'\u5e74'M'\u6708'd'\u65e5'", + "GGGGGy.MM.dd", + "GGGGGy.MM.dd", + "GGGGGy.MM.dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u897f\u66a6", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u897f\u66a6", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.long.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u897f\u66a6", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/MM/dd", + "Gy/MM/dd", + } + }, + { "java.time.short.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u897f\u66a6", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/MM/dd", + "GGGGy/MM/dd", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ko/JavaTimeSupplementary_ko.java 2013-04-11 23:18:33.000000000 -0700 @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ko; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ko extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1\ubd84\uae30", + "2\ubd84\uae30", + "3\ubd84\uae30", + "4\ubd84\uae30", + } + }, + { "QuarterNames", + new String[] { + "\uc81c 1/4\ubd84\uae30", + "\uc81c 2/4\ubd84\uae30", + "\uc81c 3/4\ubd84\uae30", + "\uc81c 4/4\ubd84\uae30", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\ubd88\uad50\ub825" }, + { "calendarname.gregorian", + "\ud0dc\uc591\ub825" }, + { "calendarname.gregory", + "\ud0dc\uc591\ub825" }, + { "calendarname.islamic", + "\uc774\uc2ac\ub78c\ub825" }, + { "calendarname.islamic-civil", + "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, + { "calendarname.islamicc", + "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, + { "calendarname.japanese", + "\uc77c\ubcf8\ub825" }, + { "calendarname.roc", + "\ub300\ub9cc\ub825" }, + { "field.dayperiod", + "\uc624\uc804/\uc624\ud6c4" }, + { "field.era", + "\uc5f0\ud638" }, + { "field.hour", + "\uc2dc" }, + { "field.minute", + "\ubd84" }, + { "field.month", + "\uc6d4" }, + { "field.second", + "\ucd08" }, + { "field.week", + "\uc8fc" }, + { "field.weekday", + "\uc694\uc77c" }, + { "field.year", + "\ub144" }, + { "field.zone", + "\uc2dc\uac04\ub300" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\ubd88\uae30", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, + { "java.time.long.Eras", + new String[] { + "\uc11c\ub825\uae30\uc6d0\uc804", + "\uc11c\ub825\uae30\uc6d0", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.short.Eras", + new String[] { + "\uae30\uc6d0\uc804", + "\uc11c\uae30", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", + "GGGG y\ub144 M\uc6d4 d\uc77c", + "GGGG y. M. d", + "GGGG y. M. d", + } + }, + { "roc.Eras", + new String[] { + "\uc911\ud654\ubbfc\uad6d\uc804", + "\uc911\ud654\ubbfc\uad6d", + } + }, + { "roc.short.Eras", + new String[] { + "\uc911\ud654\ubbfc\uad6d\uc804", + "\uc911\ud654\ubbfc\uad6d", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java 2013-04-11 23:18:34.000000000 -0700 @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.lt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_lt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I k.", + "II k.", + "III k.", + "IV ketv.", + } + }, + { "QuarterNames", + new String[] { + "I ketvirtis", + "II ketvirtis", + "III ketvirtis", + "IV ketvirtis", + } + }, + { "QuarterNarrows", + new String[] { + "I", + "II", + "3", + "IV", + } + }, + { "calendarname.buddhist", + "Budist\u0173 kalendorius" }, + { "calendarname.gregorian", + "Grigaliaus kalendorius" }, + { "calendarname.gregory", + "Grigaliaus kalendorius" }, + { "calendarname.islamic", + "Islamo kalendorius" }, + { "calendarname.islamic-civil", + "Pilietinis islamo kalendorius" }, + { "calendarname.islamicc", + "Pilietinis islamo kalendorius" }, + { "calendarname.japanese", + "Japon\u0173 kalendorius" }, + { "calendarname.roc", + "Kinijos Respublikos kalendorius" }, + { "field.dayperiod", + "dienos metas" }, + { "field.era", + "era" }, + { "field.hour", + "valanda" }, + { "field.minute", + "minut\u0117" }, + { "field.month", + "m\u0117nuo" }, + { "field.second", + "sekund\u0117" }, + { "field.week", + "savait\u0117" }, + { "field.weekday", + "savait\u0117s diena" }, + { "field.year", + "metai" }, + { "field.zone", + "laiko juosta" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "y G, MMMM d, EEEE", + "G y MMMM d", + "G y MMM d", + "GGGGG yyyy-MM-dd", + } + }, + { "java.time.long.Eras", + new String[] { + "prie\u0161 Krist\u0173", + "po Kristaus", + } + }, + { "java.time.short.Eras", + new String[] { + "pr.Kr.", + "po.Kr.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/lv/JavaTimeSupplementary_lv.java 2013-04-11 23:18:34.000000000 -0700 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.lv; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_lv extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "C1", + "C2", + "C3", + "C4", + } + }, + { "QuarterNames", + new String[] { + "1. ceturksnis", + "2. ceturksnis", + "3. ceturksnis", + "4. ceturksnis", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "budistu kalend\u0101rs" }, + { "calendarname.gregorian", + "Gregora kalend\u0101rs" }, + { "calendarname.gregory", + "Gregora kalend\u0101rs" }, + { "calendarname.islamic", + "isl\u0101ma kalend\u0101rs" }, + { "calendarname.islamic-civil", + "isl\u0101ma pilso\u0146u kalend\u0101rs" }, + { "calendarname.islamicc", + "isl\u0101ma pilso\u0146u kalend\u0101rs" }, + { "calendarname.japanese", + "jap\u0101\u0146u kalend\u0101rs" }, + { "calendarname.roc", + "\u0136\u012bnas Republikas kalend\u0101rs" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "\u0113ra" }, + { "field.hour", + "Stundas" }, + { "field.minute", + "Min\u016btes" }, + { "field.month", + "M\u0113nesis" }, + { "field.second", + "Sekundes" }, + { "field.week", + "Ned\u0113\u013ca" }, + { "field.weekday", + "Ned\u0113\u013cas diena" }, + { "field.year", + "Gads" }, + { "field.zone", + "Josla" }, + { "islamic.MonthNames", + new String[] { + "muharams", + "safars", + "1. rab\u012b", + "2. rab\u012b", + "1. d\u017eum\u0101d\u0101", + "2. d\u017eum\u0101d\u0101", + "rad\u017eabs", + "\u0161abans", + "ramad\u0101ns", + "\u0161auvals", + "du al-kid\u0101", + "du al-hid\u017e\u0101", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "pirms m\u016bsu \u0113ras", + "m\u016bsu \u0113r\u0101", + } + }, + { "java.time.short.Eras", + new String[] { + "pm\u0113", + "m\u0113", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/mk/JavaTimeSupplementary_mk.java 2013-04-11 23:18:35.000000000 -0700 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.mk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_mk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u043f\u0440\u0432\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0432\u0442\u043e\u0440\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0442\u0440\u0435\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0447\u0435\u0442\u0432\u0440\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430" }, + { "field.dayperiod", + "\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435" }, + { "field.era", + "\u0415\u0440\u0430" }, + { "field.hour", + "\u0427\u0430\u0441" }, + { "field.minute", + "\u041c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u041c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u041d\u0435\u0434\u0435\u043b\u0430" }, + { "field.weekday", + "\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "java.time.short.Eras", + new String[] { + "\u043f\u0440.\u043d.\u0435.", + "\u0430\u0435.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ms/JavaTimeSupplementary_ms.java 2013-04-11 23:18:35.000000000 -0700 @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ms; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ms extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Suku 1", + "Suku Ke-2", + "Suku Ke-3", + "Suku Ke-4", + } + }, + { "QuarterNames", + new String[] { + "Suku pertama", + "Suku Ke-2", + "Suku Ke-3", + "Suku Ke-4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Kalendar Buddha" }, + { "calendarname.gregorian", + "Kalendar Gregory" }, + { "calendarname.gregory", + "Kalendar Gregory" }, + { "calendarname.islamic", + "Kalendar Islam" }, + { "calendarname.islamic-civil", + "Kalendar Sivil Islam" }, + { "calendarname.islamicc", + "Kalendar Sivil Islam" }, + { "calendarname.japanese", + "Kalendar Jepun" }, + { "calendarname.roc", + "Kalendar Minguo" }, + { "field.dayperiod", + "PG/PTG" }, + { "field.hour", + "Jam" }, + { "field.minute", + "Minit" }, + { "field.month", + "Bulan" }, + { "field.second", + "Kedua" }, + { "field.week", + "Minggu" }, + { "field.weekday", + "Hari dalam Minggu" }, + { "field.year", + "Tahun" }, + { "field.zone", + "Zon Waktu" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "dd/MM/y GGGG", + "d/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "BCE", + "CE", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "dd/MM/y GGGG", + "d/MM/y GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/mt/JavaTimeSupplementary_mt.java 2013-04-11 23:18:36.000000000 -0700 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.mt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_mt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "calendarname.buddhist", + "Kalendarju Buddist" }, + { "calendarname.gregorian", + "Kalendarju Gregorjan" }, + { "calendarname.gregory", + "Kalendarju Gregorjan" }, + { "calendarname.islamic", + "Kalendarju Islamiku" }, + { "calendarname.islamic-civil", + "Kalendarju Islamiku-\u010aivili" }, + { "calendarname.islamicc", + "Kalendarju Islamiku-\u010aivili" }, + { "calendarname.japanese", + "Kalendarju \u0120appuni\u017c" }, + { "field.era", + "Epoka" }, + { "field.hour", + "Sieg\u0127a" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Xahar" }, + { "field.second", + "Sekonda" }, + { "field.week", + "\u0120img\u0127a" }, + { "field.weekday", + "Jum tal-\u0120img\u0127a" }, + { "field.year", + "Sena" }, + { "field.zone", + "\u017bona" }, + { "java.time.long.Eras", + new String[] { + "Qabel Kristu", + "Wara Kristu", + } + }, + { "java.time.short.Eras", + new String[] { + "QK", + "WK", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java 2013-04-11 23:18:36.000000000 -0700 @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.nl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_nl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1e kwartaal", + "2e kwartaal", + "3e kwartaal", + "4e kwartaal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Boeddhistische kalender" }, + { "calendarname.gregorian", + "Gregoriaanse kalender" }, + { "calendarname.gregory", + "Gregoriaanse kalender" }, + { "calendarname.islamic", + "Islamitische kalender" }, + { "calendarname.islamic-civil", + "Islamitische kalender (cyclisch)" }, + { "calendarname.islamicc", + "Islamitische kalender (cyclisch)" }, + { "calendarname.japanese", + "Japanse kalender" }, + { "calendarname.roc", + "Kalender van de Chinese Republiek" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Tijdperk" }, + { "field.hour", + "Uur" }, + { "field.minute", + "Minuut" }, + { "field.month", + "Maand" }, + { "field.second", + "Seconde" }, + { "field.week", + "week" }, + { "field.weekday", + "Dag van de week" }, + { "field.year", + "Jaar" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd-MM-yy GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "Sa\u02bbna Hizjria", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Moeh.", + "Saf.", + "Rab. I", + "Rab. II", + "Joem. I", + "Joem. II", + "Raj.", + "Sja.", + "Ram.", + "Sjaw.", + "Doe al k.", + "Doe al h.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Moeharram", + "Safar", + "Rabi\u02bba al awal", + "Rabi\u02bba al thani", + "Joemad\u02bbal awal", + "Joemad\u02bbal thani", + "Rajab", + "Sja\u02bbaban", + "Ramadan", + "Sjawal", + "Doe al ka\u02bbaba", + "Doe al hizja", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "Sa\u02bbna Hizjria", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "Voor Christus", + "na Christus", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd-MM-yy G", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java 2013-04-11 23:18:37.000000000 -0700 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.no; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_no extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamsk kalender" }, + { "calendarname.islamic-civil", + "islamsk sivil kalender" }, + { "calendarname.islamicc", + "islamsk sivil kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kalender for Republikken Kina" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "tidsalder" }, + { "field.hour", + "time" }, + { "field.minute", + "minutt" }, + { "field.month", + "m\u00e5ned" }, + { "field.second", + "sekund" }, + { "field.week", + "uke" }, + { "field.weekday", + "ukedag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "sone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.long.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M y GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/pl/JavaTimeSupplementary_pl.java 2013-04-11 23:18:37.000000000 -0700 @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "I kwarta\u0142", + "II kwarta\u0142", + "III kwarta\u0142", + "IV kwarta\u0142", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "kalendarz buddyjski" }, + { "calendarname.gregorian", + "kalendarz gregoria\u0144ski" }, + { "calendarname.gregory", + "kalendarz gregoria\u0144ski" }, + { "calendarname.islamic", + "kalendarz islamski (metoda wzrokowa)" }, + { "calendarname.islamic-civil", + "kalendarz islamski (metoda obliczeniowa)" }, + { "calendarname.islamicc", + "kalendarz islamski (metoda obliczeniowa)" }, + { "calendarname.japanese", + "kalendarz japo\u0144ski" }, + { "calendarname.roc", + "kalendarz Republiki Chi\u0144skiej" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "Era" }, + { "field.hour", + "Godzina" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Miesi\u0105c" }, + { "field.second", + "Sekunda" }, + { "field.week", + "Tydzie\u0144" }, + { "field.weekday", + "Dzie\u0144 tygodnia" }, + { "field.year", + "Rok" }, + { "field.zone", + "Strefa" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "D\u017cu. I", + "D\u017cu. II", + "Ra.", + "Sza.", + "Ram.", + "Szaw.", + "Zu al-k.", + "Zu al-h.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabi I", + "Rabi II", + "D\u017cumada I", + "D\u017cumada II", + "Rad\u017cab", + "Szaban", + "Ramadan", + "Szawwal", + "Zu al-kada", + "Zu al-hid\u017cd\u017ca", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.long.Eras", + new String[] { + "p.n.e.", + "n.e.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.short.Eras", + new String[] { + "p.n.e.", + "n.e.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "roc.Eras", + new String[] { + "Przed ROC", + "ROC", + } + }, + { "roc.short.Eras", + new String[] { + "Przed ROC", + "ROC", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt.java 2013-04-11 23:18:38.000000000 -0700 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1\u00ba trimestre", + "2\u00ba trimestre", + "3\u00ba trimestre", + "4\u00ba trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Calend\u00e1rio Budista" }, + { "calendarname.gregorian", + "Calend\u00e1rio Gregoriano" }, + { "calendarname.gregory", + "Calend\u00e1rio Gregoriano" }, + { "calendarname.islamic", + "Calend\u00e1rio Isl\u00e2mico" }, + { "calendarname.islamic-civil", + "Calend\u00e1rio Civil Isl\u00e2mico" }, + { "calendarname.islamicc", + "Calend\u00e1rio Civil Isl\u00e2mico" }, + { "calendarname.japanese", + "Calend\u00e1rio Japon\u00eas" }, + { "calendarname.roc", + "Calend\u00e1rio da Rep\u00fablica da China" }, + { "field.dayperiod", + "Per\u00edodo do dia" }, + { "field.era", + "Era" }, + { "field.hour", + "Hora" }, + { "field.minute", + "Minuto" }, + { "field.month", + "M\u00eas" }, + { "field.second", + "Segundo" }, + { "field.week", + "Semana" }, + { "field.weekday", + "Dia da semana" }, + { "field.year", + "Ano" }, + { "field.zone", + "Fuso" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/yyyy", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d 'de' MMMM 'de' y G", + "d MMM y G", + "d/M/yy", + } + }, + { "java.time.long.Eras", + new String[] { + "Antes de Cristo", + "Ano do Senhor", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.short.Eras", + new String[] { + "a.C.", + "d.C.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/yyyy", + } + }, + { "roc.Eras", + new String[] { + "Antes de R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "Antes de R.O.C.", + "R.O.C.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java 2013-04-11 23:18:38.000000000 -0700 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pt_PT extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "1.\u00ba trimestre", + "2.\u00ba trimestre", + "3.\u00ba trimestre", + "4.\u00ba trimestre", + } + }, + { "calendarname.islamic-civil", + "Calend\u00e1rio Isl\u00e2mico/Civil" }, + { "calendarname.islamicc", + "Calend\u00e1rio Isl\u00e2mico/Civil" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/y GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ro/JavaTimeSupplementary_ro.java 2013-04-11 23:18:39.000000000 -0700 @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ro; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ro extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "trim. I", + "trim. II", + "trim. III", + "trim. IV", + } + }, + { "QuarterNames", + new String[] { + "trimestrul I", + "trimestrul al II-lea", + "trimestrul al III-lea", + "trimestrul al IV-lea", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "T4", + } + }, + { "calendarname.buddhist", + "calendar budist" }, + { "calendarname.gregorian", + "calendar gregorian" }, + { "calendarname.gregory", + "calendar gregorian" }, + { "calendarname.islamic", + "calendar islamic" }, + { "calendarname.islamic-civil", + "calendar islamic civil" }, + { "calendarname.islamicc", + "calendar islamic civil" }, + { "calendarname.japanese", + "calendar japonez" }, + { "calendarname.roc", + "calendar al Republicii Chineze" }, + { "field.dayperiod", + "perioada zilei" }, + { "field.era", + "er\u0103" }, + { "field.hour", + "or\u0103" }, + { "field.minute", + "minut" }, + { "field.month", + "lun\u0103" }, + { "field.second", + "secund\u0103" }, + { "field.week", + "s\u0103pt\u0103m\u00e2n\u0103" }, + { "field.weekday", + "zi a s\u0103pt\u0103m\u00e2nii" }, + { "field.year", + "an" }, + { "field.zone", + "zon\u0103" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM y G", + "d MMM y G", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "era budist\u0103", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "e.b.", + } + }, + { "java.time.long.Eras", + new String[] { + "\u00eenainte de Hristos", + "dup\u0103 Hristos", + } + }, + { "java.time.short.Eras", + new String[] { + "d.C.", + "\u00ee.d.C.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/ru/JavaTimeSupplementary_ru.java 2013-04-11 23:18:39.000000000 -0700 @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ru; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ru extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1-\u0439 \u043a\u0432.", + "2-\u0439 \u043a\u0432.", + "3-\u0439 \u043a\u0432.", + "4-\u0439 \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "2-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "3-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "4-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.roc", + "\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "field.dayperiod", + "\u0414\u041f/\u041f\u041f" }, + { "field.era", + "\u042d\u0440\u0430" }, + { "field.hour", + "\u0427\u0430\u0441" }, + { "field.minute", + "\u041c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u041c\u0435\u0441\u044f\u0446" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u041d\u0435\u0434\u0435\u043b\u044f" }, + { "field.weekday", + "\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438" }, + { "field.year", + "\u0413\u043e\u0434" }, + { "field.zone", + "\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. GGGG", + "d MMMM y\u00a0'\u0433'. GGGG", + "dd.MM.yyyy GGGG", + "dd.MM.yy GGGG", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", + "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", + "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u043d.\u044d.", + "\u042d\u043f\u043e\u0445\u0430 \u041c\u044d\u0439\u0434\u0437\u0438", + "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e", + "\u0421\u044c\u043e\u0432\u0430", + "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u043d.\u044d.", + "\u042d\u043f\u043e\u0445\u0430 \u041c\u044d\u0439\u0434\u0437\u0438", + "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e", + "\u0421\u044c\u043e\u0432\u0430", + "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0434\u043e \u043d.\u044d.", + "\u043d.\u044d.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u043e \u043d.\u044d.", + "\u043d.\u044d.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. GGGG", + "d MMMM y\u00a0'\u0433'. GGGG", + "dd.MM.yyyy GGGG", + "dd.MM.yy GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sk/JavaTimeSupplementary_sk.java 2013-04-11 23:18:40.000000000 -0700 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u0161tvr\u0165rok", + "2. \u0161tvr\u0165rok", + "3. \u0161tvr\u0165rok", + "4. \u0161tvr\u0165rok", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistick\u00fd kalend\u00e1r" }, + { "calendarname.gregorian", + "Gregori\u00e1nsky kalend\u00e1r" }, + { "calendarname.gregory", + "Gregori\u00e1nsky kalend\u00e1r" }, + { "calendarname.islamic", + "Islamsk\u00fd kalend\u00e1r" }, + { "calendarname.islamic-civil", + "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, + { "calendarname.islamicc", + "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, + { "calendarname.japanese", + "Japonsk\u00fd kalend\u00e1r" }, + { "calendarname.roc", + "Kalend\u00e1r \u010c\u00ednskej republiky" }, + { "field.dayperiod", + "\u010cas\u0165 d\u0148a" }, + { "field.era", + "\u00c9ra" }, + { "field.hour", + "Hodina" }, + { "field.minute", + "Min\u00fata" }, + { "field.month", + "Mesiac" }, + { "field.second", + "Sekunda" }, + { "field.week", + "T\u00fd\u017ede\u0148" }, + { "field.weekday", + "De\u0148 v t\u00fd\u017edni" }, + { "field.year", + "Rok" }, + { "field.zone", + "P\u00e1smo" }, + { "java.time.short.Eras", + new String[] { + "pred n.l.", + "n.l.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sl/JavaTimeSupplementary_sl.java 2013-04-11 23:18:40.000000000 -0700 @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u010detrtletje", + "2. \u010detrtletje", + "3. \u010detrtletje", + "4. \u010detrtletje", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "budisti\u010dni koledar" }, + { "calendarname.gregorian", + "gregorijanski koledar" }, + { "calendarname.gregory", + "gregorijanski koledar" }, + { "calendarname.islamic", + "islamski koledar" }, + { "calendarname.islamic-civil", + "islamski civilni koledar" }, + { "calendarname.islamicc", + "islamski civilni koledar" }, + { "calendarname.japanese", + "japonski koledar" }, + { "calendarname.roc", + "kitajski dr\u017eavni koledar" }, + { "field.dayperiod", + "\u010cas dneva" }, + { "field.era", + "Doba" }, + { "field.hour", + "Ura" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Mesec" }, + { "field.second", + "Sekunda" }, + { "field.week", + "Teden" }, + { "field.weekday", + "Dan v tednu" }, + { "field.year", + "Leto" }, + { "field.zone", + "Obmo\u010dje" }, + { "java.time.long.Eras", + new String[] { + "pred na\u0161im \u0161tetjem", + "na\u0161e \u0161tetje", + } + }, + { "java.time.short.Eras", + new String[] { + "pr.n.\u0161.", + "po Kr.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sq/JavaTimeSupplementary_sq.java 2013-04-11 23:18:41.000000000 -0700 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sq; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sq extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "java.time.short.Eras", + new String[] { + "p.e.r.", + "n.e.r.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr.java 2013-04-11 23:18:41.000000000 -0700 @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u041a1", + "\u041a2", + "\u041a3", + "\u041a4", + } + }, + { "QuarterNames", + new String[] { + "\u041f\u0440\u0432\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0414\u0440\u0443\u0433\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0422\u0440\u0435\u045b\u0435 \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0427\u0435\u0442\u0432\u0440\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435" }, + { "field.dayperiod", + "\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435" }, + { "field.era", + "\u0435\u0440\u0430" }, + { "field.hour", + "\u0447\u0430\u0441" }, + { "field.minute", + "\u043c\u0438\u043d\u0443\u0442" }, + { "field.month", + "\u043c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434" }, + { "field.week", + "\u043d\u0435\u0434\u0435\u0459\u0430" }, + { "field.weekday", + "\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "islamic.Eras", + new String[] { + "", + "\u0410\u0425", + } + }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0440\u0430\u0445\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438\u02bb I", + "\u0420\u0430\u0431\u0438\u02bb II", + "\u0408\u0443\u043c\u0430\u0434\u0430 I", + "\u0408\u0443\u043c\u0430\u0434\u0430 II", + "\u0420\u0430\u0452\u0430\u0431", + "\u0428\u0430\u02bb\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0430\u043b", + "\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430", + "\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0410\u0425", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u0411\u0415", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u043d. \u0435.", + "\u041c\u0435\u0438\u0452\u0438", + "\u0422\u0430\u0438\u0448\u043e", + "\u0428\u043e\u0432\u0430", + "\u0425\u0430\u0438\u0441\u0435\u0438", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u043d. \u0435.", + "\u041c\u0435\u0438\u0452\u0438", + "\u0422\u0430\u0438\u0448\u043e", + "\u0428\u043e\u0432\u0430", + "\u0425\u0430\u0438\u0441\u0435\u0438", + } + }, + { "java.time.long.Eras", + new String[] { + "\u041f\u0440\u0435 \u043d\u043e\u0432\u0435 \u0435\u0440\u0435", + "\u041d\u043e\u0432\u0435 \u0435\u0440\u0435", + } + }, + { "java.time.short.Eras", + new String[] { + "\u043f. \u043d. \u0435.", + "\u043d. \u0435", + } + }, + { "roc.Eras", + new String[] { + "\u041f\u0440\u0435 \u0420\u041a", + "\u0420\u041a", + } + }, + { "roc.short.Eras", + new String[] { + "\u041f\u0440\u0435 \u0420\u041a", + "\u0420\u041a", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java 2013-04-11 23:18:42.000000000 -0700 @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sr_Latn extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "calendarname.buddhist", + "Budisti\u010dki kalendar" }, + { "calendarname.gregorian", + "Gregorijanski kalendar" }, + { "calendarname.gregory", + "Gregorijanski kalendar" }, + { "calendarname.islamic", + "Islamski kalendar" }, + { "calendarname.islamic-civil", + "Islamski civilni kalendar" }, + { "calendarname.islamicc", + "Islamski civilni kalendar" }, + { "calendarname.japanese", + "Japanski kalendar" }, + { "calendarname.roc", + "Kalendar Republike Kine" }, + { "field.dayperiod", + "pre podne/ popodne" }, + { "field.era", + "era" }, + { "field.hour", + "\u010das" }, + { "field.minute", + "minut" }, + { "field.month", + "mesec" }, + { "field.second", + "sekund" }, + { "field.week", + "nedelja" }, + { "field.weekday", + "dan u nedelji" }, + { "field.year", + "godina" }, + { "field.zone", + "zona" }, + { "java.time.long.Eras", + new String[] { + "Pre nove ere", + "Nove ere", + } + }, + { "java.time.short.Eras", + new String[] { + "p. n. e.", + "n. e", + } + }, + { "roc.Eras", + new String[] { + "Pre RK", + "RK", + } + }, + { "roc.short.Eras", + new String[] { + "Pre RK", + "RK", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java 2013-04-11 23:18:42.000000000 -0700 @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sv; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sv extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1:a kvartalet", + "2:a kvartalet", + "3:e kvartalet", + "4:e kvartalet", + } + }, + { "calendarname.buddhist", + "buddistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamisk kalender" }, + { "calendarname.islamic-civil", + "islamisk civil kalender" }, + { "calendarname.islamicc", + "islamisk civil kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kinesiska republikens kalender" }, + { "field.dayperiod", + "fm/em" }, + { "field.era", + "era" }, + { "field.hour", + "timme" }, + { "field.minute", + "minut" }, + { "field.month", + "m\u00e5nad" }, + { "field.second", + "sekund" }, + { "field.week", + "vecka" }, + { "field.weekday", + "veckodag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "tidszon" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "GGGG y-MM-dd", + } + }, + { "islamic.MonthNames", + new String[] { + "muharram", + "safar", + "rabi\u2019 al-awwal", + "rabi\u2019 al-akhir", + "jumada-l-ula", + "jumada-l-akhira", + "rajab", + "sha\u2019ban", + "ramadan", + "shawwal", + "dhu-l-ga\u2019da", + "dhu-l-hijja", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G yyyy-MM-dd", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.long.Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.short.Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "GGGG y-MM-dd", + } + }, + { "roc.Eras", + new String[] { + "f\u00f6re R.K.", + "R.K.", + } + }, + { "roc.short.Eras", + new String[] { + "f\u00f6re R.K.", + "R.K.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/th/JavaTimeSupplementary_th.java 2013-04-11 23:18:43.000000000 -0700 @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.th; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_th extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 1", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 2", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 3", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, + { "calendarname.gregorian", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, + { "calendarname.gregory", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, + { "calendarname.islamic", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21" }, + { "calendarname.islamic-civil", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, + { "calendarname.islamicc", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, + { "calendarname.japanese", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, + { "calendarname.roc", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19" }, + { "field.dayperiod", + "\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19" }, + { "field.era", + "\u0e2a\u0e21\u0e31\u0e22" }, + { "field.hour", + "\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07" }, + { "field.minute", + "\u0e19\u0e32\u0e17\u0e35" }, + { "field.month", + "\u0e40\u0e14\u0e37\u0e2d\u0e19" }, + { "field.second", + "\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35" }, + { "field.week", + "\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, + { "field.weekday", + "\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, + { "field.year", + "\u0e1b\u0e35" }, + { "field.zone", + "\u0e40\u0e02\u0e15" }, + { "islamic.Eras", + new String[] { + "", + "\u0e2e.\u0e28.", + } + }, + { "islamic.MonthNames", + new String[] { + "\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21", + "\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c", + "\u0e23\u0e2d\u0e1a\u0e35 I", + "\u0e23\u0e2d\u0e1a\u0e35 II", + "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I", + "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II", + "\u0e23\u0e2d\u0e08\u0e31\u0e1a", + "\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19", + "\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19", + "\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25", + "\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c", + "\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c", + "", + } + }, + { "islamic.long.Eras", + new String[] { + "", + "\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0e2e.\u0e28.", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM G y", + "d MMMM y", + "d MMM y", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u0e1e\u0e38\u0e17\u0e18\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e01\u0e32\u0e25\u0e17\u0e35\u0e48", + "\u0e1e.\u0e28.", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35G y", + "d MMM G y", + "d/M/yy", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + "\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35G y", + "d MMM G y", + "d/M/yy", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e01\u0e32\u0e25\u0e17\u0e35\u0e48", + "\u0e04.\u0e28.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35GGGG y", + "d MMM GGGG y", + "d/M/yy", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/tr/JavaTimeSupplementary_tr.java 2013-04-11 23:18:43.000000000 -0700 @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.tr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_tr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u00c71", + "\u00c72", + "\u00c73", + "\u00c74", + } + }, + { "QuarterNames", + new String[] { + "1. \u00e7eyrek", + "2. \u00e7eyrek", + "3. \u00e7eyrek", + "4. \u00e7eyrek", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Budist Takvimi" }, + { "calendarname.gregorian", + "Miladi Takvim" }, + { "calendarname.gregory", + "Miladi Takvim" }, + { "calendarname.islamic", + "Hicri Takvim" }, + { "calendarname.islamic-civil", + "Arap Takvimi" }, + { "calendarname.islamicc", + "Arap Takvimi" }, + { "calendarname.japanese", + "Japon Takvimi" }, + { "calendarname.roc", + "\u00c7in Cumhuriyeti Takvimi" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Miladi D\u00f6nem" }, + { "field.hour", + "Saat" }, + { "field.minute", + "Dakika" }, + { "field.month", + "Ay" }, + { "field.second", + "Saniye" }, + { "field.week", + "Hafta" }, + { "field.weekday", + "Haftan\u0131n G\u00fcn\u00fc" }, + { "field.year", + "Y\u0131l" }, + { "field.zone", + "Saat Dilimi" }, + { "islamic.DatePatterns", + new String[] { + "dd MMMM y GGGG EEEE", + "dd MMMM y GGGG", + "dd MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharrem", + "Safer", + "Rebi\u00fclevvel", + "Rebi\u00fclahir", + "Cemaziyelevvel", + "Cemaziyelahir", + "Recep", + "\u015eaban", + "Ramazan", + "\u015eevval", + "Zilkade", + "Zilhicce", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.long.Eras", + new String[] { + "Milattan \u00d6nce", + "Milattan Sonra", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.short.Eras", + new String[] { + "M\u00d6", + "MS", + } + }, + { "roc.DatePatterns", + new String[] { + "dd MMMM y GGGG EEEE", + "dd MMMM y GGGG", + "dd MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/uk/JavaTimeSupplementary_uk.java 2013-04-11 23:18:44.000000000 -0700 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.uk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_uk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I \u043a\u0432.", + "II \u043a\u0432.", + "III \u043a\u0432.", + "IV \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "I \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "II \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "III \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "IV \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439" }, + { "field.dayperiod", + "\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438" }, + { "field.era", + "\u0415\u0440\u0430" }, + { "field.hour", + "\u0413\u043e\u0434\u0438\u043d\u0430" }, + { "field.minute", + "\u0425\u0432\u0438\u043b\u0438\u043d\u0430" }, + { "field.month", + "\u041c\u0456\u0441\u044f\u0446\u044c" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0422\u0438\u0436\u0434\u0435\u043d\u044c" }, + { "field.weekday", + "\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f" }, + { "field.year", + "\u0420\u0456\u043a" }, + { "field.zone", + "\u0417\u043e\u043d\u0430" }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0456 I", + "\u0420\u0430\u0431\u0456 II", + "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I", + "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0414\u0430\u0432\u0432\u0430\u043b", + "\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430", + "\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0434\u043e \u043d\u0430\u0448\u043e\u0457 \u0435\u0440\u0438", + "\u043d\u0430\u0448\u043e\u0457 \u0435\u0440\u0438", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u043e \u043d.\u0435.", + "\u043f\u0456\u0441\u043b\u044f \u043d.\u0435.", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/vi/JavaTimeSupplementary_vi.java 2013-04-11 23:18:44.000000000 -0700 @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.vi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_vi extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "Qu\u00fd 1", + "Qu\u00fd 2", + "Qu\u00fd 3", + "Qu\u00fd 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "L\u1ecbch Ph\u1eadt Gi\u00e1o" }, + { "calendarname.gregorian", + "L\u1ecbch Gregory" }, + { "calendarname.gregory", + "L\u1ecbch Gregory" }, + { "calendarname.islamic", + "L\u1ecbch Islamic" }, + { "calendarname.islamic-civil", + "L\u1ecbch Islamic-Civil" }, + { "calendarname.islamicc", + "L\u1ecbch Islamic-Civil" }, + { "calendarname.japanese", + "L\u1ecbch Nh\u1eadt B\u1ea3n" }, + { "calendarname.roc", + "L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c" }, + { "field.dayperiod", + "SA/CH" }, + { "field.era", + "Th\u1eddi \u0111\u1ea1i" }, + { "field.hour", + "Gi\u1edd" }, + { "field.minute", + "Ph\u00fat" }, + { "field.month", + "Th\u00e1ng" }, + { "field.second", + "Gi\u00e2y" }, + { "field.week", + "Tu\u1ea7n" }, + { "field.weekday", + "Ng\u00e0y trong tu\u1ea7n" }, + { "field.year", + "N\u0103m" }, + { "field.zone", + "M\u00fai gi\u1edd" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", + "dd-MM-y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-yyyy G", + "dd/MM/yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "tr. CN", + "sau CN", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", + "dd-MM-y GGGG", + "dd/MM/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "Tr\u01b0\u1edbc R.O.C", + "", + } + }, + { "roc.short.Eras", + new String[] { + "Tr\u01b0\u1edbc R.O.C", + "", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh.java 2013-04-11 23:18:45.000000000 -0700 @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.zh; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_zh extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1\u5b63", + "2\u5b63", + "3\u5b63", + "4\u5b63", + } + }, + { "QuarterNames", + new String[] { + "\u7b2c1\u5b63\u5ea6", + "\u7b2c2\u5b63\u5ea6", + "\u7b2c3\u5b63\u5ea6", + "\u7b2c4\u5b63\u5ea6", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u4f5b\u6559\u65e5\u5386" }, + { "calendarname.gregorian", + "\u516c\u5386" }, + { "calendarname.gregory", + "\u516c\u5386" }, + { "calendarname.islamic", + "\u4f0a\u65af\u5170\u65e5\u5386" }, + { "calendarname.islamic-civil", + "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, + { "calendarname.islamicc", + "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, + { "calendarname.japanese", + "\u65e5\u672c\u65e5\u5386" }, + { "calendarname.roc", + "\u6c11\u56fd\u65e5\u5386" }, + { "field.dayperiod", + "\u4e0a\u5348/\u4e0b\u5348" }, + { "field.era", + "\u65f6\u671f" }, + { "field.hour", + "\u5c0f\u65f6" }, + { "field.minute", + "\u5206\u949f" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2\u949f" }, + { "field.week", + "\u5468" }, + { "field.weekday", + "\u5468\u5929" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u533a\u57df" }, + { "islamic.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGyy-MM-dd", + } + }, + { "islamic.Eras", + new String[] { + "", + "\u56de\u5386", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u56de\u5386", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gyyyy-M-d", + "Gy-M-d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u4f5b\u5386", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy\u5e74M\u6708d\u65e5", + "Gyy-MM-dd", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy\u5e74M\u6708d\u65e5", + "Gyy-MM-dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy-M-d", + "Gy-M-d", + } + }, + { "java.time.short.Eras", + new String[] { + "\u516c\u5143\u524d", + "\u516c\u5143", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy-M-d", + "GGGGy-M-d", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java 2013-04-11 23:18:45.000000000 -0700 @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.zh; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_zh_TW extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u7b2c1\u5b63", + "\u7b2c2\u5b63", + "\u7b2c3\u5b63", + "\u7b2c4\u5b63", + } + }, + { "calendarname.buddhist", + "\u4f5b\u6559\u66c6\u6cd5" }, + { "calendarname.gregorian", + "\u516c\u66c6" }, + { "calendarname.gregory", + "\u516c\u66c6" }, + { "calendarname.islamic", + "\u4f0a\u65af\u862d\u66c6\u6cd5" }, + { "calendarname.islamic-civil", + "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, + { "calendarname.islamicc", + "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, + { "calendarname.japanese", + "\u65e5\u672c\u66c6\u6cd5" }, + { "calendarname.roc", + "\u6c11\u570b\u66c6" }, + { "field.dayperiod", + "\u4e0a\u5348/\u4e0b\u5348" }, + { "field.era", + "\u5e74\u4ee3" }, + { "field.hour", + "\u5c0f\u6642" }, + { "field.minute", + "\u5206\u9418" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2" }, + { "field.week", + "\u9031" }, + { "field.weekday", + "\u9031\u5929" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u6642\u5340" }, + { "islamic.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, + { "islamic.MonthNames", + new String[] { + "\u7a46\u54c8\u862d\u59c6\u6708", + "\u8272\u6cd5\u723e\u6708", + "\u8cf4\u6bd4\u6708 I", + "\u8cf4\u6bd4\u6708 II", + "\u4e3b\u99ac\u9054\u6708 I", + "\u4e3b\u99ac\u9054\u6708 II", + "\u8cf4\u54f2\u535c\u6708", + "\u820d\u723e\u90a6\u6708", + "\u8cf4\u8cb7\u4e39\u6708", + "\u9583\u74e6\u9b6f\u6708", + "\u90fd\u723e\u5580\u723e\u5fb7\u6708", + "\u90fd\u723e\u9ed1\u54f2\u6708", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u4f5b\u66c6", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u897f\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u897f\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.short.Eras", + new String[] { + "\u897f\u5143\u524d", + "\u897f\u5143", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u570b\u524d", + "\u6c11\u570b", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u570b\u524d", + "\u6c11\u570b", + } + }, + }; + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/classes/sun/util/resources/ParallelListResourceBundle.java 2013-04-11 23:18:46.000000000 -0700 @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.util.resources; + +import java.util.AbstractSet; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicMarkableReference; + +/** + * ParallelListResourceBundle is another variant of ListResourceBundle + * supporting "parallel" contents provided by another resource bundle + * (OpenListResourceBundle). Parallel contents, if any, are added into this + * bundle on demand. + * + * @author Masayoshi Okutsu + */ +public abstract class ParallelListResourceBundle extends ResourceBundle { + private volatile ConcurrentMap lookup; + private volatile Set keyset; + private final AtomicMarkableReference parallelContents + = new AtomicMarkableReference<>(null, false); + + /** + * Sole constructor. (For invocation by subclass constructors, typically + * implicit.) + */ + protected ParallelListResourceBundle() { + } + + /** + * Returns an array in which each item is a pair of objects in an + * Object array. The first element of each pair is the key, which + * must be a String, and the second element is the value + * associated with that key. See the class description for + * details. + * + * @return an array of an Object array representing a key-value pair. + */ + protected abstract Object[][] getContents(); + + /** + * Returns the parent of this resource bundle or null if there's no parent. + * + * @return the parent or null if no parent + */ + ResourceBundle getParent() { + return parent; + } + + /** + * Sets the parallel contents to the data given by rb. If rb is null, this + * bundle will be marked as `complete'. + * + * @param rb an OpenResourceBundle for parallel contents, or null indicating + * there are no parallel contents for this bundle + */ + public void setParallelContents(OpenListResourceBundle rb) { + if (rb == null) { + parallelContents.compareAndSet(null, null, false, true); + } else { + parallelContents.compareAndSet(null, rb.getContents(), false, false); + } + } + + /** + * Returns true if any parallel contents have been set or if this bundle is + * marked as complete. + * + * @return true if any parallel contents have been processed + */ + boolean areParallelContentsComplete() { + // Quick check for `complete' + if (parallelContents.isMarked()) { + return true; + } + boolean[] done = new boolean[1]; + Object[][] data = parallelContents.get(done); + return data != null || done[0]; + } + + @Override + protected Object handleGetObject(String key) { + if (key == null) { + throw new NullPointerException(); + } + + loadLookupTablesIfNecessary(); + return lookup.get(key); + } + + @Override + public Enumeration getKeys() { + return Collections.enumeration(keySet()); + } + + @Override + public boolean containsKey(String key) { + return keySet().contains(key); + } + + @Override + protected Set handleKeySet() { + loadLookupTablesIfNecessary(); + return lookup.keySet(); + } + + @Override + @SuppressWarnings("UnusedAssignment") + public Set keySet() { + Set ks; + while ((ks = keyset) == null) { + ks = new KeySet(handleKeySet(), parent); + synchronized (this) { + if (keyset == null) { + keyset = ks; + } + } + } + return ks; + } + + /** + * Discards any cached keyset value. This method is called from + * LocaleData for re-creating a KeySet. + */ + synchronized void resetKeySet() { + keyset = null; + } + + /** + * Loads the lookup table if they haven't been loaded already. + */ + void loadLookupTablesIfNecessary() { + ConcurrentMap map = lookup; + if (map == null) { + map = new ConcurrentHashMap<>(); + for (Object[] item : getContents()) { + map.put((String) item[0], item[1]); + } + } + + // If there's any parallel contents data, merge the data into map. + Object[][] data = parallelContents.getReference(); + if (data != null) { + for (Object[] item : data) { + map.putIfAbsent((String) item[0], item[1]); + } + parallelContents.set(null, true); + } + if (lookup == null) { + synchronized (this) { + if (lookup == null) { + lookup = map; + } + } + } + } + + /** + * This class implements the Set interface for + * ParallelListResourceBundle methods. + */ + private static class KeySet extends AbstractSet { + private final Set set; + private final ResourceBundle parent; + + private KeySet(Set set, ResourceBundle parent) { + this.set = set; + this.parent = parent; + } + + @Override + public boolean contains(Object o) { + if (set.contains(o)) { + return true; + } + return (parent != null) ? parent.containsKey((String) o) : false; + } + + @Override + public Iterator iterator() { + if (parent == null) { + return set.iterator(); + } + return new Iterator() { + private Iterator itr = set.iterator(); + private boolean usingParent; + + @Override + public boolean hasNext() { + if (itr.hasNext()) { + return true; + } + if (!usingParent) { + Set nextset = new HashSet<>(parent.keySet()); + nextset.removeAll(set); + itr = nextset.iterator(); + usingParent = true; + } + return itr.hasNext(); + } + + @Override + public String next() { + if (hasNext()) { + return itr.next(); + } + throw new NoSuchElementException(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + @Override + public int size() { + if (parent == null) { + return set.size(); + } + Set allset = new HashSet<>(set); + allset.addAll(parent.keySet()); + return allset.size(); + } + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/src/share/lib/hijrah-config-umalqura.properties 2013-04-11 23:18:46.000000000 -0700 @@ -0,0 +1,58 @@ +# +# hijrah-config-umalqura.properties +# +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# +# This properties file defines a Hijrah calendar variant. +# +# Fields: +# +# ::= 'version' '=' +# ::= 'id' '=' +# ::= 'type' '=' +# ::= 'iso-start' '=' +# ::= '=' +# +# version ... (Required) +# +# id ... (Required) +# Identifies the Java Chronology +# +# type ... (Required) +# Identifies the type of calendar in the standard calendar ID scheme +# iso-start ... (Required) +# Specifies the corresponding ISO date to the first Hijrah day +# in the defined range of dates +# +# year ... (Required) +# Number of days for each month of a Hijrah year +# * Each line defines a year. The years must be in the chronological +# order and no gap is allowed. +# * Each line is in the form indicated above. is a Hijrah year and +# nn is the number of days for a month listed in the order of the months. +# * Each year must have 12 months. +# * Each month should be 29 or 30 days long. +# * There must be one or more space characters between the months. +# + +# indicates the version of this definition +version=1.8.0_1 + +# Java chronology ID +id=Hijrah-umalqura + +# Standard calendar type specification +type=islamic-umalqura + +# defines the corresponding ISO date to the earliest Hijrah date +iso-start=2010-12-07 + +# +# the data section; defines the dates with the number of days for each month +# +# Placeholder data until full Umm alQura data can be validated +1432=29 30 30 30 29 30 29 30 29 30 29 29 +1433=30 29 30 30 29 30 30 29 30 29 30 29 +1434=29 30 29 30 29 30 30 29 30 30 29 29 +1435=30 29 30 29 30 29 30 29 30 30 29 30 --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKChronoLocalDate.java 2013-04-11 23:18:47.000000000 -0700 @@ -0,0 +1,482 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAmount; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalUnit; +import java.time.temporal.ValueRange; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test assertions that must be true for all built-in chronologies. + */ +@Test +public class TCKChronoLocalDate { + + //----------------------------------------------------------------------- + // regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendars") + Chronology[][] data_of_calendars() { + return new Chronology[][]{ + {HijrahChronology.INSTANCE}, + {IsoChronology.INSTANCE}, + {JapaneseChronology.INSTANCE}, + {MinguoChronology.INSTANCE}, + {ThaiBuddhistChronology.INSTANCE}}; + } + + @Test(dataProvider="calendars") + public void test_badWithAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalAdjuster adjuster = new FixedAdjuster(date2); + if (chrono != chrono2) { + try { + date.with(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException"); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.with(adjuster); + assertEquals(result, date2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalAmount adjuster = new FixedAdjuster(date2); + if (chrono != chrono2) { + try { + date.plus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException"); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.plus(adjuster); + assertEquals(result, date2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalAmount adjuster = new FixedAdjuster(date2); + if (chrono != chrono2) { + try { + date.minus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException"); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.minus(adjuster); + assertEquals(result, date2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalUnit adjuster = new FixedTemporalUnit(date2); + if (chrono != chrono2) { + try { + date.plus(1, adjuster); + Assert.fail("TemporalUnit.doAdd plus should have thrown a ClassCastException" + date.getClass() + + ", can not be cast to " + date2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.plus(1, adjuster); + assertEquals(result, date2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalUnit adjuster = new FixedTemporalUnit(date2); + if (chrono != chrono2) { + try { + date.minus(1, adjuster); + Assert.fail("TemporalUnit.doAdd minus should have thrown a ClassCastException" + date.getClass() + + ", can not be cast to " + date2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.minus(1, adjuster); + assertEquals(result, date2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badTemporalFieldChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDate date2 = chrono2.date(refDate); + TemporalField adjuster = new FixedTemporalField(date2); + if (chrono != chrono2) { + try { + date.with(adjuster, 1); + Assert.fail("TemporalField doSet should have thrown a ClassCastException" + date.getClass() + + ", can not be cast to " + date2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDate result = date.with(adjuster, 1); + assertEquals(result, date2, "TemporalField doSet failed to replace date"); + } + } + } + + //----------------------------------------------------------------------- + // isBefore, isAfter, isEqual, DATE_COMPARATOR + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_date_comparisons(Chronology chrono) { + List dates = new ArrayList<>(); + + ChronoLocalDate date = chrono.date(LocalDate.of(2013, 1, 1)); + + // Insert dates in order, no duplicates + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + + // Check these dates against the corresponding dates for every calendar + for (Chronology[] clist : data_of_calendars()) { + List> otherDates = new ArrayList<>(); + Chronology chrono2 = clist[0]; + for (ChronoLocalDate d : dates) { + otherDates.add(chrono2.date(d)); + } + + // Now compare the sequence of original dates with the sequence of converted dates + for (int i = 0; i < dates.size(); i++) { + ChronoLocalDate a = dates.get(i); + for (int j = 0; j < otherDates.size(); j++) { + ChronoLocalDate b = otherDates.get(j); + int cmp = ChronoLocalDate.timeLineOrder().compare(a, b); + if (i < j) { + assertTrue(cmp < 0, a + " compare " + b); + assertEquals(a.isBefore(b), true, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " isAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else if (i > j) { + assertTrue(cmp > 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), true, a + " isAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else { + assertTrue(cmp == 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " isAfter " + b); + assertEquals(a.isEqual(b), true, a + " isEqual " + b); + } + } + } + } + } + + //----------------------------------------------------------------------- + // Test Serialization of Calendars + //----------------------------------------------------------------------- + @Test( dataProvider="calendars") + public void test_ChronoSerialization(Chronology chrono) throws Exception { + LocalDate ref = LocalDate.of(2013, 1, 5); + ChronoLocalDate orginal = chrono.date(ref); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(orginal); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + ChronoLocalDate ser = (ChronoLocalDate) in.readObject(); + assertEquals(ser, orginal, "deserialized date is wrong"); + } + + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + ChronoLocalDate test1 = ChronoLocalDate.from(date); + assertEquals(test1, date); + ChronoLocalDate test2 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30))); + assertEquals(test2, date); + ChronoLocalDate test3 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30)).atZone(ZoneOffset.UTC)); + assertEquals(test3, date); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoLocalDate.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoLocalDate.from(null); + } + + //----------------------------------------------------------------------- + /** + * FixedAdjusted returns a fixed Temporal in all adjustments. + * Construct an adjuster with the Temporal that should be returned from adjust. + */ + static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { + private Temporal datetime; + + FixedAdjuster(Temporal datetime) { + this.datetime = datetime; + } + + @Override + public Temporal adjustInto(Temporal ignore) { + return datetime; + } + + @Override + public Temporal addTo(Temporal ignore) { + return datetime; + } + + @Override + public Temporal subtractFrom(Temporal ignore) { + return datetime; + } + + @Override + public long get(TemporalUnit unit) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public List getUnits() { + throw new UnsupportedOperationException("Not supported yet."); + } + } + + /** + * FixedTemporalUnit returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalUnit with the Temporal that should be returned from doAdd. + */ + static class FixedTemporalUnit implements TemporalUnit { + private Temporal temporal; + + FixedTemporalUnit(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalUnit"; + } + + @Override + public Duration getDuration() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isDurationEstimated() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(Temporal temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R addTo(R temporal, long amount) { + return (R) this.temporal; + } + + @Override + public long between(Temporal temporal1, Temporal temporal2) { + throw new UnsupportedOperationException("Not supported yet."); + } + } + + /** + * FixedTemporalField returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalField with the Temporal that should be returned from doSet. + */ + static class FixedTemporalField implements TemporalField { + private Temporal temporal; + FixedTemporalField(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalField"; + } + + @Override + public TemporalUnit getBaseUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TemporalUnit getRangeUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange range() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange rangeRefinedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getFrom(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R adjustInto(R temporal, long newValue) { + return (R) this.temporal; + } + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java 2013-04-11 23:18:47.000000000 -0700 @@ -0,0 +1,496 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.chrono.ChronoLocalDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAmount; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalUnit; +import java.time.temporal.ValueRange; +import java.util.ArrayList; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test assertions that must be true for all built-in chronologies. + */ +@Test +public class TCKChronoLocalDateTime { + + //----------------------------------------------------------------------- + // regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendars") + Chronology[][] data_of_calendars() { + return new Chronology[][]{ + {HijrahChronology.INSTANCE}, + {IsoChronology.INSTANCE}, + {JapaneseChronology.INSTANCE}, + {MinguoChronology.INSTANCE}, + {ThaiBuddhistChronology.INSTANCE}}; + } + + @Test(dataProvider="calendars") + public void test_badWithAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalAdjuster adjuster = new FixedAdjuster(cdt2); + if (chrono != chrono2) { + try { + cdt.with(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + cdt + ", supplied: " + cdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.with(adjuster); + assertEquals(result, cdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalAmount adjuster = new FixedAdjuster(cdt2); + if (chrono != chrono2) { + try { + cdt.plus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + cdt + ", supplied: " + cdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.plus(adjuster); + assertEquals(result, cdt2, "WithAdjuster failed to replace date time"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalAmount adjuster = new FixedAdjuster(cdt2); + if (chrono != chrono2) { + try { + cdt.minus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + cdt + ", supplied: " + cdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.minus(adjuster); + assertEquals(result, cdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalUnit adjuster = new FixedTemporalUnit(cdt2); + if (chrono != chrono2) { + try { + cdt.plus(1, adjuster); + Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt + + ", can not be cast to " + cdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.plus(1, adjuster); + assertEquals(result, cdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalUnit adjuster = new FixedTemporalUnit(cdt2); + if (chrono != chrono2) { + try { + cdt.minus(1, adjuster); + Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + cdt.getClass() + + ", can not be cast to " + cdt2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.minus(1, adjuster); + assertEquals(result, cdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badTemporalFieldChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); + TemporalField adjuster = new FixedTemporalField(cdt2); + if (chrono != chrono2) { + try { + cdt.with(adjuster, 1); + Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + + ", can not be cast to " + cdt2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoLocalDateTime result = cdt.with(adjuster, 1); + assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); + } + } + } + + //----------------------------------------------------------------------- + // isBefore, isAfter, isEqual + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_datetime_comparisons(Chronology chrono) { + List> dates = new ArrayList<>(); + + ChronoLocalDateTime date = chrono.date(LocalDate.of(2013, 1, 1)).atTime(LocalTime.MIN); + + // Insert dates in order, no duplicates + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date.minus(1, ChronoUnit.HOURS)); + dates.add(date.minus(1, ChronoUnit.MINUTES)); + dates.add(date.minus(1, ChronoUnit.SECONDS)); + dates.add(date.minus(1, ChronoUnit.NANOS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.NANOS)); + dates.add(date.plus(1, ChronoUnit.SECONDS)); + dates.add(date.plus(1, ChronoUnit.MINUTES)); + dates.add(date.plus(1, ChronoUnit.HOURS)); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + + // Check these dates against the corresponding dates for every calendar + for (Chronology[] clist : data_of_calendars()) { + List> otherDates = new ArrayList<>(); + Chronology chrono2 = clist[0]; + for (ChronoLocalDateTime d : dates) { + otherDates.add(chrono2.date(d).atTime(d.toLocalTime())); + } + + // Now compare the sequence of original dates with the sequence of converted dates + for (int i = 0; i < dates.size(); i++) { + ChronoLocalDateTime a = dates.get(i); + for (int j = 0; j < otherDates.size(); j++) { + ChronoLocalDateTime b = otherDates.get(j); + int cmp = ChronoLocalDateTime.timeLineOrder().compare(a, b); + if (i < j) { + assertTrue(cmp < 0, a + " compare " + b); + assertEquals(a.isBefore(b), true, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " isAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else if (i > j) { + assertTrue(cmp > 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), true, a + " isAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else { + assertTrue(cmp == 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " isAfter " + b); + assertEquals(a.isEqual(b), true, a + " isEqual " + b); + } + } + } + } + } + + //----------------------------------------------------------------------- + // Test Serialization of ISO via chrono API + //----------------------------------------------------------------------- + @Test( dataProvider="calendars") + public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception { + LocalDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3); + ChronoLocalDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(orginal); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + ChronoLocalDateTime ser = (ChronoLocalDateTime) in.readObject(); + assertEquals(ser, orginal, "deserialized date is wrong"); + } + + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + LocalDateTime refDateTime = LocalDateTime.of(2013, 1, 1, 12, 30); + ChronoLocalDateTime dateTime = chrono.localDateTime(refDateTime); + ChronoLocalDateTime test1 = ChronoLocalDateTime.from(dateTime); + assertEquals(test1, dateTime); + ChronoLocalDateTime test2 = ChronoLocalDateTime.from(dateTime.atZone(ZoneOffset.UTC)); + assertEquals(test2, dateTime); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_dateOnly() { + ChronoLocalDateTime.from(LocalDate.of(2013, 1, 1)); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoLocalDateTime.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoLocalDateTime.from(null); + } + + //----------------------------------------------------------------------- + /** + * FixedAdjusted returns a fixed Temporal in all adjustments. + * Construct an adjuster with the Temporal that should be returned from adjust. + */ + static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { + private Temporal datetime; + + FixedAdjuster(Temporal datetime) { + this.datetime = datetime; + } + + @Override + public Temporal adjustInto(Temporal ignore) { + return datetime; + } + + @Override + public Temporal addTo(Temporal ignore) { + return datetime; + } + + @Override + public Temporal subtractFrom(Temporal ignore) { + return datetime; + } + + @Override + public long get(TemporalUnit unit) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public List getUnits() { + throw new UnsupportedOperationException("Not supported yet."); + } + + } + + /** + * FixedTemporalUnit returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. + */ + static class FixedTemporalUnit implements TemporalUnit { + private Temporal temporal; + + FixedTemporalUnit(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalUnit"; + } + + @Override + public Duration getDuration() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isDurationEstimated() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(Temporal temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R addTo(R temporal, long amount) { + return (R) this.temporal; + } + + @Override + public long between(Temporal temporal1, Temporal temporal2) { + throw new UnsupportedOperationException("Not supported yet."); + } + } + + /** + * FixedTemporalField returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. + */ + static class FixedTemporalField implements TemporalField { + private Temporal temporal; + FixedTemporalField(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalField"; + } + + @Override + public TemporalUnit getBaseUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TemporalUnit getRangeUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange range() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange rangeRefinedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getFrom(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R adjustInto(R temporal, long newValue) { + return (R) this.temporal; + } + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java 2013-04-11 23:18:48.000000000 -0700 @@ -0,0 +1,498 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAmount; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalUnit; +import java.time.temporal.ValueRange; +import java.util.ArrayList; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test assertions that must be true for all built-in chronologies. + */ +@Test +public class TCKChronoZonedDateTime { + + //----------------------------------------------------------------------- + // regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendars") + Chronology[][] data_of_calendars() { + return new Chronology[][]{ + {HijrahChronology.INSTANCE}, + {IsoChronology.INSTANCE}, + {JapaneseChronology.INSTANCE}, + {MinguoChronology.INSTANCE}, + {ThaiBuddhistChronology.INSTANCE}, + }; + } + + @Test(dataProvider="calendars") + public void test_badWithAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalAdjuster adjuster = new FixedAdjuster(czdt2); + if (chrono != chrono2) { + try { + czdt.with(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + czdt + ", supplied: " + czdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + ChronoZonedDateTime result = czdt.with(adjuster); + assertEquals(result, czdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalAmount adjuster = new FixedAdjuster(czdt2); + if (chrono != chrono2) { + try { + czdt.plus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + czdt + ", supplied: " + czdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoZonedDateTime result = czdt.plus(adjuster); + assertEquals(result, czdt2, "WithAdjuster failed to replace date time"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusAdjusterChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalAmount adjuster = new FixedAdjuster(czdt2); + if (chrono != chrono2) { + try { + czdt.minus(adjuster); + Assert.fail("WithAdjuster should have thrown a ClassCastException, " + + "required: " + czdt + ", supplied: " + czdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoZonedDateTime result = czdt.minus(adjuster); + assertEquals(result, czdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badPlusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalUnit adjuster = new FixedTemporalUnit(czdt2); + if (chrono != chrono2) { + try { + czdt.plus(1, adjuster); + Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException, " + czdt + + " can not be cast to " + czdt2); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoZonedDateTime result = czdt.plus(1, adjuster); + assertEquals(result, czdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badMinusTemporalUnitChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalUnit adjuster = new FixedTemporalUnit(czdt2); + if (chrono != chrono2) { + try { + czdt.minus(1, adjuster); + Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException, " + czdt.getClass() + + " can not be cast to " + czdt2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoZonedDateTime result = czdt.minus(1, adjuster); + assertEquals(result, czdt2, "WithAdjuster failed to replace date"); + } + } + } + + @Test(dataProvider="calendars") + public void test_badTemporalFieldChrono(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + for (Chronology[] clist : data_of_calendars()) { + Chronology chrono2 = clist[0]; + ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); + TemporalField adjuster = new FixedTemporalField(czdt2); + if (chrono != chrono2) { + try { + czdt.with(adjuster, 1); + Assert.fail("TemporalField doWith() should have thrown a ClassCastException, " + czdt.getClass() + + " can not be cast to " + czdt2.getClass()); + } catch (ClassCastException cce) { + // Expected exception; not an error + } + } else { + // Same chronology, + ChronoZonedDateTime result = czdt.with(adjuster, 1); + assertEquals(result, czdt2, "TemporalField doWith() failed to replace date"); + } + } + } + + //----------------------------------------------------------------------- + // isBefore, isAfter, isEqual, INSTANT_COMPARATOR test a Chronology against the other Chronos + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_zonedDateTime_comparisons(Chronology chrono) { + List> dates = new ArrayList<>(); + + ChronoZonedDateTime date = chrono.date(LocalDate.of(2013, 1, 1)) + .atTime(LocalTime.MIN) + .atZone(ZoneOffset.UTC); + + // Insert dates in order, no duplicates + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date.minus(1, ChronoUnit.HOURS)); + dates.add(date.minus(1, ChronoUnit.MINUTES)); + dates.add(date.minus(1, ChronoUnit.SECONDS)); + dates.add(date.minus(1, ChronoUnit.NANOS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.NANOS)); + dates.add(date.plus(1, ChronoUnit.SECONDS)); + dates.add(date.plus(1, ChronoUnit.MINUTES)); + dates.add(date.plus(1, ChronoUnit.HOURS)); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + + // Check these dates against the corresponding dates for every calendar + for (Chronology[] clist : data_of_calendars()) { + List> otherDates = new ArrayList<>(); + Chronology chrono2 = IsoChronology.INSTANCE; //clist[0]; + for (ChronoZonedDateTime d : dates) { + otherDates.add(chrono2.date(d).atTime(d.toLocalTime()).atZone(d.getZone())); + } + + // Now compare the sequence of original dates with the sequence of converted dates + for (int i = 0; i < dates.size(); i++) { + ChronoZonedDateTime a = dates.get(i); + for (int j = 0; j < otherDates.size(); j++) { + ChronoZonedDateTime b = otherDates.get(j); + int cmp = ChronoZonedDateTime.timeLineOrder().compare(a, b); + if (i < j) { + assertTrue(cmp < 0, a + " compare " + b); + assertEquals(a.isBefore(b), true, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " ifAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else if (i > j) { + assertTrue(cmp > 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), true, a + " ifAfter " + b); + assertEquals(a.isEqual(b), false, a + " isEqual " + b); + } else { + assertTrue(cmp == 0, a + " compare " + b); + assertEquals(a.isBefore(b), false, a + " isBefore " + b); + assertEquals(a.isAfter(b), false, a + " ifAfter " + b); + assertEquals(a.isEqual(b), true, a + " isEqual " + b); + } + } + } + } + } + + //----------------------------------------------------------------------- + // Test Serialization of ISO via chrono API + //----------------------------------------------------------------------- + @Test( dataProvider="calendars") + public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception { + ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23")); + ChronoZonedDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone()); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(orginal); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + ChronoZonedDateTime ser = (ChronoZonedDateTime) in.readObject(); + assertEquals(ser, orginal, "deserialized date is wrong"); + } + + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + ZonedDateTime refDateTime = ZonedDateTime.of(2013, 1, 1, 12, 30, 0, 0, ZoneId.of("Europe/Paris")); + ChronoZonedDateTime dateTime = chrono.zonedDateTime(refDateTime); + ChronoZonedDateTime test1 = ChronoZonedDateTime.from(dateTime); + assertEquals(test1, dateTime); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_dateOnly() { + ChronoZonedDateTime.from(LocalDate.of(2013, 1, 1)); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoZonedDateTime.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoZonedDateTime.from(null); + } + + //----------------------------------------------------------------------- + /** + * FixedAdjusted returns a fixed Temporal in all adjustments. + * Construct an adjuster with the Temporal that should be returned from adjust. + */ + static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { + private Temporal datetime; + + FixedAdjuster(Temporal datetime) { + this.datetime = datetime; + } + + @Override + public Temporal adjustInto(Temporal ignore) { + return datetime; + } + + @Override + public Temporal addTo(Temporal ignore) { + return datetime; + } + + @Override + public Temporal subtractFrom(Temporal ignore) { + return datetime; + } + + @Override + public long get(TemporalUnit unit) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public List getUnits() { + throw new UnsupportedOperationException("Not supported yet."); + } + + } + + /** + * FixedTemporalUnit returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. + */ + static class FixedTemporalUnit implements TemporalUnit { + private Temporal temporal; + + FixedTemporalUnit(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalUnit"; + } + + @Override + public Duration getDuration() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isDurationEstimated() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(Temporal temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R addTo(R temporal, long amount) { + return (R) this.temporal; + } + + @Override + public long between(Temporal temporal1, Temporal temporal2) { + throw new UnsupportedOperationException("Not supported yet."); + } + } + + /** + * FixedTemporalField returns a fixed Temporal in all adjustments. + * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. + */ + static class FixedTemporalField implements TemporalField { + private Temporal temporal; + FixedTemporalField(Temporal temporal) { + this.temporal = temporal; + } + + @Override + public String getName() { + return "FixedTemporalField"; + } + + @Override + public TemporalUnit getBaseUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TemporalUnit getRangeUnit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange range() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isSupportedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ValueRange rangeRefinedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getFrom(TemporalAccessor temporal) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @SuppressWarnings("unchecked") + @Override + public R adjustInto(R temporal, long newValue) { + return (R) this.temporal; + } + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKChronologySerialization.java 2013-04-11 23:18:48.000000000 -0700 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintStream; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +public class TCKChronologySerialization { + + //----------------------------------------------------------------------- + // regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendars") + Chronology[][] data_of_calendars() { + return new Chronology[][]{ + {HijrahChronology.INSTANCE}, + {IsoChronology.INSTANCE}, + {JapaneseChronology.INSTANCE}, + {MinguoChronology.INSTANCE}, + {ThaiBuddhistChronology.INSTANCE}}; + } + + //----------------------------------------------------------------------- + // Test Serialization of Calendars + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_ChronoSerialization(Chronology chrono) throws Exception { + System.out.printf(" ChronoSerialization: %s%n", chrono); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(chrono); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, chrono, "deserialized Chronology is wrong"); + } + + /** + * Utility method to dump a byte array in a java syntax. + * @param bytes and array of bytes + * @param os the outputstream to receive the output. + */ + static void dumpSerialStream(byte[] bytes, PrintStream os) { + os.printf(" byte[] bytes = {" ); + final int linelen = 10; + for (int i = 0; i < bytes.length; i++) { + if (i % linelen == 0) { + os.printf("%n "); + } + os.printf(" %3d,", bytes[i] & 0xff); + if ((i % linelen) == (linelen-1) || i == bytes.length - 1) { + os.printf(" /*"); + int s = i / linelen * linelen; + int k = i % linelen; + for (int j = 0; j <= k && s + j < bytes.length; j++) { + os.printf(" %c", bytes[s + j] & 0xff); + } + os.printf(" */"); + } + } + os.printf("%n };%n"); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKHijrahChronology.java 2013-04-11 23:18:49.000000000 -0700 @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.Period; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahDate; +import java.time.chrono.IsoChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKHijrahChronology { + + //----------------------------------------------------------------------- + // Chronology.ofName("Hijrah") Lookup by name + //----------------------------------------------------------------------- + @Test + public void test_chrono_byName() { + Chronology c = HijrahChronology.INSTANCE; + Chronology test = Chronology.of("Hijrah-umalqura"); + Assert.assertNotNull(test, "The Hijrah-umalqura calendar could not be found by name"); + Assert.assertEquals(test.getId(), "Hijrah-umalqura", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "islamic-umalqura", "Type mismatch"); + Assert.assertEquals(test, c); + } + + //----------------------------------------------------------------------- + // creation, toLocalDate() + //----------------------------------------------------------------------- + @DataProvider(name="samples") + Object[][] data_samples() { + return new Object[][] { + //{HijrahChronology.INSTANCE.date(1320, 1, 1), LocalDate.of(1902, 4, 9)}, + //{HijrahChronology.INSTANCE.date(1320, 1, 2), LocalDate.of(1902, 4, 10)}, + //{HijrahChronology.INSTANCE.date(1320, 1, 3), LocalDate.of(1902, 4, 11)}, + + //{HijrahChronology.INSTANCE.date(1322, 1, 1), LocalDate.of(1904, 3, 18)}, + //{HijrahChronology.INSTANCE.date(1323, 1, 1), LocalDate.of(1905, 3, 7)}, + //{HijrahChronology.INSTANCE.date(1323, 12, 6), LocalDate.of(1906, 1, 30)}, + //{HijrahChronology.INSTANCE.date(1324, 1, 1), LocalDate.of(1906, 2, 24)}, + //{HijrahChronology.INSTANCE.date(1324, 7, 3), LocalDate.of(1906, 8, 23)}, + //{HijrahChronology.INSTANCE.date(1324, 7, 4), LocalDate.of(1906, 8, 24)}, + //{HijrahChronology.INSTANCE.date(1325, 1, 1), LocalDate.of(1907, 2, 13)}, + {HijrahChronology.INSTANCE.date(1434, 7, 1), LocalDate.of(2013, 5, 11)}, + + //{HijrahChronology.INSTANCE.date(1500, 3, 3), LocalDate.of(2079, 1, 5)}, + //{HijrahChronology.INSTANCE.date(1500, 10, 28), LocalDate.of(2079, 8, 25)}, + //{HijrahChronology.INSTANCE.date(1500, 10, 29), LocalDate.of(2079, 8, 26)}, + }; + } + + @Test(dataProvider="samples") + public void test_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { + assertEquals(LocalDate.from(hijrahDate), iso); + } + + @Test(dataProvider="samples") + public void test_fromCalendrical(ChronoLocalDate hijrahDate, LocalDate iso) { + assertEquals(HijrahChronology.INSTANCE.date(iso), hijrahDate); + } + + @Test(dataProvider="samples") + public void test_dayOfWeekEqualIsoDayOfWeek(ChronoLocalDate hijrahDate, LocalDate iso) { + assertEquals(hijrahDate.get(DAY_OF_WEEK), iso.get(DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1434, 0, 0}, + + {1434, -1, 1}, + {1434, 0, 1}, + {1434, 14, 1}, + {1434, 15, 1}, + + {1434, 1, -1}, + {1434, 1, 0}, + {1434, 1, 32}, + + {1434, 12, -1}, + {1434, 12, 0}, + {1434, 12, 32}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + HijrahChronology.INSTANCE.date(year, month, dom); + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof HijrahChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = HijrahChronology.INSTANCE.date(era, 1, 1, 1); + fail("HijrahChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* TODO: Test for missing HijrahDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + HijrahDate jdate = HijrahDate.of(era, 1, 1, 1); + fail("HijrahDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = HijrahChronology.INSTANCE.prolepticYear(era, 1); + fail("HijrahChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + } + } + } + + //----------------------------------------------------------------------- + // with(WithAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + ChronoLocalDate base = HijrahChronology.INSTANCE.date(1434, 5, 15); + ChronoLocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, HijrahChronology.INSTANCE.date(1434, 5, 29)); + } + + @Test + public void test_adjust2() { + ChronoLocalDate base = HijrahChronology.INSTANCE.date(1434, 6, 2); + ChronoLocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, HijrahChronology.INSTANCE.date(1434, 6, 30)); + } + + //----------------------------------------------------------------------- + // HijrahDate.with(Local*) + //----------------------------------------------------------------------- + @Test + public void test_adjust_toLocalDate() { + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 1, 4); + ChronoLocalDate test = hijrahDate.with(LocalDate.of(2012, 7, 6)); + assertEquals(test, HijrahChronology.INSTANCE.date(1433, 8, 16)); + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_adjust_toMonth() { + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 1, 4); + hijrahDate.with(Month.APRIL); + } + + //----------------------------------------------------------------------- + // LocalDate.with(HijrahDate) + //----------------------------------------------------------------------- + @Test + public void test_LocalDate_adjustToHijrahDate() { + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1434, 5, 15); + LocalDate test = LocalDate.MIN.with(hijrahDate); + assertEquals(test, LocalDate.of(2013, 3, 27)); + } + + @Test + public void test_LocalDateTime_adjustToHijrahDate() { + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 5, 15); + LocalDateTime test = LocalDateTime.MIN.with(hijrahDate); + assertEquals(test, LocalDateTime.of(2014, 3, 16, 0, 0)); + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + //----------------------------------------------------------------------- + // toString() + //----------------------------------------------------------------------- + @DataProvider(name="toString") + Object[][] data_toString() { + return new Object[][] { + //{HijrahChronology.INSTANCE.date(1320, 1, 1), "Hijrah AH 1320-01-01"}, + //{HijrahChronology.INSTANCE.date(1500, 10, 28), "Hijrah AH 1500-10-28"}, + //{HijrahChronology.INSTANCE.date(1500, 10, 29), "Hijrah AH 1500-10-29"}, + {HijrahChronology.INSTANCE.date(1434, 12, 5), "Hijrah-umalqura AH 1434-12-05"}, + {HijrahChronology.INSTANCE.date(1434, 12, 6), "Hijrah-umalqura AH 1434-12-06"}, + }; + } + + @Test(dataProvider="toString") + public void test_toString(ChronoLocalDate hijrahDate, String expected) { + assertEquals(hijrahDate.toString(), expected); + } + + //----------------------------------------------------------------------- + // equals() + //----------------------------------------------------------------------- + @Test + public void test_equals_true() { + assertTrue(HijrahChronology.INSTANCE.equals(HijrahChronology.INSTANCE)); + } + + @Test + public void test_equals_false() { + assertFalse(HijrahChronology.INSTANCE.equals(IsoChronology.INSTANCE)); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKHijrahEra.java 2013-04-11 23:18:50.000000000 -0700 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKHijrahEra { + + @DataProvider(name = "HijrahEras") + Object[][] data_of_eras() { + return new Object[][] { + {HijrahEra.AH, "AH", 1}, + }; + } + + @Test(dataProvider="HijrahEras") + public void test_valueOf(HijrahEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(HijrahEra.of(eraValue), era); + assertEquals(HijrahEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = HijrahChronology.INSTANCE.eras(); + HijrahEra[] eras = HijrahEra.values(); + assertEquals(eraList.size(), eras.length); + for (HijrahEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (HijrahEra era : HijrahEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(1, 1)); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKIsoChronology.java 2013-04-11 23:18:50.000000000 -0700 @@ -0,0 +1,679 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; +import java.time.format.ResolverStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; +import java.util.HashMap; +import java.util.Map; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKIsoChronology { + // Can only work with IsoChronology here + // others may be in separate module + + @Test + public void factory_from_TemporalAccessor_dateWithChronlogy() { + assertEquals(Chronology.from(LocalDate.of(2012, 6, 30)), IsoChronology.INSTANCE); + } + + @Test + public void factory_from_TemporalAccessor_chronology() { + assertEquals(Chronology.from(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return (R) IsoChronology.INSTANCE; + } + throw new UnsupportedOperationException(); + } + }), IsoChronology.INSTANCE); + } + + @Test + public void factory_from_TemporalAccessor_noChronology() { + assertEquals(Chronology.from(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return null; + } + throw new UnsupportedOperationException(); + } + }), IsoChronology.INSTANCE); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_from_TemporalAccessor_null() { + Chronology.from(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_date_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.date(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + throw new UnsupportedOperationException(); + } + }), LocalDate.of(2012, 6, 30)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_date_TemporalAccessor_null() { + IsoChronology.INSTANCE.date(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_localDateTime_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.localDateTime(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + if (field == ChronoField.NANO_OF_DAY) { + return LocalTime.of(12, 30, 40).toNanoOfDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + if (query == TemporalQuery.localTime()) { + return (R) LocalTime.of(12, 30, 40); + } + throw new UnsupportedOperationException(); + } + }), LocalDateTime.of(2012, 6, 30, 12, 30, 40)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_localDateTime_TemporalAccessor_null() { + IsoChronology.INSTANCE.localDateTime(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_zonedDateTime_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.zonedDateTime(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY || + field == ChronoField.INSTANT_SECONDS || field == ChronoField.NANO_OF_SECOND) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.INSTANT_SECONDS) { + return ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London")).toEpochSecond(); + } + if (field == ChronoField.NANO_OF_SECOND) { + return 0; + } + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + if (field == ChronoField.NANO_OF_DAY) { + return LocalTime.of(12, 30, 40).toNanoOfDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + if (query == TemporalQuery.localTime()) { + return (R) LocalTime.of(12, 30, 40); + } + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone()) { + return (R) ZoneId.of("Europe/London"); + } + throw new UnsupportedOperationException(); + } + }), ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London"))); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_zonedDateTime_TemporalAccessor_null() { + IsoChronology.INSTANCE.zonedDateTime(null); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_yearOfEra") + Object[][] data_resolve_yearOfEra() { + return new Object[][] { + {-1, 2012, null, null, false, false}, + {0, 2012, null, -2011, true, true}, + {1, 2012, null, 2012, true, true}, + {2, 2012, null, null, false, false}, + + {null, 2012, null, 2012, true, null}, + {null, 2012, 2012, 2012, true, true}, + {null, 2012, -2011, -2011, true, true}, + {null, 2012, 2013, null, false, false}, + {null, 2012, -2013, null, false, false}, + }; + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_lenient(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_smart(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_strict(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (strict == null) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) (long) yoe); + } else if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_ymd") + Object[][] data_resolve_ymd() { + return new Object[][] { + {2012, 1, -365, date(2010, 12, 31), false, false}, + {2012, 1, -364, date(2011, 1, 1), false, false}, + {2012, 1, -31, date(2011, 11, 30), false, false}, + {2012, 1, -30, date(2011, 12, 1), false, false}, + {2012, 1, -12, date(2011, 12, 19), false, false}, + {2012, 1, 1, date(2012, 1, 1), true, true}, + {2012, 1, 59, date(2012, 2, 28), false, false}, + {2012, 1, 60, date(2012, 2, 29), false, false}, + {2012, 1, 61, date(2012, 3, 1), false, false}, + {2012, 1, 365, date(2012, 12, 30), false, false}, + {2012, 1, 366, date(2012, 12, 31), false, false}, + {2012, 1, 367, date(2013, 1, 1), false, false}, + {2012, 1, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 1, 367 + 365, date(2014, 1, 1), false, false}, + + {2012, 2, 1, date(2012, 2, 1), true, true}, + {2012, 2, 28, date(2012, 2, 28), true, true}, + {2012, 2, 29, date(2012, 2, 29), true, true}, + {2012, 2, 30, date(2012, 3, 1), date(2012, 2, 29), false}, + {2012, 2, 31, date(2012, 3, 2), date(2012, 2, 29), false}, + {2012, 2, 32, date(2012, 3, 3), false, false}, + + {2012, -12, 1, date(2010, 12, 1), false, false}, + {2012, -11, 1, date(2011, 1, 1), false, false}, + {2012, -1, 1, date(2011, 11, 1), false, false}, + {2012, 0, 1, date(2011, 12, 1), false, false}, + {2012, 1, 1, date(2012, 1, 1), true, true}, + {2012, 12, 1, date(2012, 12, 1), true, true}, + {2012, 13, 1, date(2013, 1, 1), false, false}, + {2012, 24, 1, date(2013, 12, 1), false, false}, + {2012, 25, 1, date(2014, 1, 1), false, false}, + + {2012, 6, -31, date(2012, 4, 30), false, false}, + {2012, 6, -30, date(2012, 5, 1), false, false}, + {2012, 6, -1, date(2012, 5, 30), false, false}, + {2012, 6, 0, date(2012, 5, 31), false, false}, + {2012, 6, 1, date(2012, 6, 1), true, true}, + {2012, 6, 30, date(2012, 6, 30), true, true}, + {2012, 6, 31, date(2012, 7, 1), date(2012, 6, 30), false}, + {2012, 6, 61, date(2012, 7, 31), false, false}, + {2012, 6, 62, date(2012, 8, 1), false, false}, + + {2011, 2, 1, date(2011, 2, 1), true, true}, + {2011, 2, 28, date(2011, 2, 28), true, true}, + {2011, 2, 29, date(2011, 3, 1), date(2011, 2, 28), false}, + {2011, 2, 30, date(2011, 3, 2), date(2011, 2, 28), false}, + {2011, 2, 31, date(2011, 3, 3), date(2011, 2, 28), false}, + {2011, 2, 32, date(2011, 3, 4), false, false}, + }; + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_lenient(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_smart(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + if (Boolean.TRUE.equals(smart)) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else if (smart instanceof LocalDate) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, smart); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_strict(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_yd") + Object[][] data_resolve_yd() { + return new Object[][] { + {2012, -365, date(2010, 12, 31), false, false}, + {2012, -364, date(2011, 1, 1), false, false}, + {2012, -31, date(2011, 11, 30), false, false}, + {2012, -30, date(2011, 12, 1), false, false}, + {2012, -12, date(2011, 12, 19), false, false}, + {2012, -1, date(2011, 12, 30), false, false}, + {2012, 0, date(2011, 12, 31), false, false}, + {2012, 1, date(2012, 1, 1), true, true}, + {2012, 2, date(2012, 1, 2), true, true}, + {2012, 31, date(2012, 1, 31), true, true}, + {2012, 32, date(2012, 2, 1), true, true}, + {2012, 59, date(2012, 2, 28), true, true}, + {2012, 60, date(2012, 2, 29), true, true}, + {2012, 61, date(2012, 3, 1), true, true}, + {2012, 365, date(2012, 12, 30), true, true}, + {2012, 366, date(2012, 12, 31), true, true}, + {2012, 367, date(2013, 1, 1), false, false}, + {2012, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 367 + 365, date(2014, 1, 1), false, false}, + + {2011, 59, date(2011, 2, 28), true, true}, + {2011, 60, date(2011, 3, 1), true, true}, + }; + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_lenient(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_smart(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_strict(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_ymaa") + Object[][] data_resolve_ymaa() { + return new Object[][] { + {2012, 1, 1, -365, date(2010, 12, 31), false, false}, + {2012, 1, 1, -364, date(2011, 1, 1), false, false}, + {2012, 1, 1, -31, date(2011, 11, 30), false, false}, + {2012, 1, 1, -30, date(2011, 12, 1), false, false}, + {2012, 1, 1, -12, date(2011, 12, 19), false, false}, + {2012, 1, 1, 1, date(2012, 1, 1), true, true}, + {2012, 1, 1, 59, date(2012, 2, 28), false, false}, + {2012, 1, 1, 60, date(2012, 2, 29), false, false}, + {2012, 1, 1, 61, date(2012, 3, 1), false, false}, + {2012, 1, 1, 365, date(2012, 12, 30), false, false}, + {2012, 1, 1, 366, date(2012, 12, 31), false, false}, + {2012, 1, 1, 367, date(2013, 1, 1), false, false}, + {2012, 1, 1, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 1, 1, 367 + 365, date(2014, 1, 1), false, false}, + + {2012, 2, 0, 1, date(2012, 1, 25), false, false}, + {2012, 2, 0, 7, date(2012, 1, 31), false, false}, + {2012, 2, 1, 1, date(2012, 2, 1), true, true}, + {2012, 2, 1, 7, date(2012, 2, 7), true, true}, + {2012, 2, 2, 1, date(2012, 2, 8), true, true}, + {2012, 2, 2, 7, date(2012, 2, 14), true, true}, + {2012, 2, 3, 1, date(2012, 2, 15), true, true}, + {2012, 2, 3, 7, date(2012, 2, 21), true, true}, + {2012, 2, 4, 1, date(2012, 2, 22), true, true}, + {2012, 2, 4, 7, date(2012, 2, 28), true, true}, + {2012, 2, 5, 1, date(2012, 2, 29), true, true}, + {2012, 2, 5, 2, date(2012, 3, 1), true, false}, + {2012, 2, 5, 7, date(2012, 3, 6), true, false}, + {2012, 2, 6, 1, date(2012, 3, 7), false, false}, + {2012, 2, 6, 7, date(2012, 3, 13), false, false}, + + {2012, 12, 1, 1, date(2012, 12, 1), true, true}, + {2012, 12, 5, 1, date(2012, 12, 29), true, true}, + {2012, 12, 5, 2, date(2012, 12, 30), true, true}, + {2012, 12, 5, 3, date(2012, 12, 31), true, true}, + {2012, 12, 5, 4, date(2013, 1, 1), true, false}, + {2012, 12, 5, 7, date(2013, 1, 4), true, false}, + + {2012, -12, 1, 1, date(2010, 12, 1), false, false}, + {2012, -11, 1, 1, date(2011, 1, 1), false, false}, + {2012, -1, 1, 1, date(2011, 11, 1), false, false}, + {2012, 0, 1, 1, date(2011, 12, 1), false, false}, + {2012, 1, 1, 1, date(2012, 1, 1), true, true}, + {2012, 12, 1, 1, date(2012, 12, 1), true, true}, + {2012, 13, 1, 1, date(2013, 1, 1), false, false}, + {2012, 24, 1, 1, date(2013, 12, 1), false, false}, + {2012, 25, 1, 1, date(2014, 1, 1), false, false}, + + {2011, 2, 1, 1, date(2011, 2, 1), true, true}, + {2011, 2, 4, 7, date(2011, 2, 28), true, true}, + {2011, 2, 5, 1, date(2011, 3, 1), true, false}, + }; + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_lenient(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_smart(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_strict(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + private static LocalDate date(int y, int m, int d) { + return LocalDate.of(y, m, d); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKIsoEra.java 2013-04-11 23:18:51.000000000 -0700 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.IsoEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKIsoEra { + + @DataProvider(name = "IsoEras") + Object[][] data_of_eras() { + return new Object[][] { + {IsoEra.BCE, "BCE", 0}, + {IsoEra.CE, "CE", 1}, + }; + } + + @Test(dataProvider="IsoEras") + public void test_valueOf(IsoEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(IsoEra.of(eraValue), era); + assertEquals(IsoEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = IsoChronology.INSTANCE.eras(); + IsoEra[] eras = IsoEra.values(); + assertEquals(eraList.size(), eras.length); + for (IsoEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (IsoEra era : IsoEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java 2013-04-11 23:18:51.000000000 -0700 @@ -0,0 +1,545 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.Period; +import java.time.Year; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseDate; +import java.time.chrono.JapaneseEra; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; +import java.util.List; +import java.util.Locale; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKJapaneseChronology { + private static final int YDIFF_HEISEI = 1988; + private static final int YDIFF_MEIJI = 1867; + private static final int YDIFF_SHOWA = 1925; + private static final int YDIFF_TAISHO = 1911; + + //----------------------------------------------------------------------- + // Chronology.of(String) + //----------------------------------------------------------------------- + @Test + public void test_chrono_byName() { + Chronology c = JapaneseChronology.INSTANCE; + Chronology test = Chronology.of("Japanese"); + Assert.assertNotNull(test, "The Japanese calendar could not be found byName"); + Assert.assertEquals(test.getId(), "Japanese", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch"); + Assert.assertEquals(test, c); + } + + //----------------------------------------------------------------------- + // Chronology.ofLocale(Locale) + //----------------------------------------------------------------------- + @Test + public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() { + Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese")); + Assert.assertEquals(test.getId(), "Japanese"); + Assert.assertEquals(test, JapaneseChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() { + Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese")); + Assert.assertEquals(test.getId(), "Japanese"); + Assert.assertEquals(test, JapaneseChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_oldJP_noVariant() { + Chronology test = Chronology.ofLocale(new Locale("ja", "JP")); + Assert.assertEquals(test.getId(), "ISO"); + Assert.assertEquals(test, IsoChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_oldJP_variant() { + Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP")); + Assert.assertEquals(test.getId(), "Japanese"); + Assert.assertEquals(test, JapaneseChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_iso() { + Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO"); + Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO"); + Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO"); + } + + //----------------------------------------------------------------------- + // creation, toLocalDate() + //----------------------------------------------------------------------- + @DataProvider(name="samples") + Object[][] data_samples() { + return new Object[][] { + {JapaneseChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1, 1, 1)}, + {JapaneseChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1, 1, 2)}, + {JapaneseChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1, 1, 3)}, + + {JapaneseChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2, 1, 1)}, + {JapaneseChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3, 1, 1)}, + {JapaneseChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3, 12, 6)}, + {JapaneseChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4, 1, 1)}, + {JapaneseChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)}, + {JapaneseChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)}, + {JapaneseChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)}, + {JapaneseChronology.INSTANCE.date(1662, 3, 3), LocalDate.of(1662, 3, 3)}, + {JapaneseChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)}, + {JapaneseChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(1728, 10, 29)}, + + {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29), LocalDate.of(1996, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29), LocalDate.of(2000, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.MEIJI, 1868 - YDIFF_MEIJI, 2, 29), LocalDate.of(1868, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25), LocalDate.of(1928, 12, 25)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.TAISHO, 1912 - YDIFF_TAISHO, 7, 30), LocalDate.of(1912, 7, 30)}, + + {JapaneseChronology.INSTANCE.dateYearDay(1996, 60), LocalDate.of(1996, 2, 29)}, + {JapaneseChronology.INSTANCE.dateYearDay(1868, 60), LocalDate.of(1868, 2, 29)}, + {JapaneseChronology.INSTANCE.dateYearDay(1928, 60), LocalDate.of(1928, 2, 29)}, + {JapaneseChronology.INSTANCE.dateYearDay(1912, 60), LocalDate.of(1912, 2, 29)}, + }; + } + + @Test(dataProvider="samples") + public void test_toLocalDate(JapaneseDate jdate, LocalDate iso) { + assertEquals(LocalDate.from(jdate), iso); + } + + @Test(dataProvider="samples") + public void test_fromCalendrical(JapaneseDate jdate, LocalDate iso) { + assertEquals(JapaneseChronology.INSTANCE.date(iso), jdate); + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1728, 0, 0}, + + {1728, -1, 1}, + {1728, 0, 1}, + {1728, 14, 1}, + {1728, 15, 1}, + + {1728, 1, -1}, + {1728, 1, 0}, + {1728, 1, 32}, + + {1728, 12, -1}, + {1728, 12, 0}, + {1728, 12, 32}, + + {1725, 2, 29}, + {500, 2, 29}, + {2100, 2, 29}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + JapaneseChronology.INSTANCE.date(year, month, dom); + } + + //----------------------------------------------------------------------- + // prolepticYear() and is LeapYear() + //----------------------------------------------------------------------- + @DataProvider(name="prolepticYear") + Object[][] data_prolepticYear() { + return new Object[][] { + {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, + {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, + {2, JapaneseEra.HEISEI, 0, YDIFF_HEISEI, true}, + {2, JapaneseEra.HEISEI, -10, -10 + YDIFF_HEISEI, false}, + + {-1, JapaneseEra.MEIJI, 1, 1 + YDIFF_MEIJI, true}, + {-1, JapaneseEra.MEIJI, 4, 4 + YDIFF_MEIJI, false}, + + {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false}, + {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true}, + + {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true}, + {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false}, + }; + } + + @Test(dataProvider="prolepticYear") + public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { + Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue) ; + assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj)); + assertEquals(eraObj, era); + assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); + assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; + assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap()) ; + } + + @DataProvider(name="prolepticYearError") + Object[][] data_prolepticYearError() { + return new Object[][] { + {JapaneseEra.MEIJI, 100}, + {JapaneseEra.MEIJI, 0}, + {JapaneseEra.MEIJI, -10}, + + {JapaneseEra.SHOWA, 100}, + {JapaneseEra.SHOWA, 0}, + {JapaneseEra.SHOWA, -10}, + + {JapaneseEra.TAISHO, 100}, + {JapaneseEra.TAISHO, 0}, + {JapaneseEra.TAISHO, -10}, + }; + } + + @Test(dataProvider="prolepticYearError", expectedExceptions=DateTimeException.class) + public void test_prolepticYearError(Era era, int yearOfEra) { + JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra); + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof JapaneseChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = JapaneseChronology.INSTANCE.date(era, 1, 1, 1); + fail("JapaneseChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + try { + @SuppressWarnings("unused") + JapaneseDate jdate = JapaneseDate.of(era, 1, 1, 1); + fail("JapaneseDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + try { + @SuppressWarnings("unused") + int year = JapaneseChronology.INSTANCE.prolepticYear(era, 1); + fail("JapaneseChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + } + } + } + + //----------------------------------------------------------------------- + // get(TemporalField) + //----------------------------------------------------------------------- + @Test + public void test_getLong() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); + assertEquals(base.getLong(ERA), JapaneseEra.SHOWA.getValue()); + assertEquals(base.getLong(YEAR), 1988L); + assertEquals(base.getLong(YEAR_OF_ERA), 63L); + assertEquals(base.getLong(MONTH_OF_YEAR), 6L); + assertEquals(base.getLong(DAY_OF_MONTH), 30L); + } + + //----------------------------------------------------------------------- + // with(TemporalField, long) + //----------------------------------------------------------------------- + @Test + public void test_with_TemporalField_long() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); + JapaneseDate test = base.with(YEAR, 1987); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30)); + + test = test.with(YEAR_OF_ERA, 2); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30)); + + test = test.with(ERA, JapaneseEra.HEISEI.getValue()); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30)); + + test = test.with(MONTH_OF_YEAR, 3); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30)); + + test = test.with(DAY_OF_MONTH, 4); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4)); + } + + //----------------------------------------------------------------------- + // with(WithAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 10, 29); + JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 10, 31)); + } + + @Test + public void test_adjust2() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 12, 2); + JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 12, 31)); + } + + //----------------------------------------------------------------------- + // JapaneseDate.with(Local*) + //----------------------------------------------------------------------- + @Test + public void test_adjust_toLocalDate() { + JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); + JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6)); + assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6)); + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_adjust_toMonth() { + JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); + jdate.with(Month.APRIL); + } + + //----------------------------------------------------------------------- + // LocalDate.with(JapaneseDate) + //----------------------------------------------------------------------- + @Test + public void test_LocalDate_adjustToJapaneseDate() { + JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); + LocalDate test = LocalDate.MIN.with(jdate); + assertEquals(test, LocalDate.of(1728, 10, 29)); + } + + @Test + public void test_LocalDateTime_adjustToJapaneseDate() { + JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); + LocalDateTime test = LocalDateTime.MIN.with(jdate); + assertEquals(test, LocalDateTime.of(1728, 10, 29, 0, 0)); + } + + //----------------------------------------------------------------------- + // Check Japanese Eras + //----------------------------------------------------------------------- + @DataProvider(name="japaneseEras") + Object[][] data_japanseseEras() { + return new Object[][] { + { JapaneseEra.SEIREKI, -999, "Seireki"}, + { JapaneseEra.MEIJI, -1, "Meiji"}, + { JapaneseEra.TAISHO, 0, "Taisho"}, + { JapaneseEra.SHOWA, 1, "Showa"}, + { JapaneseEra.HEISEI, 2, "Heisei"}, + }; + } + + @Test(dataProvider="japaneseEras") + public void test_Japanese_Eras(Era era, int eraValue, String name) { + assertEquals(era.getValue(), eraValue, "EraValue"); + assertEquals(era.toString(), name, "Era Name"); + assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()"); + List eras = JapaneseChronology.INSTANCE.eras(); + assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()"); + } + + @Test + public void test_Japanese_badEras() { + int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000}; + for (int badEra : badEras) { + try { + Era era = JapaneseChronology.INSTANCE.eraOf(badEra); + fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra); + } catch (DateTimeException ex) { + // ignore expected exception + } + } + } + + @Test(dataProvider="japaneseEras") + public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) { + JapaneseEra actualEra = JapaneseEra.valueOf(name); + assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)"); + + actualEra = JapaneseEra.of(eraValue); + assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)"); + + String string = actualEra.toString(); + assertEquals(string, name, "JapaneseEra.toString()"); + } + + @Test + public void test_JapaneseEra_values() { + JapaneseEra[] actualEras = JapaneseEra.values(); + Object[][] erasInfo = data_japanseseEras(); + assertEquals(actualEras.length, erasInfo.length, "Wrong number of Eras"); + + for (int i = 0; i < erasInfo.length; i++) { + Object[] eraInfo = erasInfo[i]; + assertEquals(actualEras[i], eraInfo[0], "Singleton mismatch"); + } + } + + @Test + public void test_JapaneseChronology_eras() { + List actualEras = JapaneseChronology.INSTANCE.eras(); + Object[][] erasInfo = data_japanseseEras(); + assertEquals(actualEras.size(), erasInfo.length, "Wrong number of Eras"); + + for (int i = 0; i < erasInfo.length; i++) { + Object[] eraInfo = erasInfo[i]; + assertEquals(actualEras.get(i), eraInfo[0], "Singleton mismatch"); + } + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + //----------------------------------------------------------------------- + // toString() + //----------------------------------------------------------------------- + @DataProvider(name="toString") + Object[][] data_toString() { + return new Object[][] { + {JapaneseChronology.INSTANCE.date(0001, 1, 1), "Japanese 0001-01-01"}, + {JapaneseChronology.INSTANCE.date(1728, 10, 28), "Japanese 1728-10-28"}, + {JapaneseChronology.INSTANCE.date(1728, 10, 29), "Japanese 1728-10-29"}, + {JapaneseChronology.INSTANCE.date(1727, 12, 5), "Japanese 1727-12-05"}, + {JapaneseChronology.INSTANCE.date(1727, 12, 6), "Japanese 1727-12-06"}, + {JapaneseChronology.INSTANCE.date(1868, 9, 8), "Japanese Meiji 1-09-08"}, + {JapaneseChronology.INSTANCE.date(1912, 7, 29), "Japanese Meiji 45-07-29"}, + {JapaneseChronology.INSTANCE.date(1912, 7, 30), "Japanese Taisho 1-07-30"}, + {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"}, + {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"}, + {JapaneseChronology.INSTANCE.date(1989, 1, 7), "Japanese Showa 64-01-07"}, + {JapaneseChronology.INSTANCE.date(1989, 1, 8), "Japanese Heisei 1-01-08"}, + {JapaneseChronology.INSTANCE.date(2012, 12, 6), "Japanese Heisei 24-12-06"}, + }; + } + + @Test(dataProvider="toString") + public void test_toString(JapaneseDate jdate, String expected) { + assertEquals(jdate.toString(), expected); + } + + //----------------------------------------------------------------------- + // equals() + //----------------------------------------------------------------------- + @Test + public void test_equals_true() { + assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE)); + } + + @Test + public void test_equals_false() { + assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE)); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java 2013-04-11 23:18:52.000000000 -0700 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseEra; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKJapaneseEra { + + @DataProvider(name = "JapaneseEras") + Object[][] data_of_eras() { + return new Object[][] { + {JapaneseEra.HEISEI, "Heisei", 2}, + {JapaneseEra.SHOWA, "Showa", 1}, + {JapaneseEra.TAISHO, "Taisho", 0}, + {JapaneseEra.MEIJI, "Meiji", -1}, + {JapaneseEra.SEIREKI, "Seireki", -999}, + }; + } + + @Test(dataProvider="JapaneseEras") + public void test_valueOf(JapaneseEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(JapaneseEra.of(eraValue), era); + assertEquals(JapaneseEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = JapaneseChronology.INSTANCE.eras(); + JapaneseEra[] eras = JapaneseEra.values(); + assertEquals(eraList.size(), eras.length); + for (JapaneseEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + // eras may be added after release + for (JapaneseEra era : JapaneseEra.values()) { + assertEquals(era.range(ERA).getMinimum(), -999); + assertEquals(era.range(ERA).getLargestMinimum(), -999); + assertEquals(era.range(ERA).getSmallestMaximum(), era.range(ERA).getMaximum()); + assertEquals(era.range(ERA).getMaximum() >= 2, true); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java 2013-04-11 23:18:52.000000000 -0700 @@ -0,0 +1,523 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.time.Clock; +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.Period; +import java.time.Year; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.ChronoLocalDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseDate; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.chrono.MinguoEra; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKMinguoChronology { + + private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); + private static final int YDIFF = 1911; + //----------------------------------------------------------------------- + // Chronology.ofName("Minguo") Lookup by name + //----------------------------------------------------------------------- + @Test + public void test_chrono_byName() { + Chronology c = MinguoChronology.INSTANCE; + Chronology test = Chronology.of("Minguo"); + Assert.assertNotNull(test, "The Minguo calendar could not be found byName"); + Assert.assertEquals(test.getId(), "Minguo", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch"); + Assert.assertEquals(test, c); + } + + //----------------------------------------------------------------------- + // creation, toLocalDate() + //----------------------------------------------------------------------- + @DataProvider(name="samples") + Object[][] data_samples() { + return new Object[][] { + {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)}, + {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)}, + + {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)}, + {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)}, + {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)}, + {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)}, + {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)}, + {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)}, + + {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, + + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.BEFORE_ROC, 4, 60), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, + + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1916 - YDIFF, 2, 29 ), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.BEFORE_ROC, 4, 2, 29), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2000 - YDIFF, 2, 29), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2400 - YDIFF, 2, 29), LocalDate.of(2400, 2, 29)}, + }; + } + + @Test(dataProvider="samples") + public void test_toLocalDate(MinguoDate minguo, LocalDate iso) { + assertEquals(LocalDate.from(minguo), iso); + } + + @Test(dataProvider="samples") + public void test_fromCalendrical(MinguoDate minguo, LocalDate iso) { + assertEquals(MinguoChronology.INSTANCE.date(iso), minguo); + } + + @Test + public void test_dateNow(){ + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ; + + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ; + + ZoneId zoneId = ZoneId.of("Europe/Paris"); + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ; + + assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ; + } + + @SuppressWarnings("unused") + @Test(dataProvider="samples") + public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) { + MinguoDate hd = minguoDate; + ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); + ZoneOffset zo = ZoneOffset.ofHours(1); + ChronoZonedDateTime hzdt = hdt.atZone(zo); + hdt = hdt.plus(1, ChronoUnit.YEARS); + hdt = hdt.plus(1, ChronoUnit.MONTHS); + hdt = hdt.plus(1, ChronoUnit.DAYS); + hdt = hdt.plus(1, ChronoUnit.HOURS); + hdt = hdt.plus(1, ChronoUnit.MINUTES); + hdt = hdt.plus(1, ChronoUnit.SECONDS); + hdt = hdt.plus(1, ChronoUnit.NANOS); + ChronoLocalDateTime a2 = hzdt.toLocalDateTime(); + MinguoDate a3 = a2.toLocalDate(); + MinguoDate a5 = hzdt.toLocalDate(); + //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5); + } + + @Test() + public void test_MinguoChrono() { + MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3); + MinguoDate h2 = h1; + ChronoLocalDateTime h3 = h2.atTime(LocalTime.NOON); + @SuppressWarnings("unused") + ChronoZonedDateTime h4 = h3.atZone(ZoneOffset.UTC); + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1912, 0, 0}, + + {1912, -1, 1}, + {1912, 0, 1}, + {1912, 14, 1}, + {1912, 15, 1}, + + {1912, 1, -1}, + {1912, 1, 0}, + {1912, 1, 32}, + {1912, 2, 29}, + {1912, 2, 30}, + + {1912, 12, -1}, + {1912, 12, 0}, + {1912, 12, 32}, + + {1907 - YDIFF, 2, 29}, + {100 - YDIFF, 2, 29}, + {2100 - YDIFF, 2, 29}, + {2101 - YDIFF, 2, 29}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + MinguoChronology.INSTANCE.date(year, month, dom); + } + + //----------------------------------------------------------------------- + // prolepticYear() and is LeapYear() + //----------------------------------------------------------------------- + @DataProvider(name="prolepticYear") + Object[][] data_prolepticYear() { + return new Object[][] { + {1, MinguoEra.ROC, 1912 - YDIFF, 1912 - YDIFF, true}, + {1, MinguoEra.ROC, 1916 - YDIFF, 1916 - YDIFF, true}, + {1, MinguoEra.ROC, 1914 - YDIFF, 1914 - YDIFF, false}, + {1, MinguoEra.ROC, 2000 - YDIFF, 2000 - YDIFF, true}, + {1, MinguoEra.ROC, 2100 - YDIFF, 2100 - YDIFF, false}, + {1, MinguoEra.ROC, 0, 0, false}, + {1, MinguoEra.ROC, 1908 - YDIFF, 1908 - YDIFF, true}, + {1, MinguoEra.ROC, 1900 - YDIFF, 1900 - YDIFF, false}, + {1, MinguoEra.ROC, 1600 - YDIFF, 1600 - YDIFF, true}, + + {0, MinguoEra.BEFORE_ROC, YDIFF - 1911, 1912 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1915, 1916 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1913, 1914 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1999, 2000 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 2099, 2100 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, 1, 0, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1907, 1908 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1899, 1900 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1599, 1600 - YDIFF, true}, + + }; + } + + @Test(dataProvider="prolepticYear") + public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { + Era eraObj = MinguoChronology.INSTANCE.eraOf(eraValue) ; + assertTrue(MinguoChronology.INSTANCE.eras().contains(eraObj)); + assertEquals(eraObj, era); + assertEquals(MinguoChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); + assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; + assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear + YDIFF).isLeap()) ; + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof MinguoChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = MinguoChronology.INSTANCE.date(era, 1, 1, 1); + fail("MinguoChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* Test for missing MinguoDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + MinguoDate jdate = MinguoDate.of(era, 1, 1, 1); + fail("MinguoDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = MinguoChronology.INSTANCE.prolepticYear(era, 1); + fail("MinguoChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + } + } + } + + //----------------------------------------------------------------------- + // with(DateTimeAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29); + MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31)); + } + + @Test + public void test_adjust2() { + MinguoDate base = MinguoChronology.INSTANCE.date(1728, 12, 2); + MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, MinguoChronology.INSTANCE.date(1728, 12, 31)); + } + + //----------------------------------------------------------------------- + // MinguoDate.with(Local*) + //----------------------------------------------------------------------- + @Test + public void test_adjust_toLocalDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(99, 1, 4); + MinguoDate test = minguo.with(LocalDate.of(2012, 7, 6)); + assertEquals(test, MinguoChronology.INSTANCE.date(101, 7, 6)); + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_adjust_toMonth() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(1726, 1, 4); + minguo.with(Month.APRIL); + } + + //----------------------------------------------------------------------- + // LocalDate.with(MinguoDate) + //----------------------------------------------------------------------- + @Test + public void test_LocalDate_adjustToMinguoDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); + LocalDate test = LocalDate.MIN.with(minguo); + assertEquals(test, LocalDate.of(2012, 10, 29)); + } + + @Test + public void test_LocalDateTime_adjustToMinguoDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); + LocalDateTime test = LocalDateTime.MIN.with(minguo); + assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); + } + + //----------------------------------------------------------------------- + // localDateTime() + //----------------------------------------------------------------------- + @DataProvider(name="localDateTime") + Object[][] data_localDateTime() { + return new Object[][] { + {LocalDateTime.of(2012, 2, 29, 2, 7), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7), null}, + {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + + {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, + {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, + }; + } + + @Test(dataProvider="localDateTime") + public void test_localDateTime(TemporalAccessor accessor, MinguoDate expectedDate, LocalTime expectedTime, Class expectedEx) { + if (expectedEx == null) { + ChronoLocalDateTime result = MinguoChronology.INSTANCE.localDateTime(accessor); + assertEquals(result.toLocalDate(), expectedDate); + assertEquals(MinguoDate.from(accessor), expectedDate); + assertEquals(result.toLocalTime(), expectedTime); + } else { + try { + ChronoLocalDateTime result = MinguoChronology.INSTANCE.localDateTime(accessor); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // zonedDateTime(TemporalAccessor) + //----------------------------------------------------------------------- + @DataProvider(name="zonedDateTime") + Object[][] data_zonedDateTime() { + return new Object[][] { + {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + + {LocalDateTime.of(2012, 2, 29, 2, 7), null, null, DateTimeException.class}, + {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, + {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, + }; + } + + @Test(dataProvider="zonedDateTime") + public void test_zonedDateTime(TemporalAccessor accessor, MinguoDate expectedDate, LocalTime expectedTime, Class expectedEx) { + if (expectedEx == null) { + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(accessor); + assertEquals(result.toLocalDate(), expectedDate); + assertEquals(MinguoDate.from(accessor), expectedDate); + assertEquals(result.toLocalTime(), expectedTime); + + } else { + try { + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(accessor); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // zonedDateTime(Instant, ZoneId ) + //----------------------------------------------------------------------- + @Test + public void test_Instant_zonedDateTime() { + OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO); + ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS); + + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset()); + assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); + assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + + result = MinguoChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset()); + assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); + assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + ThaiBuddhistDate ldate2 = ThaiBuddhistChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + //----------------------------------------------------------------------- + // toString() + //----------------------------------------------------------------------- + @DataProvider(name="toString") + Object[][] data_toString() { + return new Object[][] { + {MinguoChronology.INSTANCE.date(1, 1, 1), "Minguo ROC 1-01-01"}, + {MinguoChronology.INSTANCE.date(1728, 10, 28), "Minguo ROC 1728-10-28"}, + {MinguoChronology.INSTANCE.date(1728, 10, 29), "Minguo ROC 1728-10-29"}, + {MinguoChronology.INSTANCE.date(1727, 12, 5), "Minguo ROC 1727-12-05"}, + {MinguoChronology.INSTANCE.date(1727, 12, 6), "Minguo ROC 1727-12-06"}, + }; + } + + @Test(dataProvider="toString") + public void test_toString(MinguoDate minguo, String expected) { + assertEquals(minguo.toString(), expected); + } + + //----------------------------------------------------------------------- + // equals() + //----------------------------------------------------------------------- + @Test + public void test_equals_true() { + assertTrue(MinguoChronology.INSTANCE.equals(MinguoChronology.INSTANCE)); + } + + @Test + public void test_equals_false() { + assertFalse(MinguoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKMinguoEra.java 2013-04-11 23:18:53.000000000 -0700 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKMinguoEra { + + @DataProvider(name = "MinguoEras") + Object[][] data_of_eras() { + return new Object[][] { + {MinguoEra.BEFORE_ROC, "BEFORE_ROC", 0}, + {MinguoEra.ROC, "ROC", 1}, + }; + } + + //----------------------------------------------------------------------- + // valueOf() + //----------------------------------------------------------------------- + @Test(dataProvider="MinguoEras") + public void test_valueOf(MinguoEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(MinguoEra.of(eraValue), era); + assertEquals(MinguoEra.valueOf(eraName), era); + } + + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = MinguoChronology.INSTANCE.eras(); + MinguoEra[] eras = MinguoEra.values() ; + assertEquals(eraList.size(), eras.length); + for (MinguoEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (MinguoEra era : MinguoEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java 2013-04-11 23:18:53.000000000 -0700 @@ -0,0 +1,468 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.Period; +import java.time.Year; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.chrono.ThaiBuddhistEra; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.ValueRange; +import java.util.List; +import java.util.Locale; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKThaiBuddhistChronology { + + private static final int YDIFF = 543; + + //----------------------------------------------------------------------- + // Chronology.of(String) + //----------------------------------------------------------------------- + @Test + public void test_chrono_byName() { + Chronology c = ThaiBuddhistChronology.INSTANCE; + Chronology test = Chronology.of("ThaiBuddhist"); + Assert.assertNotNull(test, "The ThaiBuddhist calendar could not be found byName"); + Assert.assertEquals(test.getId(), "ThaiBuddhist", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "buddhist", "Type mismatch"); + Assert.assertEquals(test, c); + } + + //----------------------------------------------------------------------- + // Chronology.ofLocale(Locale) + //----------------------------------------------------------------------- + @Test + public void test_chrono_byLocale_fullTag_thaiCalendarFromThai() { + Chronology test = Chronology.ofLocale(Locale.forLanguageTag("th-TH-u-ca-buddhist")); + Assert.assertEquals(test.getId(), "ThaiBuddhist"); + Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() { + Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist")); + Assert.assertEquals(test.getId(), "ThaiBuddhist"); + Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_oldTH_noVariant() { // deliberately different to Calendar + Chronology test = Chronology.ofLocale(new Locale("th", "TH")); + Assert.assertEquals(test.getId(), "ISO"); + Assert.assertEquals(test, IsoChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_oldTH_variant() { + Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH")); + Assert.assertEquals(test.getId(), "ISO"); + Assert.assertEquals(test, IsoChronology.INSTANCE); + } + + @Test + public void test_chrono_byLocale_iso() { + Assert.assertEquals(Chronology.ofLocale(new Locale("th", "TH")).getId(), "ISO"); + Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH")).getId(), "ISO"); + Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH-TH")).getId(), "ISO"); + } + + //----------------------------------------------------------------------- + // creation, toLocalDate() + //----------------------------------------------------------------------- + @DataProvider(name="samples") + Object[][] data_samples() { + return new Object[][] { + {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 1), LocalDate.of(1, 1, 1)}, + {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 2), LocalDate.of(1, 1, 2)}, + {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 3), LocalDate.of(1, 1, 3)}, + + {ThaiBuddhistChronology.INSTANCE.date(2 + YDIFF, 1, 1), LocalDate.of(2, 1, 1)}, + {ThaiBuddhistChronology.INSTANCE.date(3 + YDIFF, 1, 1), LocalDate.of(3, 1, 1)}, + {ThaiBuddhistChronology.INSTANCE.date(3 + YDIFF, 12, 6), LocalDate.of(3, 12, 6)}, + {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 1, 1), LocalDate.of(4, 1, 1)}, + {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 7, 3), LocalDate.of(4, 7, 3)}, + {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 7, 4), LocalDate.of(4, 7, 4)}, + {ThaiBuddhistChronology.INSTANCE.date(5 + YDIFF, 1, 1), LocalDate.of(5, 1, 1)}, + {ThaiBuddhistChronology.INSTANCE.date(1662 + YDIFF, 3, 3), LocalDate.of(1662, 3, 3)}, + {ThaiBuddhistChronology.INSTANCE.date(1728 + YDIFF, 10, 28), LocalDate.of(1728, 10, 28)}, + {ThaiBuddhistChronology.INSTANCE.date(1728 + YDIFF, 10, 29), LocalDate.of(1728, 10, 29)}, + {ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29), LocalDate.of(2012, 8, 29)}, + + {ThaiBuddhistChronology.INSTANCE.dateYearDay(4 + YDIFF, 60), LocalDate.of(4, 2, 29)}, + {ThaiBuddhistChronology.INSTANCE.dateYearDay(400 + YDIFF, 60), LocalDate.of(400, 2, 29)}, + {ThaiBuddhistChronology.INSTANCE.dateYearDay(2000 + YDIFF, 60), LocalDate.of(2000, 2, 29)}, + + }; + } + + @Test(dataProvider="samples") + public void test_toLocalDate(ThaiBuddhistDate jdate, LocalDate iso) { + assertEquals(LocalDate.from(jdate), iso); + } + + @Test(dataProvider="samples") + public void test_fromCalendrical(ThaiBuddhistDate jdate, LocalDate iso) { + assertEquals(ThaiBuddhistChronology.INSTANCE.date(iso), jdate); + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1728, 0, 0}, + + {1728, -1, 1}, + {1728, 0, 1}, + {1728, 14, 1}, + {1728, 15, 1}, + + {1728, 1, -1}, + {1728, 1, 0}, + {1728, 1, 32}, + + {1728, 12, -1}, + {1728, 12, 0}, + {1728, 12, 32}, + + {3 + YDIFF, 2, 29}, + {600 + YDIFF, 2, 29}, + {1501 + YDIFF, 2, 29}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + ThaiBuddhistChronology.INSTANCE.date(year, month, dom); + } + + //----------------------------------------------------------------------- + // prolepticYear() and is LeapYear() + //----------------------------------------------------------------------- + @DataProvider(name="prolepticYear") + Object[][] data_prolepticYear() { + return new Object[][] { + {1, ThaiBuddhistEra.BE, 4 + YDIFF, 4 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 7 + YDIFF, 7 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, 8 + YDIFF, 8 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 1000 + YDIFF, 1000 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, 2000 + YDIFF, 2000 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 0, 0, false}, + {1, ThaiBuddhistEra.BE, -4 + YDIFF, -4 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, -7 + YDIFF, -7 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, -100 + YDIFF, -100 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, -800 + YDIFF, -800 + YDIFF, true}, + + {0, ThaiBuddhistEra.BEFORE_BE, -3 - YDIFF, 4 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, -6 - YDIFF, 7 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, -7 - YDIFF, 8 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, -999 - YDIFF, 1000 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, -1999 - YDIFF, 2000 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, 1, 0, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 5 - YDIFF, -4 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, 8 - YDIFF, -7 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 101 - YDIFF, -100 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 801 - YDIFF, -800 + YDIFF, true}, + + }; + } + + @Test(dataProvider="prolepticYear") + public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { + Era eraObj = ThaiBuddhistChronology.INSTANCE.eraOf(eraValue) ; + assertTrue(ThaiBuddhistChronology.INSTANCE.eras().contains(eraObj)); + assertEquals(eraObj, era); + assertEquals(ThaiBuddhistChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); + assertEquals(ThaiBuddhistChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; + assertEquals(ThaiBuddhistChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear - YDIFF).isLeap()) ; + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof ThaiBuddhistChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = ThaiBuddhistChronology.INSTANCE.date(era, 1, 1, 1); + fail("ThaiBuddhistChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* TODO: Test for missing ThaiBuddhistDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + ThaiBuddhistDate jdate = ThaiBuddhistDate.of(era, 1, 1, 1); + fail("ThaiBuddhistDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = ThaiBuddhistChronology.INSTANCE.prolepticYear(era, 1); + fail("ThaiBuddhistChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } } + } + } + + //----------------------------------------------------------------------- + // with(WithAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 10, 29); + ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 10, 31)); + } + + @Test + public void test_adjust2() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2); + ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31)); + } + + //----------------------------------------------------------------------- + // withYear() + //----------------------------------------------------------------------- + @Test + public void test_withYear_BE() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); + ThaiBuddhistDate test = base.with(YEAR, 2554); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2554, 8, 29)); + } + + @Test + public void test_withYear_BBE() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); + ThaiBuddhistDate test = base.with(YEAR_OF_ERA, 2554); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(-2553, 8, 29)); + } + + //----------------------------------------------------------------------- + // withEra() + //----------------------------------------------------------------------- + @Test + public void test_withEra_BE() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BE.getValue()); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); + } + + @Test + public void test_withEra_BBE() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BEFORE_BE.getValue()); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29)); + } + + @Test + public void test_withEra_swap() { + ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BE.getValue()); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); + } + + //----------------------------------------------------------------------- + // BuddhistDate.with(Local*) + //----------------------------------------------------------------------- + @Test + public void test_adjust_toLocalDate() { + ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); + ThaiBuddhistDate test = jdate.with(LocalDate.of(2012, 7, 6)); + assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 7, 6)); + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_adjust_toMonth() { + ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); + jdate.with(Month.APRIL); + } + + //----------------------------------------------------------------------- + // LocalDate.with(BuddhistDate) + //----------------------------------------------------------------------- + @Test + public void test_LocalDate_adjustToBuddhistDate() { + ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); + LocalDate test = LocalDate.MIN.with(jdate); + assertEquals(test, LocalDate.of(2012, 10, 29)); + } + + @Test + public void test_LocalDateTime_adjustToBuddhistDate() { + ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); + LocalDateTime test = LocalDateTime.MIN.with(jdate); + assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + //----------------------------------------------------------------------- + // toString() + //----------------------------------------------------------------------- + @DataProvider(name="toString") + Object[][] data_toString() { + return new Object[][] { + {ThaiBuddhistChronology.INSTANCE.date(544, 1, 1), "ThaiBuddhist BE 544-01-01"}, + {ThaiBuddhistChronology.INSTANCE.date(2271, 10, 28), "ThaiBuddhist BE 2271-10-28"}, + {ThaiBuddhistChronology.INSTANCE.date(2271, 10, 29), "ThaiBuddhist BE 2271-10-29"}, + {ThaiBuddhistChronology.INSTANCE.date(2270, 12, 5), "ThaiBuddhist BE 2270-12-05"}, + {ThaiBuddhistChronology.INSTANCE.date(2270, 12, 6), "ThaiBuddhist BE 2270-12-06"}, + }; + } + + @Test(dataProvider="toString") + public void test_toString(ThaiBuddhistDate jdate, String expected) { + assertEquals(jdate.toString(), expected); + } + + //----------------------------------------------------------------------- + // chronology range(ChronoField) + //----------------------------------------------------------------------- + @Test + public void test_Chrono_range() { + long minYear = LocalDate.MIN.getYear() + YDIFF; + long maxYear = LocalDate.MAX.getYear() + YDIFF; + assertEquals(ThaiBuddhistChronology.INSTANCE.range(YEAR), ValueRange.of(minYear, maxYear)); + assertEquals(ThaiBuddhistChronology.INSTANCE.range(YEAR_OF_ERA), ValueRange.of(1, -minYear + 1, maxYear)); + + assertEquals(ThaiBuddhistChronology.INSTANCE.range(DAY_OF_MONTH), DAY_OF_MONTH.range()); + assertEquals(ThaiBuddhistChronology.INSTANCE.range(DAY_OF_YEAR), DAY_OF_YEAR.range()); + assertEquals(ThaiBuddhistChronology.INSTANCE.range(MONTH_OF_YEAR), MONTH_OF_YEAR.range()); + } + + //----------------------------------------------------------------------- + // equals() + //----------------------------------------------------------------------- + @Test + public void test_equals_true() { + assertTrue(ThaiBuddhistChronology.INSTANCE.equals(ThaiBuddhistChronology.INSTANCE)); + } + + @Test + public void test_equals_false() { + assertFalse(ThaiBuddhistChronology.INSTANCE.equals(IsoChronology.INSTANCE)); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/chrono/TCKThaiBuddhistEra.java 2013-04-11 23:18:54.000000000 -0700 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKThaiBuddhistEra { + + @DataProvider(name = "ThaiBuddhistEras") + Object[][] data_of_eras() { + return new Object[][] { + {ThaiBuddhistEra.BEFORE_BE, "BEFORE_BE", 0}, + {ThaiBuddhistEra.BE, "BE", 1}, + }; + } + + + //----------------------------------------------------------------------- + // valueOf() + //----------------------------------------------------------------------- + @Test(dataProvider="ThaiBuddhistEras") + public void test_valueOf(ThaiBuddhistEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(ThaiBuddhistEra.of(eraValue), era); + assertEquals(ThaiBuddhistEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = ThaiBuddhistChronology.INSTANCE.eras(); + ThaiBuddhistEra[] eras = ThaiBuddhistEra.values(); + assertEquals(eraList.size(), eras.length); + for (ThaiBuddhistEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (ThaiBuddhistEra era : ThaiBuddhistEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java 2013-04-11 23:18:54.000000000 -0700 @@ -0,0 +1,522 @@ +/* + * Copyright (c) 2013, 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 + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.format; + +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.AMPM_OF_DAY; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.HOUR_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_SECOND; +import static java.time.temporal.ChronoField.MILLI_OF_DAY; +import static java.time.temporal.ChronoField.MILLI_OF_SECOND; +import static java.time.temporal.ChronoField.MINUTE_OF_DAY; +import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.SECOND_OF_DAY; +import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.IsoFields; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test parse resolving. + */ +@Test +public class TCKDateTimeParseResolver { + // TODO: tests with weird TenporalField implementations + // TODO: tests with non-ISO chronologies + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneNoChange") + Object[][] data_resolveOneNoChange() { + return new Object[][]{ + {YEAR, 2012}, + {MONTH_OF_YEAR, 8}, + {DAY_OF_MONTH, 7}, + {DAY_OF_YEAR, 6}, + {DAY_OF_WEEK, 5}, + }; + } + + @Test(dataProvider="resolveOneNoChange") + public void test_resolveOneNoChange(TemporalField field1, long value1) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.getLong(field1), value1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoNoChange") + Object[][] data_resolveTwoNoChange() { + return new Object[][]{ + {YEAR, 2012, MONTH_OF_YEAR, 5}, + {YEAR, 2012, DAY_OF_MONTH, 5}, + {YEAR, 2012, DAY_OF_WEEK, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_MONTH, 5}, + {YEAR, 2012, IsoFields.QUARTER_OF_YEAR, 3}, + {YEAR, 2012, MINUTE_OF_HOUR, 5}, + {YEAR, 2012, SECOND_OF_MINUTE, 5}, + {YEAR, 2012, NANO_OF_SECOND, 5}, + + {MONTH_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_YEAR, 5}, + {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_MONTH, 5}, + {MONTH_OF_YEAR, 3, IsoFields.QUARTER_OF_YEAR, 5}, + {MONTH_OF_YEAR, 5, MINUTE_OF_HOUR, 5}, + {MONTH_OF_YEAR, 5, SECOND_OF_MINUTE, 5}, + {MONTH_OF_YEAR, 5, NANO_OF_SECOND, 5}, + }; + } + + @Test(dataProvider="resolveTwoNoChange") + public void test_resolveTwoNoChange(TemporalField field1, long value1, TemporalField field2, long value2) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + TemporalAccessor accessor = f.parse(str); + + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.isSupported(field2), true); + assertEquals(accessor.getLong(field1), value1); + assertEquals(accessor.getLong(field2), value2); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveThreeNoChange") + Object[][] data_resolveThreeNoChange() { + return new Object[][]{ + {YEAR, 2012, MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_MONTH, 5, DAY_OF_MONTH, 5}, + {YEAR, 2012, MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {ERA, 1, MONTH_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {MONTH_OF_YEAR, 1, DAY_OF_MONTH, 5, IsoFields.QUARTER_OF_YEAR, 3}, + {HOUR_OF_DAY, 1, SECOND_OF_MINUTE, 5, NANO_OF_SECOND, 5}, + {MINUTE_OF_HOUR, 1, SECOND_OF_MINUTE, 5, NANO_OF_SECOND, 5}, + }; + } + + @Test(dataProvider="resolveThreeNoChange") + public void test_resolveThreeNoChange(TemporalField field1, long value1, TemporalField field2, long value2, TemporalField field3, long value3) { + String str = value1 + " " + value2 + " " + value3; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).toFormatter(); + TemporalAccessor accessor = f.parse(str); + + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.isSupported(field2), true); + assertEquals(accessor.isSupported(field3), true); + assertEquals(accessor.getLong(field1), value1); + assertEquals(accessor.getLong(field2), value2); + assertEquals(accessor.getLong(field3), value3); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToField") + Object[][] data_resolveOneToField() { + return new Object[][]{ + {YEAR_OF_ERA, 2012, YEAR, 2012L, null, null}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR, 2012L, MONTH_OF_YEAR, 3L}, + + {CLOCK_HOUR_OF_AMPM, 8, HOUR_OF_AMPM, 8L, null, null}, + {CLOCK_HOUR_OF_AMPM, 12, HOUR_OF_AMPM, 0L, null, null}, + {MICRO_OF_SECOND, 12, NANO_OF_SECOND, 12_000L, null, null}, + {MILLI_OF_SECOND, 12, NANO_OF_SECOND, 12_000_000L, null, null}, + }; + } + + @Test(dataProvider="resolveOneToField") + public void test_resolveOneToField(TemporalField field1, long value1, + TemporalField expectedField1, Long expectedValue1, + TemporalField expectedField2, Long expectedValue2) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + if (expectedField1 != null) { + assertEquals(accessor.isSupported(expectedField1), true); + assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); + } + if (expectedField2 != null) { + assertEquals(accessor.isSupported(expectedField2), true); + assertEquals(accessor.getLong(expectedField2), expectedValue2.longValue()); + } + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToDate") + Object[][] data_resolveOneToDate() { + return new Object[][]{ + {EPOCH_DAY, 32, LocalDate.of(1970, 2, 2)}, + }; + } + + @Test(dataProvider="resolveOneToDate") + public void test_resolveOneToDate(TemporalField field1, long value1, LocalDate expectedDate) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToTime") + Object[][] data_resolveOneToTime() { + return new Object[][]{ + {HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 24, LocalTime.of(0, 0)}, + {MINUTE_OF_DAY, 650, LocalTime.of(10, 50)}, + {SECOND_OF_DAY, 3600 + 650, LocalTime.of(1, 10, 50)}, + {MILLI_OF_DAY, (3600 + 650) * 1_000L + 2, LocalTime.of(1, 10, 50, 2_000_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1_000_000L + 2, LocalTime.of(1, 10, 50, 2_000)}, + {NANO_OF_DAY, (3600 + 650) * 1_000_000_000L + 2, LocalTime.of(1, 10, 50, 2)}, + }; + } + + @Test(dataProvider="resolveOneToTime") + public void test_resolveOneToTime(TemporalField field1, long value1, LocalTime expectedTime) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToField") + Object[][] data_resolveTwoToField() { + return new Object[][]{ + // cross-check + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR, 2012, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR_OF_ERA, 2012, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), ERA, 1, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), YEAR, 0, YEAR, 0L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), YEAR_OF_ERA, 1, YEAR, 0L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), ERA, 0, YEAR, 0L, MONTH_OF_YEAR, 3L}, + }; + } + + @Test(dataProvider="resolveTwoToField") + public void test_resolveTwoToField(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField expectedField1, Long expectedValue1, + TemporalField expectedField2, Long expectedValue2) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + if (expectedField1 != null) { + assertEquals(accessor.isSupported(expectedField1), true); + assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); + } + if (expectedField2 != null) { + assertEquals(accessor.isSupported(expectedField2), true); + assertEquals(accessor.getLong(expectedField2), expectedValue2.longValue()); + } + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToDate") + Object[][] data_resolveTwoToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, DAY_OF_YEAR, 32, LocalDate.of(2012, 2, 1)}, + {YEAR_OF_ERA, 2012, DAY_OF_YEAR, 32, LocalDate.of(2012, 2, 1)}, + + // merge + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_MONTH, 25, LocalDate.of(2012, 2, 25)}, + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_YEAR, 56, LocalDate.of(2012, 2, 25)}, + + // cross-check + {EPOCH_DAY, 32, ERA, 1, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, ERA, 0, LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, YEAR, 1970, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, YEAR, 1970 - (400 * 5), LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, YEAR_OF_ERA, 1970, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, YEAR_OF_ERA, 1 - (1970 - (400 * 5)), LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, MONTH_OF_YEAR, 2, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_YEAR, 33, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_MONTH, 2, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_WEEK, 1, LocalDate.of(1970, 2, 2)}, + }; + } + + @Test(dataProvider="resolveTwoToDate") + public void test_resolveTwoToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + LocalDate expectedDate) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToTime") + Object[][] data_resolveTwoToTime() { + return new Object[][]{ + // merge + {HOUR_OF_DAY, 8, MINUTE_OF_HOUR, 6, LocalTime.of(8, 6)}, + + // merge + {AMPM_OF_DAY, 0, HOUR_OF_AMPM, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, HOUR_OF_AMPM, 5, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, CLOCK_HOUR_OF_AMPM, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, CLOCK_HOUR_OF_AMPM, 5, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, HOUR_OF_DAY, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, HOUR_OF_DAY, 17, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, CLOCK_HOUR_OF_DAY, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, CLOCK_HOUR_OF_DAY, 17, LocalTime.of(17, 0)}, + + // merge + {CLOCK_HOUR_OF_DAY, 8, MINUTE_OF_HOUR, 6, LocalTime.of(8, 6)}, + {CLOCK_HOUR_OF_DAY, 24, MINUTE_OF_HOUR, 6, LocalTime.of(0, 6)}, + // cross-check + {CLOCK_HOUR_OF_DAY, 8, HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 8, CLOCK_HOUR_OF_AMPM, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 20, CLOCK_HOUR_OF_AMPM, 8, LocalTime.of(20, 0)}, + {CLOCK_HOUR_OF_DAY, 8, AMPM_OF_DAY, 0, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 20, AMPM_OF_DAY, 1, LocalTime.of(20, 0)}, + + // merge + {MINUTE_OF_DAY, 650, SECOND_OF_MINUTE, 8, LocalTime.of(10, 50, 8)}, + // cross-check + {MINUTE_OF_DAY, 650, HOUR_OF_DAY, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, CLOCK_HOUR_OF_DAY, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, CLOCK_HOUR_OF_AMPM, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, AMPM_OF_DAY, 0, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, MINUTE_OF_HOUR, 50, LocalTime.of(10, 50)}, + + // merge + {SECOND_OF_DAY, 3600 + 650, MILLI_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000_000)}, + {SECOND_OF_DAY, 3600 + 650, MICRO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000)}, + {SECOND_OF_DAY, 3600 + 650, NANO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2)}, + // cross-check + {SECOND_OF_DAY, 3600 + 650, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50)}, + {SECOND_OF_DAY, 3600 + 650, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50)}, + {SECOND_OF_DAY, 3600 + 650, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50)}, + + // merge + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MICRO_OF_SECOND, 2_004, LocalTime.of(1, 10, 50, 2_004_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, NANO_OF_SECOND, 2_000_004, LocalTime.of(1, 10, 50, 2_000_004)}, + // cross-check + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MILLI_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000_000)}, + + // merge + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, NANO_OF_SECOND, 2_004, LocalTime.of(1, 10, 50, 2_004)}, + // cross-check + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MILLI_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MICRO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000)}, + + // cross-check + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MILLI_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MICRO_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, NANO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2)}, + }; + } + + @Test(dataProvider="resolveTwoToTime") + public void test_resolveTwoToTime(TemporalField field1, long value1, + TemporalField field2, long value2, + LocalTime expectedTime) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveThreeToDate") + Object[][] data_resolveThreeToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, MONTH_OF_YEAR, 2, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + + // cross-check + {YEAR, 2012, DAY_OF_YEAR, 32, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR_OF_ERA, 2012, DAY_OF_YEAR, 32, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, DAY_OF_YEAR, 32, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_MONTH, 25, DAY_OF_WEEK, 6, LocalDate.of(2012, 2, 25)}, + }; + } + + @Test(dataProvider="resolveThreeToDate") + public void test_resolveThreeToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField field3, long value3, + LocalDate expectedDate) { + String str = value1 + " " + value2 + " " + value3; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveFourToDate") + Object[][] data_resolveFourToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, MONTH_OF_YEAR, 2, ALIGNED_WEEK_OF_MONTH, 1, ALIGNED_DAY_OF_WEEK_IN_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, MONTH_OF_YEAR, 2, ALIGNED_WEEK_OF_MONTH, 1, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + + // cross-check + {YEAR, 2012, MONTH_OF_YEAR, 2, DAY_OF_MONTH, 1, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_WEEK, 3, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + }; + } + + @Test(dataProvider="resolveFourToDate") + public void test_resolveFourToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField field3, long value3, + TemporalField field4, long value4, + LocalDate expectedDate) { + String str = value1 + " " + value2 + " " + value3 + " " + value4; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).appendLiteral(' ') + .appendValue(field4).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/format/TCKTextStyle.java 2013-04-11 23:18:55.000000000 -0700 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2013, 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 + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.format; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.format.TextStyle; + +import org.testng.annotations.Test; + +/** + * Test DateTimeFormatSymbols. + */ +@Test +public class TCKTextStyle { + + @Test + public void test_standaloneNormal() { + assertEquals(TextStyle.FULL, TextStyle.FULL_STANDALONE.asNormal()); + assertEquals(TextStyle.SHORT, TextStyle.SHORT.asNormal()); + assertEquals(TextStyle.NARROW, TextStyle.NARROW.asNormal()); + + assertEquals(TextStyle.FULL_STANDALONE, TextStyle.FULL_STANDALONE.asStandalone()); + assertEquals(TextStyle.SHORT_STANDALONE, TextStyle.SHORT.asStandalone()); + assertEquals(TextStyle.NARROW_STANDALONE, TextStyle.NARROW.asStandalone()); + + assertTrue(TextStyle.FULL_STANDALONE.isStandalone()); + assertTrue(TextStyle.SHORT_STANDALONE.isStandalone()); + assertTrue(TextStyle.NARROW_STANDALONE.isStandalone()); + + assertTrue(!TextStyle.FULL.isStandalone()); + assertTrue(!TextStyle.SHORT.isStandalone()); + assertTrue(!TextStyle.NARROW.isStandalone()); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java 2013-04-11 23:18:55.000000000 -0700 @@ -0,0 +1,615 @@ +/* + * Copyright (c) 2012, 2013, 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 + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.temporal; + +import static java.time.DayOfWeek.MONDAY; +import static java.time.DayOfWeek.TUESDAY; +import static java.time.Month.DECEMBER; +import static java.time.Month.JANUARY; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; + +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.Month; +import java.time.temporal.TemporalAdjuster; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test TemporalAdjuster. + */ +@Test +public class TCKTemporalAdjusters { + + //----------------------------------------------------------------------- + // ofDateAdjuster() + //----------------------------------------------------------------------- + @Test + public void factory_ofDateAdjuster() { + TemporalAdjuster test = TemporalAdjuster.ofDateAdjuster(date -> date.plusDays(2)); + assertEquals(LocalDate.of(2012, 6, 30).with(test), LocalDate.of(2012, 7, 2)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_ofDateAdjuster_null() { + TemporalAdjuster.ofDateAdjuster(null); + } + + + //----------------------------------------------------------------------- + // firstDayOfMonth() + //----------------------------------------------------------------------- + @Test + public void factory_firstDayOfMonth() { + assertNotNull(TemporalAdjuster.firstDayOfMonth()); + } + + @Test + public void test_firstDayOfMonth_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); + assertEquals(test.getYear(), 2007); + assertEquals(test.getMonth(), month); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + @Test + public void test_firstDayOfMonth_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); + assertEquals(test.getYear(), 2008); + assertEquals(test.getMonth(), month); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + //----------------------------------------------------------------------- + // lastDayOfMonth() + //----------------------------------------------------------------------- + @Test + public void factory_lastDayOfMonth() { + assertNotNull(TemporalAdjuster.lastDayOfMonth()); + } + + @Test + public void test_lastDayOfMonth_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); + assertEquals(test.getYear(), 2007); + assertEquals(test.getMonth(), month); + assertEquals(test.getDayOfMonth(), month.length(false)); + } + } + } + + @Test + public void test_lastDayOfMonth_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); + assertEquals(test.getYear(), 2008); + assertEquals(test.getMonth(), month); + assertEquals(test.getDayOfMonth(), month.length(true)); + } + } + } + + //----------------------------------------------------------------------- + // firstDayOfNextMonth() + //----------------------------------------------------------------------- + @Test + public void factory_firstDayOfNextMonth() { + assertNotNull(TemporalAdjuster.firstDayOfNextMonth()); + } + + @Test + public void test_firstDayOfNextMonth_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); + assertEquals(test.getYear(), month == DECEMBER ? 2008 : 2007); + assertEquals(test.getMonth(), month.plus(1)); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + @Test + public void test_firstDayOfNextMonth_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); + assertEquals(test.getYear(), month == DECEMBER ? 2009 : 2008); + assertEquals(test.getMonth(), month.plus(1)); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + //----------------------------------------------------------------------- + // firstDayOfYear() + //----------------------------------------------------------------------- + @Test + public void factory_firstDayOfYear() { + assertNotNull(TemporalAdjuster.firstDayOfYear()); + } + + @Test + public void test_firstDayOfYear_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); + assertEquals(test.getYear(), 2007); + assertEquals(test.getMonth(), Month.JANUARY); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + @Test + public void test_firstDayOfYear_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); + assertEquals(test.getYear(), 2008); + assertEquals(test.getMonth(), Month.JANUARY); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + //----------------------------------------------------------------------- + // lastDayOfYear() + //----------------------------------------------------------------------- + @Test + public void factory_lastDayOfYear() { + assertNotNull(TemporalAdjuster.lastDayOfYear()); + } + + @Test + public void test_lastDayOfYear_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); + assertEquals(test.getYear(), 2007); + assertEquals(test.getMonth(), Month.DECEMBER); + assertEquals(test.getDayOfMonth(), 31); + } + } + } + + @Test + public void test_lastDayOfYear_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); + assertEquals(test.getYear(), 2008); + assertEquals(test.getMonth(), Month.DECEMBER); + assertEquals(test.getDayOfMonth(), 31); + } + } + } + + //----------------------------------------------------------------------- + // firstDayOfNextYear() + //----------------------------------------------------------------------- + @Test + public void factory_firstDayOfNextYear() { + assertNotNull(TemporalAdjuster.firstDayOfNextYear()); + } + + @Test + public void test_firstDayOfNextYear_nonLeap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); + assertEquals(test.getYear(), 2008); + assertEquals(test.getMonth(), JANUARY); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + @Test + public void test_firstDayOfNextYear_leap() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(true); i++) { + LocalDate date = date(2008, month, i); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); + assertEquals(test.getYear(), 2009); + assertEquals(test.getMonth(), JANUARY); + assertEquals(test.getDayOfMonth(), 1); + } + } + } + + //----------------------------------------------------------------------- + // dayOfWeekInMonth() + //----------------------------------------------------------------------- + @Test + public void factory_dayOfWeekInMonth() { + assertNotNull(TemporalAdjuster.dayOfWeekInMonth(1, MONDAY)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_dayOfWeekInMonth_nullDayOfWeek() { + TemporalAdjuster.dayOfWeekInMonth(1, null); + } + + @DataProvider(name = "dayOfWeekInMonth_positive") + Object[][] data_dayOfWeekInMonth_positive() { + return new Object[][] { + {2011, 1, TUESDAY, date(2011, 1, 4)}, + {2011, 2, TUESDAY, date(2011, 2, 1)}, + {2011, 3, TUESDAY, date(2011, 3, 1)}, + {2011, 4, TUESDAY, date(2011, 4, 5)}, + {2011, 5, TUESDAY, date(2011, 5, 3)}, + {2011, 6, TUESDAY, date(2011, 6, 7)}, + {2011, 7, TUESDAY, date(2011, 7, 5)}, + {2011, 8, TUESDAY, date(2011, 8, 2)}, + {2011, 9, TUESDAY, date(2011, 9, 6)}, + {2011, 10, TUESDAY, date(2011, 10, 4)}, + {2011, 11, TUESDAY, date(2011, 11, 1)}, + {2011, 12, TUESDAY, date(2011, 12, 6)}, + }; + } + + @Test(dataProvider = "dayOfWeekInMonth_positive") + public void test_dayOfWeekInMonth_positive(int year, int month, DayOfWeek dow, LocalDate expected) { + for (int ordinal = 1; ordinal <= 5; ordinal++) { + for (int day = 1; day <= Month.of(month).length(false); day++) { + LocalDate date = date(year, month, day); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(ordinal, dow).adjustInto(date); + assertEquals(test, expected.plusWeeks(ordinal - 1)); + } + } + } + + @DataProvider(name = "dayOfWeekInMonth_zero") + Object[][] data_dayOfWeekInMonth_zero() { + return new Object[][] { + {2011, 1, TUESDAY, date(2010, 12, 28)}, + {2011, 2, TUESDAY, date(2011, 1, 25)}, + {2011, 3, TUESDAY, date(2011, 2, 22)}, + {2011, 4, TUESDAY, date(2011, 3, 29)}, + {2011, 5, TUESDAY, date(2011, 4, 26)}, + {2011, 6, TUESDAY, date(2011, 5, 31)}, + {2011, 7, TUESDAY, date(2011, 6, 28)}, + {2011, 8, TUESDAY, date(2011, 7, 26)}, + {2011, 9, TUESDAY, date(2011, 8, 30)}, + {2011, 10, TUESDAY, date(2011, 9, 27)}, + {2011, 11, TUESDAY, date(2011, 10, 25)}, + {2011, 12, TUESDAY, date(2011, 11, 29)}, + }; + } + + @Test(dataProvider = "dayOfWeekInMonth_zero") + public void test_dayOfWeekInMonth_zero(int year, int month, DayOfWeek dow, LocalDate expected) { + for (int day = 1; day <= Month.of(month).length(false); day++) { + LocalDate date = date(year, month, day); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(0, dow).adjustInto(date); + assertEquals(test, expected); + } + } + + @DataProvider(name = "dayOfWeekInMonth_negative") + Object[][] data_dayOfWeekInMonth_negative() { + return new Object[][] { + {2011, 1, TUESDAY, date(2011, 1, 25)}, + {2011, 2, TUESDAY, date(2011, 2, 22)}, + {2011, 3, TUESDAY, date(2011, 3, 29)}, + {2011, 4, TUESDAY, date(2011, 4, 26)}, + {2011, 5, TUESDAY, date(2011, 5, 31)}, + {2011, 6, TUESDAY, date(2011, 6, 28)}, + {2011, 7, TUESDAY, date(2011, 7, 26)}, + {2011, 8, TUESDAY, date(2011, 8, 30)}, + {2011, 9, TUESDAY, date(2011, 9, 27)}, + {2011, 10, TUESDAY, date(2011, 10, 25)}, + {2011, 11, TUESDAY, date(2011, 11, 29)}, + {2011, 12, TUESDAY, date(2011, 12, 27)}, + }; + } + + @Test(dataProvider = "dayOfWeekInMonth_negative") + public void test_dayOfWeekInMonth_negative(int year, int month, DayOfWeek dow, LocalDate expected) { + for (int ordinal = 0; ordinal < 5; ordinal++) { + for (int day = 1; day <= Month.of(month).length(false); day++) { + LocalDate date = date(year, month, day); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); + assertEquals(test, expected.minusWeeks(ordinal)); + } + } + } + + //----------------------------------------------------------------------- + // firstInMonth() + //----------------------------------------------------------------------- + @Test + public void factory_firstInMonth() { + assertNotNull(TemporalAdjuster.firstInMonth(MONDAY)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_firstInMonth_nullDayOfWeek() { + TemporalAdjuster.firstInMonth(null); + } + + @Test(dataProvider = "dayOfWeekInMonth_positive") + public void test_firstInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { + for (int day = 1; day <= Month.of(month).length(false); day++) { + LocalDate date = date(year, month, day); + LocalDate test = (LocalDate) TemporalAdjuster.firstInMonth(dow).adjustInto(date); + assertEquals(test, expected, "day-of-month=" + day); + } + } + + //----------------------------------------------------------------------- + // lastInMonth() + //----------------------------------------------------------------------- + @Test + public void factory_lastInMonth() { + assertNotNull(TemporalAdjuster.lastInMonth(MONDAY)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_lastInMonth_nullDayOfWeek() { + TemporalAdjuster.lastInMonth(null); + } + + @Test(dataProvider = "dayOfWeekInMonth_negative") + public void test_lastInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { + for (int day = 1; day <= Month.of(month).length(false); day++) { + LocalDate date = date(year, month, day); + LocalDate test = (LocalDate) TemporalAdjuster.lastInMonth(dow).adjustInto(date); + assertEquals(test, expected, "day-of-month=" + day); + } + } + + //----------------------------------------------------------------------- + // next() + //----------------------------------------------------------------------- + @Test + public void factory_next() { + assertNotNull(TemporalAdjuster.next(MONDAY)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_next_nullDayOfWeek() { + TemporalAdjuster.next(null); + } + + @Test + public void test_next() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + + for (DayOfWeek dow : DayOfWeek.values()) { + LocalDate test = (LocalDate) TemporalAdjuster.next(dow).adjustInto(date); + + assertSame(test.getDayOfWeek(), dow, date + " " + test); + + if (test.getYear() == 2007) { + int dayDiff = test.getDayOfYear() - date.getDayOfYear(); + assertTrue(dayDiff > 0 && dayDiff < 8); + } else { + assertSame(month, Month.DECEMBER); + assertTrue(date.getDayOfMonth() > 24); + assertEquals(test.getYear(), 2008); + assertSame(test.getMonth(), Month.JANUARY); + assertTrue(test.getDayOfMonth() < 8); + } + } + } + } + } + + //----------------------------------------------------------------------- + // nextOrSame() + //----------------------------------------------------------------------- + @Test + public void factory_nextOrCurrent() { + assertNotNull(TemporalAdjuster.nextOrSame(MONDAY)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_nextOrCurrent_nullDayOfWeek() { + TemporalAdjuster.nextOrSame(null); + } + + @Test + public void test_nextOrCurrent() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + + for (DayOfWeek dow : DayOfWeek.values()) { + LocalDate test = (LocalDate) TemporalAdjuster.nextOrSame(dow).adjustInto(date); + + assertSame(test.getDayOfWeek(), dow); + + if (test.getYear() == 2007) { + int dayDiff = test.getDayOfYear() - date.getDayOfYear(); + assertTrue(dayDiff < 8); + assertEquals(date.equals(test), date.getDayOfWeek() == dow); + } else { + assertFalse(date.getDayOfWeek() == dow); + assertSame(month, Month.DECEMBER); + assertTrue(date.getDayOfMonth() > 24); + assertEquals(test.getYear(), 2008); + assertSame(test.getMonth(), Month.JANUARY); + assertTrue(test.getDayOfMonth() < 8); + } + } + } + } + } + + //----------------------------------------------------------------------- + // previous() + //----------------------------------------------------------------------- + @Test + public void factory_previous() { + assertNotNull(TemporalAdjuster.previous(MONDAY)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_previous_nullDayOfWeek() { + TemporalAdjuster.previous(null); + } + + @Test + public void test_previous() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + + for (DayOfWeek dow : DayOfWeek.values()) { + LocalDate test = (LocalDate) TemporalAdjuster.previous(dow).adjustInto(date); + + assertSame(test.getDayOfWeek(), dow, date + " " + test); + + if (test.getYear() == 2007) { + int dayDiff = test.getDayOfYear() - date.getDayOfYear(); + assertTrue(dayDiff < 0 && dayDiff > -8, dayDiff + " " + test); + } else { + assertSame(month, Month.JANUARY); + assertTrue(date.getDayOfMonth() < 8); + assertEquals(test.getYear(), 2006); + assertSame(test.getMonth(), Month.DECEMBER); + assertTrue(test.getDayOfMonth() > 24); + } + } + } + } + } + + //----------------------------------------------------------------------- + // previousOrSame() + //----------------------------------------------------------------------- + @Test + public void factory_previousOrCurrent() { + assertNotNull(TemporalAdjuster.previousOrSame(MONDAY)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_previousOrCurrent_nullDayOfWeek() { + TemporalAdjuster.previousOrSame(null); + } + + @Test + public void test_previousOrCurrent() { + for (Month month : Month.values()) { + for (int i = 1; i <= month.length(false); i++) { + LocalDate date = date(2007, month, i); + + for (DayOfWeek dow : DayOfWeek.values()) { + LocalDate test = (LocalDate) TemporalAdjuster.previousOrSame(dow).adjustInto(date); + + assertSame(test.getDayOfWeek(), dow); + + if (test.getYear() == 2007) { + int dayDiff = test.getDayOfYear() - date.getDayOfYear(); + assertTrue(dayDiff <= 0 && dayDiff > -7); + assertEquals(date.equals(test), date.getDayOfWeek() == dow); + } else { + assertFalse(date.getDayOfWeek() == dow); + assertSame(month, Month.JANUARY); + assertTrue(date.getDayOfMonth() < 7); + assertEquals(test.getYear(), 2006); + assertSame(test.getMonth(), Month.DECEMBER); + assertTrue(test.getDayOfMonth() > 25); + } + } + } + } + } + + private LocalDate date(int year, Month month, int day) { + return LocalDate.of(year, month, day); + } + + private LocalDate date(int year, int month, int day) { + return LocalDate.of(year, month, day); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/chrono/TestChronoLocalDate.java 2013-04-11 23:18:56.000000000 -0700 @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.LocalDate; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.testng.annotations.Test; + +/** + * Test chrono local date. + */ +@Test +public class TestChronoLocalDate { + // this class primarily tests whether the generics work OK + + //----------------------------------------------------------------------- + public void test_date_comparator_checkGenerics_ISO() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public void test_date_comparator_checkGenerics_unknown() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public > void test_date_comparator_checkGenerics_unknownExtends() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = (ChronoLocalDate) LocalDate.of(2013, 1, 1); // TODO generics raw type + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public void test_date_comparator_checkGenerics_LocalDate() { + List dates = new ArrayList<>(); + LocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + //----------------------------------------------------------------------- + public void test_date_checkGenerics_genericsMethod() { + Chronology chrono = ThaiBuddhistChronology.INSTANCE; + ChronoLocalDate date = chrono.dateNow(); + // date = processOK(date); // does not compile + date = processClassOK(ThaiBuddhistDate.class); + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + public void test_date_checkGenerics_genericsMethod_concreteType() { + ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE; + ThaiBuddhistDate date = chrono.dateNow(); + date = ThaiBuddhistDate.now(); + date = processOK(date); + date = processClassOK(ThaiBuddhistDate.class); + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + public > void test_date_checkGenerics_genericsMethod_withType() { + Chronology chrono = ThaiBuddhistChronology.INSTANCE; + D date = (D) chrono.dateNow(); + date = processOK(date); + // date = processClassOK(ThaiBuddhistDate.class); // does not compile (correct) + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + private > D dateSupplier() { + return (D) (ChronoLocalDate) ThaiBuddhistChronology.INSTANCE.dateNow(); // TODO raw types + } + + // decent generics signatures that need to work + private > D processOK(D date) { + return date; + } + private > D processClassOK(Class cls) { + return null; + } + + // weird generics signatures that shouldn't really work + private > ChronoLocalDate processWeird(ChronoLocalDate date) { + return date; + } + private > ChronoLocalDate processClassWeird(Class cls) { + return null; + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/chrono/TestChronologyPerf.java 2013-04-11 23:18:56.000000000 -0700 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package test.java.time.chrono; + +import java.time.Duration; +import java.time.chrono.Chronology; +import java.time.temporal.ChronoUnit; +import java.util.Set; + +import org.testng.annotations.Test; + +/** + * Test the speed of initializing all calendars. + */ +public class TestChronologyPerf { + + @Test + public void test_chronologyGetAvailablePerf() { + long start = System.nanoTime(); + Set chronos = Chronology.getAvailableChronologies(); + long end = System.nanoTime(); + Duration d = Duration.of(end - start, ChronoUnit.NANOS); + System.out.printf(" Duration of Chronology.getAvailableChronologies(): %s%n", d); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java 2013-04-11 23:18:57.000000000 -0700 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.chrono; + +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TestJapaneseChronoImpl { + + /** + * Range of years to check consistency with java.util.Calendar + */ + @DataProvider(name="RangeVersusCalendar") + Object[][] provider_rangeVersusCalendar() { + return new Object[][] { + {LocalDate.of(1868, 1, 1), LocalDate.of(2100, 1, 1)}, + }; + } + + //----------------------------------------------------------------------- + // Verify Japanese Calendar matches java.util.Calendar for range + //----------------------------------------------------------------------- + @Test(dataProvider="RangeVersusCalendar") + public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { + Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); + assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); + + Calendar cal = java.util.Calendar.getInstance(locale); + assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type"); + + JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate); + + // Convert to millis and set Japanese Calendar to that start date (at GMT) + OffsetDateTime jodt = OffsetDateTime.of(isoStartDate, LocalTime.MIN, ZoneOffset.UTC); + long millis = jodt.toInstant().toEpochMilli(); + cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); + cal.setTimeInMillis(millis); + + while (jDate.isBefore(isoEndDate)) { + assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); + assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate); + assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate); + + jDate = jDate.plus(1, ChronoUnit.DAYS); + cal.add(Calendar.DAY_OF_MONTH, 1); + } + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java 2013-04-11 23:18:57.000000000 -0700 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2012, 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.chrono; + +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TestThaiBuddhistChronoImpl { + + /** + * Range of years to check consistency with java.util.Calendar + */ + @DataProvider(name="RangeVersusCalendar") + Object[][] provider_rangeVersusCalendar() { + return new Object[][] { + {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, + }; + } + + //----------------------------------------------------------------------- + // Verify ThaiBuddhist Calendar matches java.util.Calendar for range + //----------------------------------------------------------------------- + @Test(dataProvider="RangeVersusCalendar") + public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { + Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist"); + assertEquals(locale.toString(), "th_TH", "Unexpected locale"); + Calendar cal = java.util.Calendar.getInstance(locale); + assertEquals(cal.getCalendarType(), "buddhist", "Unexpected calendar type"); + + ThaiBuddhistDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(isoStartDate); + + cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); + cal.set(Calendar.YEAR, thaiDate.get(ChronoField.YEAR)); + cal.set(Calendar.MONTH, thaiDate.get(ChronoField.MONTH_OF_YEAR) - 1); + cal.set(Calendar.DAY_OF_MONTH, thaiDate.get(ChronoField.DAY_OF_MONTH)); + + while (thaiDate.isBefore(isoEndDate)) { + assertEquals(thaiDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); + assertEquals(thaiDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + thaiDate); + assertEquals(thaiDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + thaiDate); + + thaiDate = thaiDate.plus(1, ChronoUnit.DAYS); + cal.add(Calendar.DAY_OF_MONTH, 1); + } + } + + private String calToString(Calendar cal) { + return String.format("%04d-%02d-%02d", + cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH)); + } + +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java 2013-04-11 23:18:58.000000000 -0700 @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package test.java.time.chrono; + +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.YEAR; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.time.temporal.ValueRange; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Tests for the Umm alQura chronology and data + */ +@Test +public class TestUmmAlQuraChronology { + + @Test + public void test_aliases() { + HijrahChronology hc = (HijrahChronology) Chronology.of("Hijrah"); + assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + hc = (HijrahChronology) Chronology.of("islamic"); + assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + } + + //----------------------------------------------------------------------- + // regular data factory for Umm alQura dates and the corresponding ISO dates + //----------------------------------------------------------------------- + @DataProvider(name = "UmmalQuraVsISODates") + Object[][] data_of_ummalqura() { + return new Object[][]{ + + //{1318, 01, 01, 1900, 04, 30}, + //{1318, 01, 02, 1900, 05, 01}, + + //{1318, 12, 29, 1901, 04, 18}, + //{1319, 01, 01, 1901, 04, 19}, + + //{1433, 12, 29, 2012, 11, 14}, + //{1434, 01, 01, 2012, 11, 15}, + + {1434, 02, 18, 2012, 12, 31}, + {1434, 02, 19, 2013, 01, 01}, + + //{1502, 12, 30, 2079, 10, 25}, + // not in Umm alQura data {1503, 01, 01, 2079, 10, 26}, + + // not in Umm alQura data {1503, 06, 28, 2080, 04, 18}, + // not in Umm alQura data ~/ws/Downloads + }; + } + + @Test(dataProvider="UmmalQuraVsISODates") + public void Test_UmmAlQuraDatesVsISO(int h_year, int h_month, int h_day, int iso_year, int iso_month, int iso_day) { + HijrahDate hd = HijrahDate.of(h_year, h_month, h_day); + LocalDate ld = LocalDate.of(iso_year, iso_month, iso_day); + assertEquals(hd.toEpochDay(), ld.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); + } + + + @Test + public void Test_UmmAlQuraChronoRange() { + HijrahChronology chrono = HijrahChronology.INSTANCE; + ValueRange year = chrono.range(YEAR); + assertEquals(year.getMinimum(), 1432, "Minimum year"); + assertEquals(year.getLargestMinimum(), 1432, "Largest minimum year"); + assertEquals(year.getMaximum(), 1435, "Largest year"); + assertEquals(year.getSmallestMaximum(), 1435, "Smallest Maximum year"); + + ValueRange month = chrono.range(MONTH_OF_YEAR); + assertEquals(month.getMinimum(), 1, "Minimum month"); + assertEquals(month.getLargestMinimum(), 1, "Largest minimum month"); + assertEquals(month.getMaximum(), 12, "Largest month"); + assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month"); + + ValueRange day = chrono.range(DAY_OF_MONTH); + assertEquals(day.getMinimum(), 1, "Minimum day"); + assertEquals(day.getLargestMinimum(), 1, "Largest minimum day"); + assertEquals(day.getMaximum(), 30, "Largest day"); + assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day"); + } + + //----------------------------------------------------------------------- + // regular data factory for dates and the corresponding range values + //----------------------------------------------------------------------- + @DataProvider(name = "dates") + Object[][] data_of_calendars() { + return new Object[][]{ + {HijrahDate.of(1434, 5, 1), 1432, 1435, 1, 12, 1, 29, 30}, + {HijrahDate.of(1434, 6, 1), 1432, 1435, 1, 12, 1, 30, 30}, + }; + } + + @Test(dataProvider="dates") + public void Test_UmmAlQuraRanges(HijrahDate date, + int minYear, int maxYear, + int minMonth, int maxMonth, + int minDay, int maxDay, int maxChronoDay) { + // Check the chronology ranges + HijrahChronology chrono = date.getChronology(); + ValueRange yearRange = chrono.range(YEAR); + assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology"); + assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology"); + assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology"); + assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology"); + + ValueRange monthRange = chrono.range(MONTH_OF_YEAR); + assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology"); + assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology"); + + ValueRange daysRange = chrono.range(DAY_OF_MONTH); + assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology"); + assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology"); + + // Check the date ranges + yearRange = date.range(YEAR); + assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date"); + assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah date"); + assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date"); + assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date"); + + monthRange = date.range(MONTH_OF_YEAR); + assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate"); + assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate"); + + daysRange = date.range(DAY_OF_MONTH); + assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate"); + assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate"); + + } + + @Test + public void test_hijrahDateLimits() { + HijrahChronology chrono = HijrahChronology.INSTANCE; + ValueRange yearRange = chrono.range(YEAR); + ValueRange monthRange = chrono.range(MONTH_OF_YEAR); + ValueRange dayRange = chrono.range(DAY_OF_MONTH); + + HijrahDate xx = chrono.date(1434, 1, 1); + HijrahDate minDate = chrono.date((int)yearRange.getLargestMinimum(), + (int)monthRange.getMinimum(), (int)dayRange.getMinimum()); + try { + HijrahDate before = minDate.minus(1, ChronoUnit.DAYS); + fail("Exception did not occur, minDate: " + minDate + ".minus(1, DAYS) = " + before); + + } catch (DateTimeException ex) { + // ignore, this exception was expected + } + + HijrahDate maxDate = chrono.date((int)yearRange.getSmallestMaximum(), + (int)monthRange.getMaximum(), 1); + int monthLen = maxDate.lengthOfMonth(); + maxDate = maxDate.with(DAY_OF_MONTH, monthLen); + try { + HijrahDate after = maxDate.plus(1, ChronoUnit.DAYS); + fail("Exception did not occur, maxDate: " + maxDate + ".plus(1, DAYS) = " + after); + } catch (DateTimeException ex) { + // ignore, this exception was expected + } + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1317, 12, 29}, + {1317, 12, 30}, + + {1320, 1, 29 + 1}, + {1320, 2, 30 + 1}, + {1320, 3, 29 + 1}, + {1320, 4, 29 + 1}, + {1320, 5, 30 + 1}, + {1320, 6, 29 + 1}, + {1320, 7, 30 + 1}, + {1320, 8, 30 + 1}, + {1320, 9, 29 + 1}, + {1320, 10, 30 + 1}, + {1320, 11, 30 + 1}, + {1320, 12, 30 + 1}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + HijrahChronology.INSTANCE.date(year, month, dom); + } + + void printRange(ValueRange range, Object obj, ChronoField field) { + System.err.printf(" range: min: %d, max: %d; of: %s, field: %s%n", range.getMinimum(), range.getMaximum(), obj.toString(), field.toString()); + } +} --- /dev/null 2013-02-25 15:01:43.885878341 -0800 +++ new/test/java/time/test/java/time/temporal/TestChronoField.java 2013-04-11 23:18:58.000000000 -0700 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.temporal; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; +import java.time.temporal.TemporalField; +import java.time.temporal.WeekFields; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +@Test +public class TestChronoField { + Map fieldMap; + + + @BeforeClass + public void initClass() { + fieldMap = new HashMap<>(); + fieldMap.put(ChronoField.ERA, "era"); + fieldMap.put(ChronoField.YEAR, "year"); + fieldMap.put(ChronoField.MONTH_OF_YEAR, "month"); + fieldMap.put(ChronoField.DAY_OF_MONTH, "day"); + fieldMap.put(ChronoField.AMPM_OF_DAY, "dayperiod"); + fieldMap.put(ChronoField.ALIGNED_WEEK_OF_YEAR, "week"); + fieldMap.put(ChronoField.DAY_OF_WEEK, "weekday"); + fieldMap.put(ChronoField.HOUR_OF_DAY, "hour"); + fieldMap.put(ChronoField.MINUTE_OF_HOUR, "minute"); + fieldMap.put(ChronoField.SECOND_OF_MINUTE, "second"); + fieldMap.put(ChronoField.OFFSET_SECONDS, "zone"); + } + + @DataProvider(name = "localeList") + Locale[] data_localeList() { + return new Locale[] { + Locale.US, + Locale.GERMAN, + Locale.JAPAN, + Locale.ROOT, + }; + } + //----------------------------------------------------------------------- + @DataProvider(name = "localeDisplayNames") + Object[][] data_localeDisplayNames() { + return new Object[][] { + {ChronoField.ERA}, + {ChronoField.YEAR}, + {ChronoField.MONTH_OF_YEAR}, + {ChronoField.DAY_OF_WEEK}, + // {ChronoField.ALIGNED_WEEK_OF_YEAR}, + {ChronoField.DAY_OF_MONTH}, + {ChronoField.AMPM_OF_DAY}, + {ChronoField.HOUR_OF_DAY}, + {ChronoField.MINUTE_OF_HOUR}, + {ChronoField.SECOND_OF_MINUTE}, + }; + } + + @Test + public void test_IsoFields_week_based_year() { + Locale locale = Locale.US; + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName(locale); + assertEquals(name, "Week"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullIsoFields_week_based_year() { + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + } + + @Test + public void test_WeekFields_week_based_year() { + Locale locale = Locale.US; + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName(locale); + assertEquals(name, "Week"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullWeekFields_week_based_year() { + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName((Locale)null); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullLocaleChronoFieldDisplayName() { + ChronoField.YEAR.getDisplayName((Locale)null); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullLocaleTemporalFieldDisplayName() { + // Test the default method in TemporalField using the + // IsoFields.DAY_OF_QUARTER which does not override getDisplayName + IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + } +} --- old/src/share/classes/java/time/chrono/HijrahDeviationReader.java 2013-04-11 23:18:59.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.chrono; - - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.file.FileSystems; -import java.security.AccessController; -import java.text.ParseException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoField; -import java.util.Arrays; -import java.util.function.Consumer; - -/** - * A reader for Hijrah Deviation files. - *

    - * For each Hijrah calendar a deviation file is used - * to modify the initial Hijrah calendar by changing the length of - * individual months. - *

    - * The default location of the deviation files is - * {@code + FILE_SEP + "lib"}. - * The deviation files are named {@code "hijrah_" + ID}. - *

    - * The deviation file for a calendar can be overridden by defining the - * property {@code java.time.chrono.HijrahChronology.File.hijrah_} - * with the full pathname of the deviation file. - *

    - * The deviation file is read line by line: - *

      - *
    • The "#" character begins a comment - - * all characters including and after the "#" on the line are ignored
    • - *
    • Valid lines contain two fields, separated by whitespace, whitespace - * is otherwise ignored.
    • - *
    • The first field is a LocalDate using the format "MMM-dd-yyyy"; - * The LocalDate must be converted to a HijrahDate using - * the {@code islamic} calendar.
    • - *
    • The second field is the offset, +2, +1, -1, -2 as parsed - * by Integer.valueOf to modify the length of the Hijrah month.
    • - *
    • Empty lines are ignore.
    • - *
    • Exceptions are throw for invalid formatted dates and offset, - * and other I/O errors on the file. - *
    - *

    Example:

    - *
    # Deviation data for islamicc calendar
    - * Mar-23-2012 -1
    - * Apr-22-2012 +1
    - * May-21-2012 -1
    - * Dec-14-2012 +1
    - * 
    - * - * @since 1.8 - */ -final class HijrahDeviationReader { - - /** - * Default prefix for name of deviation file; suffix is typeId. - */ - private static final String DEFAULT_CONFIG_FILE_PREFIX = "hijrah_"; - - /** - * Read Hijrah_deviation.cfg file. The config file contains the deviation - * data with format defined in the class javadoc. - * - * @param typeId the name of the calendar - * @param calendarType the calendar type - * @return {@code true} if the file was read and each entry accepted by the - * Consumer; else {@code false} no configuration was done - * - * @throws IOException for zip/jar file handling exception. - * @throws ParseException if the format of the configuration file is wrong. - */ - static boolean readDeviation(String typeId, String calendarType, - Consumer consumer) throws IOException, ParseException { - InputStream is = getConfigFileInputStream(typeId); - if (is != null) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { - String line = ""; - int num = 0; - while ((line = br.readLine()) != null) { - num++; - HijrahChronology.Deviation entry = parseLine(line, num); - if (entry != null) { - consumer.accept(entry); - } - } - } - return true; - } - return false; - } - - /** - * Parse each deviation element. - * - * @param line a line to parse - * @param num line number - * @return an Entry or null if the line is empty. - * @throws ParseException if line has incorrect format. - */ - private static HijrahChronology.Deviation parseLine(final String line, final int num) throws ParseException { - int hash = line.indexOf("#"); - String nocomment = (hash < 0) ? line : line.substring(0, hash); - String[] split = nocomment.split("\\s"); - if (split.length == 0 || split[0].isEmpty()) { - return null; // Nothing to parse - } - if (split.length != 2) { - throw new ParseException("Less than 2 tokens on line : " + line + Arrays.toString(split) + ", split.length: " + split.length, num); - } - - //element [0] is a date - //element [1] is the offset - - LocalDate isoDate = DateTimeFormatter.ofPattern("MMM-dd-yyyy").parse(split[0], LocalDate::from); - int offset = Integer.valueOf(split[1]); - - // Convert date to HijrahDate using the default Islamic Calendar - - HijrahDate hijrahDate = HijrahChronology.INSTANCE.date(isoDate); - - int year = hijrahDate.get(ChronoField.YEAR); - int month = hijrahDate.get(ChronoField.MONTH_OF_YEAR); - return new HijrahChronology.Deviation(year, month, year, month, offset); - } - - - /** - * Return InputStream for deviation configuration file. The default location - * of the deviation file is: - *
    -     *   $CLASSPATH/java/time/calendar
    -     * 
    And the default file name is: - *
    -     *   hijrah_ + typeId + .cfg
    -     * 
    The default location and file name can be overridden by setting - * following two Java system properties. - *
    -     *   Location: java.time.chrono.HijrahDate.deviationConfigDir
    -     *   File name: java.time.chrono.HijrahDate.File. + typeid
    -     * 
    Regarding the file format, see readDeviationConfig() method for - * details. - * - * @param typeId the name of the calendar deviation data - * @return InputStream for file reading. - * @throws IOException for zip/jar file handling exception. - */ - private static InputStream getConfigFileInputStream(final String typeId) throws IOException { - try { - InputStream stream = AccessController - .doPrivileged((java.security.PrivilegedExceptionAction) () -> { - String propFilename = "java.time.chrono.HijrahChronology.File." + typeId; - String filename = System.getProperty(propFilename); - File file = null; - if (filename != null) { - file = new File(filename); - } else { - String libDir = System.getProperty("java.home") + File.separator + "lib"; - try { - libDir = FileSystems.getDefault().getPath(libDir).toRealPath().toString(); - } catch(Exception e) {} - filename = DEFAULT_CONFIG_FILE_PREFIX + typeId + ".cfg"; - file = new File(libDir, filename); - } - - if (file.exists()) { - try { - return new FileInputStream(file); - } catch (IOException ioe) { - throw ioe; - } - } else { - return null; - } - }); - return stream; - } catch (Exception ex) { - ex.printStackTrace(); - // Not working - return null; - } - } -} --- old/src/share/classes/java/time/format/DateTimeBuilder.java 2013-04-11 23:19:00.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,595 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.format; - -import static java.time.temporal.Adjusters.nextOrSame; -import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; -import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; -import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; -import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; -import static java.time.temporal.ChronoField.AMPM_OF_DAY; -import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; -import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; -import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static java.time.temporal.ChronoField.DAY_OF_YEAR; -import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; -import static java.time.temporal.ChronoField.ERA; -import static java.time.temporal.ChronoField.HOUR_OF_AMPM; -import static java.time.temporal.ChronoField.HOUR_OF_DAY; -import static java.time.temporal.ChronoField.MICRO_OF_DAY; -import static java.time.temporal.ChronoField.MICRO_OF_SECOND; -import static java.time.temporal.ChronoField.MILLI_OF_DAY; -import static java.time.temporal.ChronoField.MILLI_OF_SECOND; -import static java.time.temporal.ChronoField.MINUTE_OF_DAY; -import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.NANO_OF_DAY; -import static java.time.temporal.ChronoField.NANO_OF_SECOND; -import static java.time.temporal.ChronoField.SECOND_OF_DAY; -import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; -import static java.time.temporal.ChronoField.YEAR; -import static java.time.temporal.ChronoField.YEAR_OF_ERA; - -import java.time.DateTimeException; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.Chronology; -import java.time.chrono.Era; -import java.time.chrono.IsoChronology; -import java.time.chrono.JapaneseChronology; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * Builder that can holds date and time fields and related date and time objects. - *

    - * This class still needs major revision before JDK1.8 ships. - *

    - * The builder is used to hold onto different elements of date and time. - * It holds two kinds of object: - *

      - *
    • a {@code Map} from {@link TemporalField} to {@code long} value, where the - * value may be outside the valid range for the field - *
    • a list of objects, such as {@code Chronology} or {@code ZoneId} - *

    - * - *

    Specification for implementors

    - * This class is mutable and not thread-safe. - * It should only be used from a single thread. - * - * @since 1.8 - */ -final class DateTimeBuilder - implements TemporalAccessor, Cloneable { - - /** - * The map of other fields. - */ - private Map otherFields; - /** - * The map of date-time fields. - */ - private final EnumMap standardFields = new EnumMap(ChronoField.class); - /** - * The chronology. - */ - private Chronology chrono; - /** - * The zone. - */ - private ZoneId zone; - /** - * The date. - */ - private LocalDate date; - /** - * The time. - */ - private LocalTime time; - - //----------------------------------------------------------------------- - /** - * Creates an empty instance of the builder. - */ - public DateTimeBuilder() { - } - - //----------------------------------------------------------------------- - private Long getFieldValue0(TemporalField field) { - if (field instanceof ChronoField) { - return standardFields.get(field); - } else if (otherFields != null) { - return otherFields.get(field); - } - return null; - } - - /** - * Adds a field-value pair to the builder. - *

    - * This adds a field to the builder. - * If the field is not already present, then the field-value pair is added to the map. - * If the field is already present and it has the same value as that specified, no action occurs. - * If the field is already present and it has a different value to that specified, then - * an exception is thrown. - * - * @param field the field to add, not null - * @param value the value to add, not null - * @return {@code this}, for method chaining - * @throws DateTimeException if the field is already present with a different value - */ - DateTimeBuilder addFieldValue(TemporalField field, long value) { - Objects.requireNonNull(field, "field"); - Long old = getFieldValue0(field); // check first for better error message - if (old != null && old.longValue() != value) { - throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value + ": " + this); - } - return putFieldValue0(field, value); - } - - private DateTimeBuilder putFieldValue0(TemporalField field, long value) { - if (field instanceof ChronoField) { - standardFields.put((ChronoField) field, value); - } else { - if (otherFields == null) { - otherFields = new LinkedHashMap(); - } - otherFields.put(field, value); - } - return this; - } - - //----------------------------------------------------------------------- - void addObject(Chronology chrono) { - this.chrono = chrono; - } - - void addObject(ZoneId zone) { - this.zone = zone; - } - - void addObject(LocalDate date) { - this.date = date; - } - - void addObject(LocalTime time) { - this.time = time; - } - - //----------------------------------------------------------------------- - /** - * Resolves the builder, evaluating the date and time. - *

    - * This examines the contents of the builder and resolves it to produce the best - * available date and time, throwing an exception if a problem occurs. - * Calling this method changes the state of the builder. - * - * @return {@code this}, for method chaining - */ - DateTimeBuilder resolve() { - // handle standard fields - mergeDate(); - mergeTime(); - // TODO: cross validate remaining fields? - return this; - } - - private void mergeDate() { - if (standardFields.containsKey(EPOCH_DAY)) { - checkDate(LocalDate.ofEpochDay(standardFields.remove(EPOCH_DAY))); - return; - } - - Era era = null; - if (chrono == IsoChronology.INSTANCE) { - // normalize fields - if (standardFields.containsKey(EPOCH_MONTH)) { - long em = standardFields.remove(EPOCH_MONTH); - addFieldValue(MONTH_OF_YEAR, (em % 12) + 1); - addFieldValue(YEAR, (em / 12) + 1970); - } - } else { - // TODO: revisit EPOCH_MONTH calculation in non-ISO chronology - // Handle EPOCH_MONTH here for non-ISO Chronology - if (standardFields.containsKey(EPOCH_MONTH)) { - long em = standardFields.remove(EPOCH_MONTH); - ChronoLocalDate chronoDate = chrono.date(LocalDate.ofEpochDay(0L)); - chronoDate = chronoDate.plus(em, ChronoUnit.MONTHS); - LocalDate date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - checkDate(date); - return; - } - List eras = chrono.eras(); - if (!eras.isEmpty()) { - if (standardFields.containsKey(ERA)) { - long index = standardFields.remove(ERA); - era = chrono.eraOf((int) index); - } else { - era = eras.get(eras.size() - 1); // current Era - } - if (standardFields.containsKey(YEAR_OF_ERA)) { - Long y = standardFields.remove(YEAR_OF_ERA); - putFieldValue0(YEAR, y); - } - } - - } - - // build date - if (standardFields.containsKey(YEAR)) { - if (standardFields.containsKey(MONTH_OF_YEAR)) { - if (standardFields.containsKey(DAY_OF_MONTH)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int dom = Math.toIntExact(standardFields.remove(DAY_OF_MONTH)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, dom); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, dom); - } else { - chronoDate = era.date(y, moy, dom); - } - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(ALIGNED_WEEK_OF_MONTH)) { - if (standardFields.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_MONTH)); - int ad = Math.toIntExact(standardFields.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7 + (ad - 1)); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, 1); - } else { - chronoDate = era.date(y, moy, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(DAY_OF_WEEK)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_MONTH)); - int dow = Math.toIntExact(standardFields.remove(DAY_OF_WEEK)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, 1); - } else { - chronoDate = era.date(y, moy, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - } - } - if (standardFields.containsKey(DAY_OF_YEAR)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int doy = Math.toIntExact(standardFields.remove(DAY_OF_YEAR)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.ofYearDay(y, doy); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, doy); - } else { - chronoDate = era.dateYearDay(y, doy); - } - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(ALIGNED_WEEK_OF_YEAR)) { - if (standardFields.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_YEAR)); - int ad = Math.toIntExact(standardFields.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7 + (ad - 1)); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, 1); - } else { - chronoDate = era.dateYearDay(y, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(DAY_OF_WEEK)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_YEAR)); - int dow = Math.toIntExact(standardFields.remove(DAY_OF_WEEK)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, 1); - } else { - chronoDate = era.dateYearDay(y, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - } - } - } - - private void checkDate(LocalDate date) { - addObject(date); - for (ChronoField field : standardFields.keySet()) { - long val1; - try { - val1 = date.getLong(field); - } catch (DateTimeException ex) { - continue; - } - Long val2 = standardFields.get(field); - if (val1 != val2) { - throw new DateTimeException("Conflict found: Field " + field + " " + val1 + " differs from " + field + " " + val2 + " derived from " + date); - } - } - } - - private void mergeTime() { - if (standardFields.containsKey(CLOCK_HOUR_OF_DAY)) { - long ch = standardFields.remove(CLOCK_HOUR_OF_DAY); - addFieldValue(HOUR_OF_DAY, ch == 24 ? 0 : ch); - } - if (standardFields.containsKey(CLOCK_HOUR_OF_AMPM)) { - long ch = standardFields.remove(CLOCK_HOUR_OF_AMPM); - addFieldValue(HOUR_OF_AMPM, ch == 12 ? 0 : ch); - } - if (standardFields.containsKey(AMPM_OF_DAY) && standardFields.containsKey(HOUR_OF_AMPM)) { - long ap = standardFields.remove(AMPM_OF_DAY); - long hap = standardFields.remove(HOUR_OF_AMPM); - addFieldValue(HOUR_OF_DAY, ap * 12 + hap); - } -// if (timeFields.containsKey(HOUR_OF_DAY) && timeFields.containsKey(MINUTE_OF_HOUR)) { -// long hod = timeFields.remove(HOUR_OF_DAY); -// long moh = timeFields.remove(MINUTE_OF_HOUR); -// addFieldValue(MINUTE_OF_DAY, hod * 60 + moh); -// } -// if (timeFields.containsKey(MINUTE_OF_DAY) && timeFields.containsKey(SECOND_OF_MINUTE)) { -// long mod = timeFields.remove(MINUTE_OF_DAY); -// long som = timeFields.remove(SECOND_OF_MINUTE); -// addFieldValue(SECOND_OF_DAY, mod * 60 + som); -// } - if (standardFields.containsKey(NANO_OF_DAY)) { - long nod = standardFields.remove(NANO_OF_DAY); - addFieldValue(SECOND_OF_DAY, nod / 1000_000_000L); - addFieldValue(NANO_OF_SECOND, nod % 1000_000_000L); - } - if (standardFields.containsKey(MICRO_OF_DAY)) { - long cod = standardFields.remove(MICRO_OF_DAY); - addFieldValue(SECOND_OF_DAY, cod / 1000_000L); - addFieldValue(MICRO_OF_SECOND, cod % 1000_000L); - } - if (standardFields.containsKey(MILLI_OF_DAY)) { - long lod = standardFields.remove(MILLI_OF_DAY); - addFieldValue(SECOND_OF_DAY, lod / 1000); - addFieldValue(MILLI_OF_SECOND, lod % 1000); - } - if (standardFields.containsKey(SECOND_OF_DAY)) { - long sod = standardFields.remove(SECOND_OF_DAY); - addFieldValue(HOUR_OF_DAY, sod / 3600); - addFieldValue(MINUTE_OF_HOUR, (sod / 60) % 60); - addFieldValue(SECOND_OF_MINUTE, sod % 60); - } - if (standardFields.containsKey(MINUTE_OF_DAY)) { - long mod = standardFields.remove(MINUTE_OF_DAY); - addFieldValue(HOUR_OF_DAY, mod / 60); - addFieldValue(MINUTE_OF_HOUR, mod % 60); - } - -// long sod = nod / 1000_000_000L; -// addFieldValue(HOUR_OF_DAY, sod / 3600); -// addFieldValue(MINUTE_OF_HOUR, (sod / 60) % 60); -// addFieldValue(SECOND_OF_MINUTE, sod % 60); -// addFieldValue(NANO_OF_SECOND, nod % 1000_000_000L); - if (standardFields.containsKey(MILLI_OF_SECOND) && standardFields.containsKey(MICRO_OF_SECOND)) { - long los = standardFields.remove(MILLI_OF_SECOND); - long cos = standardFields.get(MICRO_OF_SECOND); - addFieldValue(MICRO_OF_SECOND, los * 1000 + (cos % 1000)); - } - - Long hod = standardFields.get(HOUR_OF_DAY); - Long moh = standardFields.get(MINUTE_OF_HOUR); - Long som = standardFields.get(SECOND_OF_MINUTE); - Long nos = standardFields.get(NANO_OF_SECOND); - if (hod != null) { - int hodVal = Math.toIntExact(hod); - if (moh != null) { - int mohVal = Math.toIntExact(moh); - if (som != null) { - int somVal = Math.toIntExact(som); - if (nos != null) { - int nosVal = Math.toIntExact(nos); - addObject(LocalTime.of(hodVal, mohVal, somVal, nosVal)); - } else { - addObject(LocalTime.of(hodVal, mohVal, somVal)); - } - } else { - addObject(LocalTime.of(hodVal, mohVal)); - } - } else { - addObject(LocalTime.of(hodVal, 0)); - } - } - } - - //----------------------------------------------------------------------- - @Override - public boolean isSupported(TemporalField field) { - if (field == null) { - return false; - } - return standardFields.containsKey(field) || - (otherFields != null && otherFields.containsKey(field)) || - (date != null && date.isSupported(field)) || - (time != null && time.isSupported(field)); - } - - @Override - public long getLong(TemporalField field) { - Objects.requireNonNull(field, "field"); - Long value = getFieldValue0(field); - if (value == null) { - if (date != null && date.isSupported(field)) { - return date.getLong(field); - } - if (time != null && time.isSupported(field)) { - return time.getLong(field); - } - throw new DateTimeException("Field not found: " + field); - } - return value; - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { - return (R) zone; - } else if (query == Queries.chronology()) { - return (R) chrono; - } else if (query == Queries.localDate()) { - return (R) date; - } else if (query == Queries.localTime()) { - return (R) time; - } else if (query == Queries.zone() || query == Queries.offset()) { - return query.queryFrom(this); - } else if (query == Queries.precision()) { - return null; // not a complete date/time - } - // inline TemporalAccessor.super.query(query) as an optimization - // non-JDK classes are not permitted to make this optimization - return query.queryFrom(this); - } - - //----------------------------------------------------------------------- - @Override - public String toString() { - StringBuilder buf = new StringBuilder(128); - buf.append("DateTimeBuilder["); - Map fields = new HashMap<>(); - fields.putAll(standardFields); - if (otherFields != null) { - fields.putAll(otherFields); - } - if (fields.size() > 0) { - buf.append("fields=").append(fields); - } - buf.append(", ").append(chrono); - buf.append(", ").append(zone); - buf.append(", ").append(date); - buf.append(", ").append(time); - buf.append(']'); - return buf.toString(); - } - -} --- old/src/share/classes/java/time/format/DateTimeFormatStyleProvider.java 2013-04-11 23:19:00.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.format; - -import java.text.SimpleDateFormat; -import java.time.chrono.Chronology; -import java.util.Locale; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import sun.util.locale.provider.LocaleProviderAdapter; -import sun.util.locale.provider.LocaleResources; - -/** - * A provider to obtain date-time formatters for a style. - *

    - * - *

    Specification for implementors

    - * This implementation is based on extraction of data from a {@link SimpleDateFormat}. - * This class is immutable and thread-safe. - * This Implementations caches the returned formatters. - * - * @since 1.8 - */ -final class DateTimeFormatStyleProvider { - // TODO: Better implementation based on CLDR - - /** Cache of formatters. */ - private static final ConcurrentMap FORMATTER_CACHE = new ConcurrentHashMap<>(16, 0.75f, 2); - - private DateTimeFormatStyleProvider() {} - - /** - * Gets an Instance of the provider of format styles. - * - * @return the provider, not null - */ - static DateTimeFormatStyleProvider getInstance() { - return new DateTimeFormatStyleProvider(); - } - - /** - * Gets a localized date, time or date-time formatter. - *

    - * The formatter will be the most appropriate to use for the date and time style in the locale. - * For example, some locales will use the month name while others will use the number. - * - * @param dateStyle the date formatter style to obtain, null to obtain a time formatter - * @param timeStyle the time formatter style to obtain, null to obtain a date formatter - * @param chrono the chronology to use, not null - * @param locale the locale to use, not null - * @return the date-time formatter, not null - * @throws IllegalArgumentException if both format styles are null or if the locale is not recognized - */ - public DateTimeFormatter getFormatter( - FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { - if (dateStyle == null && timeStyle == null) { - throw new IllegalArgumentException("Date and Time style must not both be null"); - } - String key = chrono.getId() + '|' + locale.toString() + '|' + dateStyle + timeStyle; - Object cached = FORMATTER_CACHE.get(key); - if (cached != null) { - return (DateTimeFormatter) cached; - } - - LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); - String pattern = lr.getCldrDateTimePattern(convertStyle(timeStyle), convertStyle(dateStyle), - chrono.getCalendarType()); - DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(locale); - FORMATTER_CACHE.putIfAbsent(key, formatter); - return formatter; - } - - /** - * Converts the enum style to the java.util.Calendar style. Standalone styles - * are not supported. - * - * @param style the enum style - * @return the int style, or -1 if style is null, indicating unrequired - */ - private int convertStyle(FormatStyle style) { - if (style == null) { - return -1; - } - return style.ordinal(); // indices happen to align - } - -} --- old/src/share/classes/java/time/temporal/Adjusters.java 2013-04-11 23:19:00.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,502 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.temporal; - -import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static java.time.temporal.ChronoField.DAY_OF_YEAR; -import static java.time.temporal.ChronoUnit.DAYS; -import static java.time.temporal.ChronoUnit.MONTHS; -import static java.time.temporal.ChronoUnit.YEARS; - -import java.time.DayOfWeek; -import java.util.Objects; - -/** - * Common implementations of {@code TemporalAdjuster}. - *

    - * This class provides common implementations of {@link TemporalAdjuster}. - * They are especially useful to document the intent of business logic and - * often link well to requirements. - * For example, these two pieces of code do the same thing, but the second - * one is clearer (assuming that there is a static import of this class): - *

    - *  // direct manipulation
    - *  date.withDayOfMonth(1).plusMonths(1).minusDays(1);
    - *  // use of an adjuster from this class
    - *  date.with(lastDayOfMonth());
    - * 
    - * There are two equivalent ways of using a {@code TemporalAdjuster}. - * The first is to invoke the method on the interface directly. - * The second is to use {@link Temporal#with(TemporalAdjuster)}: - *
    - *   // these two lines are equivalent, but the second approach is recommended
    - *   dateTime = adjuster.adjustInto(dateTime);
    - *   dateTime = dateTime.with(adjuster);
    - * 
    - * It is recommended to use the second approach, {@code with(TemporalAdjuster)}, - * as it is a lot clearer to read in code. - * - *

    Specification for implementors

    - * This is a thread-safe utility class. - * All returned adjusters are immutable and thread-safe. - * - * @since 1.8 - */ -public final class Adjusters { - - /** - * Private constructor since this is a utility class. - */ - private Adjusters() { - } - - //----------------------------------------------------------------------- - /** - * Returns the "first day of month" adjuster, which returns a new date set to - * the first day of the current month. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2011-01-01.
    - * The input 2011-02-15 will return 2011-02-01. - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  temporal.with(DAY_OF_MONTH, 1);
    -     * 
    - * - * @return the first day-of-month adjuster, not null - */ - public static TemporalAdjuster firstDayOfMonth() { - return Impl.FIRST_DAY_OF_MONTH; - } - - /** - * Returns the "last day of month" adjuster, which returns a new date set to - * the last day of the current month. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2011-01-31.
    - * The input 2011-02-15 will return 2011-02-28.
    - * The input 2012-02-15 will return 2012-02-29 (leap year).
    - * The input 2011-04-15 will return 2011-04-30. - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  long lastDay = temporal.range(DAY_OF_MONTH).getMaximum();
    -     *  temporal.with(DAY_OF_MONTH, lastDay);
    -     * 
    - * - * @return the last day-of-month adjuster, not null - */ - public static TemporalAdjuster lastDayOfMonth() { - return Impl.LAST_DAY_OF_MONTH; - } - - /** - * Returns the "first day of next month" adjuster, which returns a new date set to - * the first day of the next month. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2011-02-01.
    - * The input 2011-02-15 will return 2011-03-01. - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS);
    -     * 
    - * - * @return the first day of next month adjuster, not null - */ - public static TemporalAdjuster firstDayOfNextMonth() { - return Impl.FIRST_DAY_OF_NEXT_MONTH; - } - - //----------------------------------------------------------------------- - /** - * Returns the "first day of year" adjuster, which returns a new date set to - * the first day of the current year. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2011-01-01.
    - * The input 2011-02-15 will return 2011-01-01.
    - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  temporal.with(DAY_OF_YEAR, 1);
    -     * 
    - * - * @return the first day-of-year adjuster, not null - */ - public static TemporalAdjuster firstDayOfYear() { - return Impl.FIRST_DAY_OF_YEAR; - } - - /** - * Returns the "last day of year" adjuster, which returns a new date set to - * the last day of the current year. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2011-12-31.
    - * The input 2011-02-15 will return 2011-12-31.
    - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  long lastDay = temporal.range(DAY_OF_YEAR).getMaximum();
    -     *  temporal.with(DAY_OF_YEAR, lastDay);
    -     * 
    - * - * @return the last day-of-year adjuster, not null - */ - public static TemporalAdjuster lastDayOfYear() { - return Impl.LAST_DAY_OF_YEAR; - } - - /** - * Returns the "first day of next year" adjuster, which returns a new date set to - * the first day of the next year. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 will return 2012-01-01. - *

    - * The behavior is suitable for use with most calendar systems. - * It is equivalent to: - *

    -     *  temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS);
    -     * 
    - * - * @return the first day of next month adjuster, not null - */ - public static TemporalAdjuster firstDayOfNextYear() { - return Impl.FIRST_DAY_OF_NEXT_YEAR; - } - - //----------------------------------------------------------------------- - /** - * Enum implementing the adjusters. - */ - private static class Impl implements TemporalAdjuster { - /** First day of month adjuster. */ - private static final Impl FIRST_DAY_OF_MONTH = new Impl(0); - /** Last day of month adjuster. */ - private static final Impl LAST_DAY_OF_MONTH = new Impl(1); - /** First day of next month adjuster. */ - private static final Impl FIRST_DAY_OF_NEXT_MONTH = new Impl(2); - /** First day of year adjuster. */ - private static final Impl FIRST_DAY_OF_YEAR = new Impl(3); - /** Last day of year adjuster. */ - private static final Impl LAST_DAY_OF_YEAR = new Impl(4); - /** First day of next month adjuster. */ - private static final Impl FIRST_DAY_OF_NEXT_YEAR = new Impl(5); - /** The ordinal. */ - private final int ordinal; - private Impl(int ordinal) { - this.ordinal = ordinal; - } - @Override - public Temporal adjustInto(Temporal temporal) { - switch (ordinal) { - case 0: return temporal.with(DAY_OF_MONTH, 1); - case 1: return temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); - case 2: return temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS); - case 3: return temporal.with(DAY_OF_YEAR, 1); - case 4: return temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum()); - case 5: return temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS); - } - throw new IllegalStateException("Unreachable"); - } - } - - //----------------------------------------------------------------------- - /** - * Returns the first in month adjuster, which returns a new date - * in the same month with the first matching day-of-week. - * This is used for expressions like 'first Tuesday in March'. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-12-15 for (MONDAY) will return 2011-12-05.
    - * The input 2011-12-15 for (FRIDAY) will return 2011-12-02.
    - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields - * and the {@code DAYS} unit, and assumes a seven day week. - * - * @param dayOfWeek the day-of-week, not null - * @return the first in month adjuster, not null - */ - public static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(1, dayOfWeek); - } - - /** - * Returns the last in month adjuster, which returns a new date - * in the same month with the last matching day-of-week. - * This is used for expressions like 'last Tuesday in March'. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-12-15 for (MONDAY) will return 2011-12-26.
    - * The input 2011-12-15 for (FRIDAY) will return 2011-12-30.
    - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields - * and the {@code DAYS} unit, and assumes a seven day week. - * - * @param dayOfWeek the day-of-week, not null - * @return the first in month adjuster, not null - */ - public static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(-1, dayOfWeek); - } - - /** - * Returns the day-of-week in month adjuster, which returns a new date - * in the same month with the ordinal day-of-week. - * This is used for expressions like the 'second Tuesday in March'. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-12-15 for (1,TUESDAY) will return 2011-12-06.
    - * The input 2011-12-15 for (2,TUESDAY) will return 2011-12-13.
    - * The input 2011-12-15 for (3,TUESDAY) will return 2011-12-20.
    - * The input 2011-12-15 for (4,TUESDAY) will return 2011-12-27.
    - * The input 2011-12-15 for (5,TUESDAY) will return 2012-01-03.
    - * The input 2011-12-15 for (-1,TUESDAY) will return 2011-12-27 (last in month).
    - * The input 2011-12-15 for (-4,TUESDAY) will return 2011-12-06 (3 weeks before last in month).
    - * The input 2011-12-15 for (-5,TUESDAY) will return 2011-11-29 (4 weeks before last in month).
    - * The input 2011-12-15 for (0,TUESDAY) will return 2011-11-29 (last in previous month).
    - *

    - * For a positive or zero ordinal, the algorithm is equivalent to finding the first - * day-of-week that matches within the month and then adding a number of weeks to it. - * For a negative ordinal, the algorithm is equivalent to finding the last - * day-of-week that matches within the month and then subtracting a number of weeks to it. - * The ordinal number of weeks is not validated and is interpreted leniently - * according to this algorithm. This definition means that an ordinal of zero finds - * the last matching day-of-week in the previous month. - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields - * and the {@code DAYS} unit, and assumes a seven day week. - * - * @param ordinal the week within the month, unbound but typically from -5 to 5 - * @param dayOfWeek the day-of-week, not null - * @return the day-of-week in month adjuster, not null - * @throws IllegalArgumentException if the ordinal is invalid - */ - public static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(ordinal, dayOfWeek); - } - - /** - * Class implementing day-of-week in month adjuster. - */ - private static final class DayOfWeekInMonth implements TemporalAdjuster { - /** The ordinal. */ - private final int ordinal; - /** The day-of-week value, from 1 to 7. */ - private final int dowValue; - - private DayOfWeekInMonth(int ordinal, DayOfWeek dow) { - super(); - this.ordinal = ordinal; - this.dowValue = dow.getValue(); - } - @Override - public Temporal adjustInto(Temporal temporal) { - if (ordinal >= 0) { - Temporal temp = temporal.with(DAY_OF_MONTH, 1); - int curDow = temp.get(DAY_OF_WEEK); - int dowDiff = (dowValue - curDow + 7) % 7; - dowDiff += (ordinal - 1L) * 7L; // safe from overflow - return temp.plus(dowDiff, DAYS); - } else { - Temporal temp = temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); - int curDow = temp.get(DAY_OF_WEEK); - int daysDiff = dowValue - curDow; - daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff)); - daysDiff -= (-ordinal - 1L) * 7L; // safe from overflow - return temp.plus(daysDiff, DAYS); - } - } - } - - //----------------------------------------------------------------------- - /** - * Returns the next day-of-week adjuster, which adjusts the date to the - * first occurrence of the specified day-of-week after the date being adjusted. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    - * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    - * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-22 (seven days later). - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, - * and assumes a seven day week. - * - * @param dayOfWeek the day-of-week to move the date to, not null - * @return the next day-of-week adjuster, not null - */ - public static TemporalAdjuster next(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(2, dayOfWeek); - } - - /** - * Returns the next-or-same day-of-week adjuster, which adjusts the date to the - * first occurrence of the specified day-of-week after the date being adjusted - * unless it is already on that day in which case the same object is returned. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    - * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    - * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, - * and assumes a seven day week. - * - * @param dayOfWeek the day-of-week to check for or move the date to, not null - * @return the next-or-same day-of-week adjuster, not null - */ - public static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(0, dayOfWeek); - } - - /** - * Returns the previous day-of-week adjuster, which adjusts the date to the - * first occurrence of the specified day-of-week before the date being adjusted. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    - * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    - * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-08 (seven days earlier). - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, - * and assumes a seven day week. - * - * @param dayOfWeek the day-of-week to move the date to, not null - * @return the previous day-of-week adjuster, not null - */ - public static TemporalAdjuster previous(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(3, dayOfWeek); - } - - /** - * Returns the previous-or-same day-of-week adjuster, which adjusts the date to the - * first occurrence of the specified day-of-week before the date being adjusted - * unless it is already on that day in which case the same object is returned. - *

    - * The ISO calendar system behaves as follows:
    - * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    - * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    - * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). - *

    - * The behavior is suitable for use with most calendar systems. - * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, - * and assumes a seven day week. - * - * @param dayOfWeek the day-of-week to check for or move the date to, not null - * @return the previous-or-same day-of-week adjuster, not null - */ - public static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(1, dayOfWeek); - } - - /** - * Implementation of next, previous or current day-of-week. - */ - private static final class RelativeDayOfWeek implements TemporalAdjuster { - /** Whether the current date is a valid answer. */ - private final int relative; - /** The day-of-week value, from 1 to 7. */ - private final int dowValue; - - private RelativeDayOfWeek(int relative, DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - this.relative = relative; - this.dowValue = dayOfWeek.getValue(); - } - - @Override - public Temporal adjustInto(Temporal temporal) { - int calDow = temporal.get(DAY_OF_WEEK); - if (relative < 2 && calDow == dowValue) { - return temporal; - } - if ((relative & 1) == 0) { - int daysDiff = calDow - dowValue; - return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); - } else { - int daysDiff = dowValue - calDow; - return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); - } - } - } - -} --- old/src/share/classes/java/time/temporal/Queries.java 2013-04-11 23:19:01.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.temporal; - -import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.NANO_OF_DAY; -import static java.time.temporal.ChronoField.OFFSET_SECONDS; - -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.chrono.Chronology; - -/** - * Common implementations of {@code TemporalQuery}. - *

    - * This class provides common implementations of {@link TemporalQuery}. - * These queries are primarily used as optimizations, allowing the internals - * of other objects to be extracted effectively. Note that application code - * can also use the {@code from(TemporalAccessor)} method on most temporal - * objects as a method reference matching the query interface, such as - * {@code LocalDate::from} and {@code ZoneId::from}. - *

    - * There are two equivalent ways of using a {@code TemporalQuery}. - * The first is to invoke the method on the interface directly. - * The second is to use {@link TemporalAccessor#query(TemporalQuery)}: - *

    - *   // these two lines are equivalent, but the second approach is recommended
    - *   dateTime = query.queryFrom(dateTime);
    - *   dateTime = dateTime.query(query);
    - * 
    - * It is recommended to use the second approach, {@code query(TemporalQuery)}, - * as it is a lot clearer to read in code. - * - *

    Specification for implementors

    - * This is a thread-safe utility class. - * All returned adjusters are immutable and thread-safe. - * - * @since 1.8 - */ -public final class Queries { - // note that it is vital that each method supplies a constant, not a - // calculated value, as they will be checked for using == - // it is also vital that each constant is different (due to the == checking) - // as such, alterations to use lambdas must be done with extreme care - - /** - * Private constructor since this is a utility class. - */ - private Queries() { - } - - //----------------------------------------------------------------------- - // special constants should be used to extract information from a TemporalAccessor - // that cannot be derived in other ways - // Javadoc added here, so as to pretend they are more normal than they really are - - /** - * A strict query for the {@code ZoneId}. - *

    - * This queries a {@code TemporalAccessor} for the zone. - * The zone is only returned if the date-time conceptually contains a {@code ZoneId}. - * It will not be returned if the date-time only conceptually has an {@code ZoneOffset}. - * Thus a {@link ZonedDateTime} will return the result of {@code getZone()}, - * but an {@link OffsetDateTime} will return null. - *

    - * In most cases, applications should use {@link #ZONE} as this query is too strict. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns null
    - * {@code LocalTime} returns null
    - * {@code LocalDateTime} returns null
    - * {@code ZonedDateTime} returns the associated zone
    - * {@code OffsetTime} returns null
    - * {@code OffsetDateTime} returns null
    - * {@code ChronoLocalDate} returns null
    - * {@code ChronoLocalDateTime} returns null
    - * {@code ChronoZonedDateTime} returns the associated zone
    - * {@code Era} returns null
    - * {@code DayOfWeek} returns null
    - * {@code Month} returns null
    - * {@code Year} returns null
    - * {@code YearMonth} returns null
    - * {@code MonthDay} returns null
    - * {@code ZoneOffset} returns null
    - * {@code Instant} returns null
    - * - * @return a query that can obtain the zone ID of a temporal, not null - */ - public static final TemporalQuery zoneId() { - return ZONE_ID; - } - static final TemporalQuery ZONE_ID = (temporal) -> { - return temporal.query(ZONE_ID); - }; - - /** - * A query for the {@code Chronology}. - *

    - * This queries a {@code TemporalAccessor} for the chronology. - * If the target {@code TemporalAccessor} represents a date, or part of a date, - * then it should return the chronology that the date is expressed in. - * As a result of this definition, objects only representing time, such as - * {@code LocalTime}, will return null. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns {@code IsoChronology.INSTANCE}
    - * {@code LocalTime} returns null (does not represent a date)
    - * {@code LocalDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code ZonedDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code OffsetTime} returns null (does not represent a date)
    - * {@code OffsetDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code ChronoLocalDate} returns the associated chronology
    - * {@code ChronoLocalDateTime} returns the associated chronology
    - * {@code ChronoZonedDateTime} returns the associated chronology
    - * {@code Era} returns the associated chronology
    - * {@code DayOfWeek} returns null (shared across chronologies)
    - * {@code Month} returns {@code IsoChronology.INSTANCE}
    - * {@code Year} returns {@code IsoChronology.INSTANCE}
    - * {@code YearMonth} returns {@code IsoChronology.INSTANCE}
    - * {@code MonthDay} returns null {@code IsoChronology.INSTANCE}
    - * {@code ZoneOffset} returns null (does not represent a date)
    - * {@code Instant} returns null (does not represent a date)
    - *

    - * The method {@link Chronology#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code Chronology::from}. - * That method is equivalent to this query, except that it throws an - * exception if a chronology cannot be obtained. - * - * @return a query that can obtain the chronology of a temporal, not null - */ - public static final TemporalQuery chronology() { - return CHRONO; - } - static final TemporalQuery CHRONO = (temporal) -> { - return temporal.query(CHRONO); - }; - - /** - * A query for the smallest supported unit. - *

    - * This queries a {@code TemporalAccessor} for the time precision. - * If the target {@code TemporalAccessor} represents a consistent or complete date-time, - * date or time then this must return the smallest precision actually supported. - * Note that fields such as {@code NANO_OF_DAY} and {@code NANO_OF_SECOND} - * are defined to always return ignoring the precision, thus this is the only - * way to find the actual smallest supported unit. - * For example, were {@code GregorianCalendar} to implement {@code TemporalAccessor} - * it would return a precision of {@code MILLIS}. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns {@code DAYS}
    - * {@code LocalTime} returns {@code NANOS}
    - * {@code LocalDateTime} returns {@code NANOS}
    - * {@code ZonedDateTime} returns {@code NANOS}
    - * {@code OffsetTime} returns {@code NANOS}
    - * {@code OffsetDateTime} returns {@code NANOS}
    - * {@code ChronoLocalDate} returns {@code DAYS}
    - * {@code ChronoLocalDateTime} returns {@code NANOS}
    - * {@code ChronoZonedDateTime} returns {@code NANOS}
    - * {@code Era} returns {@code ERAS}
    - * {@code DayOfWeek} returns {@code DAYS}
    - * {@code Month} returns {@code MONTHS}
    - * {@code Year} returns {@code YEARS}
    - * {@code YearMonth} returns {@code MONTHS}
    - * {@code MonthDay} returns null (does not represent a complete date or time)
    - * {@code ZoneOffset} returns null (does not represent a date or time)
    - * {@code Instant} returns {@code NANOS}
    - * - * @return a query that can obtain the precision of a temporal, not null - */ - public static final TemporalQuery precision() { - return PRECISION; - } - static final TemporalQuery PRECISION = (temporal) -> { - return temporal.query(PRECISION); - }; - - //----------------------------------------------------------------------- - // non-special constants are standard queries that derive information from other information - /** - * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. - *

    - * This queries a {@code TemporalAccessor} for the zone. - * It first tries to obtain the zone, using {@link #zoneId()}. - * If that is not found it tries to obtain the {@link #offset()}. - * Thus a {@link ZonedDateTime} will return the result of {@code getZone()}, - * while an {@link OffsetDateTime} will return the result of {@code getOffset()}. - *

    - * In most cases, applications should use this query rather than {@code #zoneId()}. - *

    - * The method {@link ZoneId#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code ZoneId::from}. - * That method is equivalent to this query, except that it throws an - * exception if a zone cannot be obtained. - * - * @return a query that can obtain the zone ID or offset of a temporal, not null - */ - public static final TemporalQuery zone() { - return ZONE; - } - static final TemporalQuery ZONE = (temporal) -> { - ZoneId zone = temporal.query(ZONE_ID); - return (zone != null ? zone : temporal.query(OFFSET)); - }; - - /** - * A query for {@code ZoneOffset} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the offset. The query will return null if the temporal - * object cannot supply an offset. - *

    - * The query implementation examines the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} - * field and uses it to create a {@code ZoneOffset}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code ZoneOffset::from}. - * This query and {@code ZoneOffset::from} will return the same result if the - * temporal object contains an offset. If the temporal object does not contain - * an offset, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the offset of a temporal, not null - */ - public static final TemporalQuery offset() { - return OFFSET; - } - static final TemporalQuery OFFSET = (temporal) -> { - if (temporal.isSupported(OFFSET_SECONDS)) { - return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS)); - } - return null; - }; - - /** - * A query for {@code LocalDate} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the local date. The query will return null if the temporal - * object cannot supply a local date. - *

    - * The query implementation examines the {@link ChronoField#EPOCH_DAY EPOCH_DAY} - * field and uses it to create a {@code LocalDate}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code LocalDate::from}. - * This query and {@code LocalDate::from} will return the same result if the - * temporal object contains a date. If the temporal object does not contain - * a date, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the date of a temporal, not null - */ - public static final TemporalQuery localDate() { - return LOCAL_DATE; - } - static final TemporalQuery LOCAL_DATE = (temporal) -> { - if (temporal.isSupported(EPOCH_DAY)) { - return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY)); - } - return null; - }; - - /** - * A query for {@code LocalTime} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the local time. The query will return null if the temporal - * object cannot supply a local time. - *

    - * The query implementation examines the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} - * field and uses it to create a {@code LocalTime}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code LocalTime::from}. - * This query and {@code LocalTime::from} will return the same result if the - * temporal object contains a time. If the temporal object does not contain - * a time, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the time of a temporal, not null - */ - public static final TemporalQuery localTime() { - return LOCAL_TIME; - } - static final TemporalQuery LOCAL_TIME = (temporal) -> { - if (temporal.isSupported(NANO_OF_DAY)) { - return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY)); - } - return null; - }; - -} --- old/test/java/time/tck/java/time/TestChronology.java 2013-04-11 23:19:01.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Locale; -import java.util.Set; - -import java.time.chrono.Chronology; -import java.time.temporal.ChronoField; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test Chronology class. - */ -@Test -public class TestChronology { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Object[][] data_of_calendars() { - return new Object[][] { - {"Hijrah", "islamicc", "Hijrah calendar"}, - {"ISO", "iso8601", "ISO calendar"}, - {"Japanese", "japanese", "Japanese calendar"}, - {"Minguo", "roc", "Minguo Calendar"}, - {"ThaiBuddhist", "buddhist", "ThaiBuddhist calendar"}, - }; - } - - @Test(dataProvider = "calendars") - public void test_getters(String chronoId, String calendarSystemType, String description) { - Chronology chrono = Chronology.of(chronoId); - assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); - assertEquals(chrono.getId(), chronoId); - assertEquals(chrono.getCalendarType(), calendarSystemType); - } - - @Test(dataProvider = "calendars") - public void test_required_calendars(String chronoId, String calendarSystemType, String description) { - Chronology chrono = Chronology.of(chronoId); - assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); - chrono = Chronology.of(calendarSystemType); - assertNotNull(chrono, "Required calendar not found by type: " + chronoId); - Set cals = Chronology.getAvailableChronologies(); - assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars"); - } - - @Test(groups="tck") - public void test_calendar_list() { - Set chronos = Chronology.getAvailableChronologies(); - assertNotNull(chronos, "Required list of calendars must be non-null"); - for (Chronology chrono : chronos) { - Chronology lookup = Chronology.of(chrono.getId()); - assertNotNull(lookup, "Required calendar not found: " + chrono); - } - assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size() - + ", expected >= " + data_of_calendars().length); - } - - /** - * Compute the number of days from the Epoch and compute the date from the number of days. - */ - @Test(dataProvider = "calendars", groups="tck") - public void test_epoch(String name, String alias, String description) { - Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded - ChronoLocalDate date1 = chrono.dateNow(); - long epoch1 = date1.getLong(ChronoField.EPOCH_DAY); - ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1); - assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2); - long epoch2 = date1.getLong(ChronoField.EPOCH_DAY); - assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2); - } - - //----------------------------------------------------------------------- - // locale based lookup - //----------------------------------------------------------------------- - @DataProvider(name = "calendarsystemtype") - Object[][] data_CalendarType() { - return new Object[][] { - {HijrahChronology.INSTANCE, "islamicc"}, - {IsoChronology.INSTANCE, "iso8601"}, - {JapaneseChronology.INSTANCE, "japanese"}, - {MinguoChronology.INSTANCE, "roc"}, - {ThaiBuddhistChronology.INSTANCE, "buddhist"}, - }; - } - - @Test(dataProvider = "calendarsystemtype", groups="tck") - public void test_getCalendarType(Chronology chrono, String calendarType) { - assertEquals(chrono.getCalendarType(), calendarType); - } - - @Test(dataProvider = "calendarsystemtype", groups="tck") - public void test_lookupLocale(Chronology chrono, String calendarType) { - Locale locale = new Locale.Builder().setLanguage("en").setRegion("CA").setUnicodeLocaleKeyword("ca", calendarType).build(); - assertEquals(Chronology.ofLocale(locale), chrono); - } - - - //----------------------------------------------------------------------- - // serialization; serialize and check each calendar system - //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}, dataProvider = "calendarsystemtype") - public void test_chronoSerializationSingleton(Chronology chrono, String calendarType) throws Exception { - Chronology orginal = chrono; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - Chronology ser = (Chronology) in.readObject(); - assertSame(ser, chrono, "Deserialized Chronology is not the singleton serialized"); - } - -} --- old/test/java/time/tck/java/time/chrono/TestChronoLocalDate.java 2013-04-11 23:19:02.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,460 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for all built-in chronologies. - */ -@Test -public class TestChronoLocalDate { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {HijrahChronology.INSTANCE}, - {IsoChronology.INSTANCE}, - {JapaneseChronology.INSTANCE}, - {MinguoChronology.INSTANCE}, - {ThaiBuddhistChronology.INSTANCE}}; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAdjuster adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.plus(1, adjuster); - Assert.fail("TemporalUnit.doAdd plus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.minus(1, adjuster); - Assert.fail("TemporalUnit.doAdd minus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalField adjuster = new FixedTemporalField(date2); - if (chrono != chrono2) { - try { - date.with(adjuster, 1); - Assert.fail("TemporalField doSet should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster, 1); - assertEquals(result, date2, "TemporalField doSet failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual, DATE_COMPARATOR - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_date_comparisons(Chronology chrono) { - List dates = new ArrayList<>(); - - ChronoLocalDate date = chrono.date(LocalDate.of(1900, 1, 1)); - - // Insert dates in order, no duplicates - dates.add(date.minus(1000, ChronoUnit.YEARS)); - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - dates.add(date.plus(1000, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List> otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDate d : dates) { - otherDates.add(chrono2.date(d)); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDate a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDate b = otherDates.get(j); - int cmp = ChronoLocalDate.DATE_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - //----------------------------------------------------------------------- - // Test Serialization of Calendars - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoSerialization(Chronology chrono) throws Exception { - LocalDate ref = LocalDate.of(1900, 1, 5); - ChronoLocalDate orginal = chrono.date(ref); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") - ChronoLocalDate ser = (ChronoLocalDate) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from doAdd. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from doSet. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} --- old/test/java/time/tck/java/time/chrono/TestChronoLocalDateTime.java 2013-04-11 23:19:02.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,470 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for all built-in chronologies. - */ -@Test -public class TestChronoLocalDateTime { - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {HijrahChronology.INSTANCE}, - {IsoChronology.INSTANCE}, - {JapaneseChronology.INSTANCE}, - {MinguoChronology.INSTANCE}, - {ThaiBuddhistChronology.INSTANCE}}; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAdjuster adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date time"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.plus(1, adjuster); - Assert.fail("TemporalUnit.doAdd plus should have thrown a ClassCastException" + cdt - + ", can not be cast to " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.minus(1, adjuster); - Assert.fail("TemporalUnit.doAdd minus should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalField adjuster = new FixedTemporalField(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.with(adjuster, 1); - Assert.fail("TemporalField doSet should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster, 1); - assertEquals(result, cdt2, "TemporalField doSet failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_datetime_comparisons(Chronology chrono) { - List> dates = new ArrayList<>(); - - ChronoLocalDateTime date = chrono.date(LocalDate.of(1900, 1, 1)).atTime(LocalTime.MIN); - - // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date.minus(1, ChronoUnit.HOURS)); - dates.add(date.minus(1, ChronoUnit.MINUTES)); - dates.add(date.minus(1, ChronoUnit.SECONDS)); - dates.add(date.minus(1, ChronoUnit.NANOS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.NANOS)); - dates.add(date.plus(1, ChronoUnit.SECONDS)); - dates.add(date.plus(1, ChronoUnit.MINUTES)); - dates.add(date.plus(1, ChronoUnit.HOURS)); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List> otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDateTime d : dates) { - otherDates.add(chrono2.date(d).atTime(d.toLocalTime())); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDateTime a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDateTime b = otherDates.get(j); - int cmp = ChronoLocalDateTime.DATE_TIME_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception { - LocalDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3); - ChronoLocalDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - ChronoLocalDateTime ser = (ChronoLocalDateTime) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from doAdd. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from doSet. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} --- old/test/java/time/tck/java/time/chrono/TestHijrahChronology.java 2013-04-11 23:19:02.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Month; -import java.time.chrono.HijrahChronology; -import java.time.chrono.HijrahDate; -import java.time.chrono.ChronoLocalDate; -import java.time.temporal.Adjusters; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestHijrahChronology { - - //----------------------------------------------------------------------- - // Chronology.ofName("Hijrah") Lookup by name - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_chrono_byName() { - Chronology c = HijrahChronology.INSTANCE; - Chronology test = Chronology.of("Hijrah"); - Assert.assertNotNull(test, "The Hijrah calendar could not be found byName"); - Assert.assertEquals(test.getId(), "Hijrah", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "islamicc", "Type mismatch"); - Assert.assertEquals(test, c); - } - - //----------------------------------------------------------------------- - // creation, toLocalDate() - //----------------------------------------------------------------------- - @DataProvider(name="samples") - Object[][] data_samples() { - return new Object[][] { - {HijrahChronology.INSTANCE.date(1, 1, 1), LocalDate.of(622, 7, 19)}, - {HijrahChronology.INSTANCE.date(1, 1, 2), LocalDate.of(622, 7, 20)}, - {HijrahChronology.INSTANCE.date(1, 1, 3), LocalDate.of(622, 7, 21)}, - - {HijrahChronology.INSTANCE.date(2, 1, 1), LocalDate.of(623, 7, 8)}, - {HijrahChronology.INSTANCE.date(3, 1, 1), LocalDate.of(624, 6, 27)}, - {HijrahChronology.INSTANCE.date(3, 12, 6), LocalDate.of(625, 5, 23)}, - {HijrahChronology.INSTANCE.date(4, 1, 1), LocalDate.of(625, 6, 16)}, - {HijrahChronology.INSTANCE.date(4, 7, 3), LocalDate.of(625, 12, 12)}, - {HijrahChronology.INSTANCE.date(4, 7, 4), LocalDate.of(625, 12, 13)}, - {HijrahChronology.INSTANCE.date(5, 1, 1), LocalDate.of(626, 6, 5)}, - {HijrahChronology.INSTANCE.date(1662, 3, 3), LocalDate.of(2234, 4, 3)}, - {HijrahChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(2298, 12, 03)}, - {HijrahChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(2298, 12, 04)}, - }; - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(LocalDate.from(hijrahDate), iso); - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_fromCalendrical(ChronoLocalDate hijrahDate, LocalDate iso) { - assertEquals(HijrahChronology.INSTANCE.date(iso), hijrahDate); - } - - @DataProvider(name="badDates") - Object[][] data_badDates() { - return new Object[][] { - {1728, 0, 0}, - - {1728, -1, 1}, - {1728, 0, 1}, - {1728, 14, 1}, - {1728, 15, 1}, - - {1728, 1, -1}, - {1728, 1, 0}, - {1728, 1, 32}, - - {1728, 12, -1}, - {1728, 12, 0}, - {1728, 12, 32}, - }; - } - - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_badDates(int year, int month, int dom) { - HijrahChronology.INSTANCE.date(year, month, dom); - } - - //----------------------------------------------------------------------- - // with(WithAdjuster) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - ChronoLocalDate base = HijrahChronology.INSTANCE.date(1728, 10, 28); - ChronoLocalDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, HijrahChronology.INSTANCE.date(1728, 10, 29)); - } - - @Test(groups={"tck"}) - public void test_adjust2() { - ChronoLocalDate base = HijrahChronology.INSTANCE.date(1728, 12, 2); - ChronoLocalDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, HijrahChronology.INSTANCE.date(1728, 12, 30)); - } - - //----------------------------------------------------------------------- - // HijrahDate.with(Local*) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust_toLocalDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1726, 1, 4); - ChronoLocalDate test = hijrahDate.with(LocalDate.of(2012, 7, 6)); - assertEquals(test, HijrahChronology.INSTANCE.date(1433, 8, 16)); - } - - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_adjust_toMonth() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1726, 1, 4); - hijrahDate.with(Month.APRIL); - } - - //----------------------------------------------------------------------- - // LocalDate.with(HijrahDate) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_LocalDate_adjustToHijrahDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1728, 10, 29); - LocalDate test = LocalDate.MIN.with(hijrahDate); - assertEquals(test, LocalDate.of(2298, 12, 4)); - } - - @Test(groups={"tck"}) - public void test_LocalDateTime_adjustToHijrahDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1728, 10, 29); - LocalDateTime test = LocalDateTime.MIN.with(hijrahDate); - assertEquals(test, LocalDateTime.of(2298, 12, 4, 0, 0)); - } - - //----------------------------------------------------------------------- - // toString() - //----------------------------------------------------------------------- - @DataProvider(name="toString") - Object[][] data_toString() { - return new Object[][] { - {HijrahChronology.INSTANCE.date(1, 1, 1), "Hijrah AH 1-01-01"}, - {HijrahChronology.INSTANCE.date(1728, 10, 28), "Hijrah AH 1728-10-28"}, - {HijrahChronology.INSTANCE.date(1728, 10, 29), "Hijrah AH 1728-10-29"}, - {HijrahChronology.INSTANCE.date(1727, 12, 5), "Hijrah AH 1727-12-05"}, - {HijrahChronology.INSTANCE.date(1727, 12, 6), "Hijrah AH 1727-12-06"}, - }; - } - - @Test(dataProvider="toString", groups={"tck"}) - public void test_toString(ChronoLocalDate hijrahDate, String expected) { - assertEquals(hijrahDate.toString(), expected); - } - - //----------------------------------------------------------------------- - // equals() - //----------------------------------------------------------------------- - @Test(groups="tck") - public void test_equals_true() { - assertTrue(HijrahChronology.INSTANCE.equals(HijrahChronology.INSTANCE)); - } - - @Test(groups="tck") - public void test_equals_false() { - assertFalse(HijrahChronology.INSTANCE.equals(IsoChronology.INSTANCE)); - } - -} --- old/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java 2013-04-11 23:19:03.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,382 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.util.List; - -import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Month; -import java.time.Year; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.JapaneseDate; -import java.time.chrono.Chronology; -import java.time.chrono.Era; -import java.time.chrono.IsoChronology; -import java.time.temporal.Adjusters; -import java.util.Locale; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestJapaneseChronology { - private static int YDIFF_HEISEI = 1988; - private static int YDIFF_MEIJI = 1867; - private static int YDIFF_SHOWA = 1925; - private static int YDIFF_TAISHO = 1911; - - //----------------------------------------------------------------------- - // Chronology.of(String) - //----------------------------------------------------------------------- - @Test - public void test_chrono_byName() { - Chronology c = JapaneseChronology.INSTANCE; - Chronology test = Chronology.of("Japanese"); - Assert.assertNotNull(test, "The Japanese calendar could not be found byName"); - Assert.assertEquals(test.getId(), "Japanese", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch"); - Assert.assertEquals(test, c); - } - - //----------------------------------------------------------------------- - // Chronology.ofLocale(Locale) - //----------------------------------------------------------------------- - @Test - public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() { - Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese")); - Assert.assertEquals(test.getId(), "Japanese"); - Assert.assertEquals(test, JapaneseChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() { - Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese")); - Assert.assertEquals(test.getId(), "Japanese"); - Assert.assertEquals(test, JapaneseChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_oldJP_noVariant() { - Chronology test = Chronology.ofLocale(new Locale("ja", "JP")); - Assert.assertEquals(test.getId(), "ISO"); - Assert.assertEquals(test, IsoChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_oldJP_variant() { - Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP")); - Assert.assertEquals(test.getId(), "Japanese"); - Assert.assertEquals(test, JapaneseChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_iso() { - Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO"); - Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO"); - Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO"); - } - - //----------------------------------------------------------------------- - // creation, toLocalDate() - //----------------------------------------------------------------------- - @DataProvider(name="samples") - Object[][] data_samples() { - return new Object[][] { - {JapaneseChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1, 1, 1)}, - {JapaneseChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1, 1, 2)}, - {JapaneseChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1, 1, 3)}, - - {JapaneseChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2, 1, 1)}, - {JapaneseChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3, 1, 1)}, - {JapaneseChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3, 12, 6)}, - {JapaneseChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4, 1, 1)}, - {JapaneseChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)}, - {JapaneseChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)}, - {JapaneseChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)}, - {JapaneseChronology.INSTANCE.date(1662, 3, 3), LocalDate.of(1662, 3, 3)}, - {JapaneseChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)}, - {JapaneseChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(1728, 10, 29)}, - - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 1996 - YDIFF_HEISEI, 2, 29), LocalDate.of(1996, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2000 - YDIFF_HEISEI, 2, 29), LocalDate.of(2000, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_MEIJI, 1868 - YDIFF_MEIJI, 2, 29), LocalDate.of(1868, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 1928 - YDIFF_SHOWA, 2, 29), LocalDate.of(1928, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_TAISHO, 1912 - YDIFF_TAISHO, 2, 29), LocalDate.of(1912, 2, 29)}, - - {JapaneseChronology.INSTANCE.dateYearDay(1996, 60), LocalDate.of(1996, 2, 29)}, - {JapaneseChronology.INSTANCE.dateYearDay(1868, 60), LocalDate.of(1868, 2, 29)}, - {JapaneseChronology.INSTANCE.dateYearDay(1928, 60), LocalDate.of(1928, 2, 29)}, - {JapaneseChronology.INSTANCE.dateYearDay(1912, 60), LocalDate.of(1912, 2, 29)}, - }; - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_toLocalDate(JapaneseDate jdate, LocalDate iso) { - assertEquals(LocalDate.from(jdate), iso); - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_fromCalendrical(JapaneseDate jdate, LocalDate iso) { - assertEquals(JapaneseChronology.INSTANCE.date(iso), jdate); - } - - @DataProvider(name="badDates") - Object[][] data_badDates() { - return new Object[][] { - {1728, 0, 0}, - - {1728, -1, 1}, - {1728, 0, 1}, - {1728, 14, 1}, - {1728, 15, 1}, - - {1728, 1, -1}, - {1728, 1, 0}, - {1728, 1, 32}, - - {1728, 12, -1}, - {1728, 12, 0}, - {1728, 12, 32}, - - {1725, 2, 29}, - {500, 2, 29}, - {2100, 2, 29}, - }; - } - - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_badDates(int year, int month, int dom) { - JapaneseChronology.INSTANCE.date(year, month, dom); - } - - //----------------------------------------------------------------------- - // prolepticYear() and is LeapYear() - //----------------------------------------------------------------------- - @DataProvider(name="prolepticYear") - Object[][] data_prolepticYear() { - return new Object[][] { - {2, JapaneseChronology.ERA_HEISEI, 1, 1 + YDIFF_HEISEI, false}, - {2, JapaneseChronology.ERA_HEISEI, 100, 100 + YDIFF_HEISEI, true}, - {2, JapaneseChronology.ERA_HEISEI, 0, YDIFF_HEISEI, true}, - {2, JapaneseChronology.ERA_HEISEI, -10, -10 + YDIFF_HEISEI, false}, - - {-1, JapaneseChronology.ERA_MEIJI, 1, 1 + YDIFF_MEIJI, true}, - {-1, JapaneseChronology.ERA_MEIJI, 100, 100 + YDIFF_MEIJI, false}, - {-1, JapaneseChronology.ERA_MEIJI, 0, YDIFF_MEIJI, false}, - {-1, JapaneseChronology.ERA_MEIJI, -10, -10 + YDIFF_MEIJI, false}, - - {1, JapaneseChronology.ERA_SHOWA, 1, 1 + YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, 100, 100 + YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, 0, YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, -5, -5 + YDIFF_SHOWA, true}, - - {0, JapaneseChronology.ERA_TAISHO, 1, 1 + YDIFF_TAISHO, true}, - {0, JapaneseChronology.ERA_TAISHO, 100, 100 + YDIFF_TAISHO, false}, - {0, JapaneseChronology.ERA_TAISHO, 0, YDIFF_TAISHO, false}, - {0, JapaneseChronology.ERA_TAISHO, -10, -10 + YDIFF_TAISHO, false}, - - }; - } - - @Test(dataProvider="prolepticYear", groups={"tck"}) - public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { - Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue) ; - assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj)); - assertEquals(eraObj, era); - assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); - assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; - assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap()) ; - } - - //----------------------------------------------------------------------- - // with(WithAdjuster) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 10, 29); - JapaneseDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 10, 31)); - } - - @Test(groups={"tck"}) - public void test_adjust2() { - JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 12, 2); - JapaneseDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 12, 31)); - } - - //----------------------------------------------------------------------- - // JapaneseDate.with(Local*) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust_toLocalDate() { - JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); - JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6)); - assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6)); - } - - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_adjust_toMonth() { - JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); - jdate.with(Month.APRIL); - } - - //----------------------------------------------------------------------- - // LocalDate.with(JapaneseDate) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_LocalDate_adjustToJapaneseDate() { - JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); - LocalDate test = LocalDate.MIN.with(jdate); - assertEquals(test, LocalDate.of(1728, 10, 29)); - } - - @Test(groups={"tck"}) - public void test_LocalDateTime_adjustToJapaneseDate() { - JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); - LocalDateTime test = LocalDateTime.MIN.with(jdate); - assertEquals(test, LocalDateTime.of(1728, 10, 29, 0, 0)); - } - - //----------------------------------------------------------------------- - // Check Japanese Eras - //----------------------------------------------------------------------- - @DataProvider(name="japaneseEras") - Object[][] data_japanseseEras() { - return new Object[][] { - { JapaneseChronology.ERA_SEIREKI, -999, "Seireki"}, - { JapaneseChronology.ERA_MEIJI, -1, "Meiji"}, - { JapaneseChronology.ERA_TAISHO, 0, "Taisho"}, - { JapaneseChronology.ERA_SHOWA, 1, "Showa"}, - { JapaneseChronology.ERA_HEISEI, 2, "Heisei"}, - }; - } - - @Test(groups={"tck"}, dataProvider="japaneseEras") - public void test_Japanese_Eras(Era era, int eraValue, String name) { - assertEquals(era.getValue(), eraValue, "EraValue"); - assertEquals(era.toString(), name, "Era Name"); - assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()"); - List eras = JapaneseChronology.INSTANCE.eras(); - assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()"); - } - - @Test(groups="tck") - public void test_Japanese_badEras() { - int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000}; - for (int badEra : badEras) { - try { - Era era = JapaneseChronology.INSTANCE.eraOf(badEra); - fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra); - } catch (DateTimeException ex) { - // ignore expected exception - } - } - } - - //----------------------------------------------------------------------- - // toString() - //----------------------------------------------------------------------- - @DataProvider(name="toString") - Object[][] data_toString() { - return new Object[][] { - {JapaneseChronology.INSTANCE.date(0001, 1, 1), "Japanese 0001-01-01"}, - {JapaneseChronology.INSTANCE.date(1728, 10, 28), "Japanese 1728-10-28"}, - {JapaneseChronology.INSTANCE.date(1728, 10, 29), "Japanese 1728-10-29"}, - {JapaneseChronology.INSTANCE.date(1727, 12, 5), "Japanese 1727-12-05"}, - {JapaneseChronology.INSTANCE.date(1727, 12, 6), "Japanese 1727-12-06"}, - {JapaneseChronology.INSTANCE.date(1868, 9, 8), "Japanese Meiji 1-09-08"}, - {JapaneseChronology.INSTANCE.date(1912, 7, 29), "Japanese Meiji 45-07-29"}, - {JapaneseChronology.INSTANCE.date(1912, 7, 30), "Japanese Taisho 1-07-30"}, - {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"}, - {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"}, - {JapaneseChronology.INSTANCE.date(1989, 1, 7), "Japanese Showa 64-01-07"}, - {JapaneseChronology.INSTANCE.date(1989, 1, 8), "Japanese Heisei 1-01-08"}, - {JapaneseChronology.INSTANCE.date(2012, 12, 6), "Japanese Heisei 24-12-06"}, - }; - } - - @Test(dataProvider="toString", groups={"tck"}) - public void test_toString(JapaneseDate jdate, String expected) { - assertEquals(jdate.toString(), expected); - } - - //----------------------------------------------------------------------- - // equals() - //----------------------------------------------------------------------- - @Test(groups="tck") - public void test_equals_true() { - assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE)); - } - - @Test(groups="tck") - public void test_equals_false() { - assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE)); - } - -} --- old/test/java/time/tck/java/time/chrono/TestMinguoChronology.java 2013-04-11 23:19:03.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,325 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Month; -import java.time.ZoneOffset; -import java.time.chrono.MinguoChronology; -import java.time.chrono.MinguoDate; -import java.time.temporal.Adjusters; -import java.time.temporal.ChronoUnit; -import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.IsoChronology; -import java.time.chrono.Era; -import java.time.Year; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestMinguoChronology { - - private static final int YDIFF = 1911; - //----------------------------------------------------------------------- - // Chronology.ofName("Minguo") Lookup by name - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_chrono_byName() { - Chronology c = MinguoChronology.INSTANCE; - Chronology test = Chronology.of("Minguo"); - Assert.assertNotNull(test, "The Minguo calendar could not be found byName"); - Assert.assertEquals(test.getId(), "Minguo", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch"); - Assert.assertEquals(test, c); - } - - //----------------------------------------------------------------------- - // creation, toLocalDate() - //----------------------------------------------------------------------- - @DataProvider(name="samples") - Object[][] data_samples() { - return new Object[][] { - {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)}, - {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)}, - - {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)}, - {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)}, - {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)}, - {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)}, - {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)}, - {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)}, - - {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, - }; - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_toLocalDate(MinguoDate minguo, LocalDate iso) { - assertEquals(LocalDate.from(minguo), iso); - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_fromCalendrical(MinguoDate minguo, LocalDate iso) { - assertEquals(MinguoChronology.INSTANCE.date(iso), minguo); - } - - @SuppressWarnings("unused") - @Test(dataProvider="samples", groups={"implementation"}) - public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) { - MinguoDate hd = minguoDate; - ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); - ZoneOffset zo = ZoneOffset.ofHours(1); - ChronoZonedDateTime hzdt = hdt.atZone(zo); - hdt = hdt.plus(1, ChronoUnit.YEARS); - hdt = hdt.plus(1, ChronoUnit.MONTHS); - hdt = hdt.plus(1, ChronoUnit.DAYS); - hdt = hdt.plus(1, ChronoUnit.HOURS); - hdt = hdt.plus(1, ChronoUnit.MINUTES); - hdt = hdt.plus(1, ChronoUnit.SECONDS); - hdt = hdt.plus(1, ChronoUnit.NANOS); - ChronoLocalDateTime a2 = hzdt.toLocalDateTime(); - MinguoDate a3 = a2.toLocalDate(); - MinguoDate a5 = hzdt.toLocalDate(); - //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5); - } - - @Test() - public void test_MinguoChrono() { - MinguoDate h1 = (MinguoDate)MinguoChronology.ERA_ROC.date(1, 2, 3); - MinguoDate h2 = h1; - ChronoLocalDateTime h3 = h2.atTime(LocalTime.NOON); - @SuppressWarnings("unused") - ChronoZonedDateTime h4 = h3.atZone(ZoneOffset.UTC); - } - - @DataProvider(name="badDates") - Object[][] data_badDates() { - return new Object[][] { - {1912, 0, 0}, - - {1912, -1, 1}, - {1912, 0, 1}, - {1912, 14, 1}, - {1912, 15, 1}, - - {1912, 1, -1}, - {1912, 1, 0}, - {1912, 1, 32}, - {1912, 2, 29}, - {1912, 2, 30}, - - {1912, 12, -1}, - {1912, 12, 0}, - {1912, 12, 32}, - - {1907 - YDIFF, 2, 29}, - {100 - YDIFF, 2, 29}, - {2100 - YDIFF, 2, 29}, - {2101 - YDIFF, 2, 29}, - }; - } - - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_badDates(int year, int month, int dom) { - MinguoChronology.INSTANCE.date(year, month, dom); - } - - //----------------------------------------------------------------------- - // prolepticYear() and is LeapYear() - //----------------------------------------------------------------------- - @DataProvider(name="prolepticYear") - Object[][] data_prolepticYear() { - return new Object[][] { - {1, MinguoChronology.ERA_ROC, 1912 - YDIFF, 1912 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1916 - YDIFF, 1916 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1914 - YDIFF, 1914 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 2000 - YDIFF, 2000 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 2100 - YDIFF, 2100 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 0, 0, false}, - {1, MinguoChronology.ERA_ROC, 1908 - YDIFF, 1908 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1900 - YDIFF, 1900 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 1600 - YDIFF, 1600 - YDIFF, true}, - - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1911, 1912 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1915, 1916 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1913, 1914 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1999, 2000 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 2099, 2100 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, 1, 0, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1907, 1908 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1899, 1900 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1599, 1600 - YDIFF, true}, - - }; - } - - @Test(dataProvider="prolepticYear", groups={"tck"}) - public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { - Era eraObj = MinguoChronology.INSTANCE.eraOf(eraValue) ; - assertTrue(MinguoChronology.INSTANCE.eras().contains(eraObj)); - assertEquals(eraObj, era); - assertEquals(MinguoChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); - assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; - assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear + YDIFF).isLeap()) ; - } - - //----------------------------------------------------------------------- - // with(DateTimeAdjuster) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29); - MinguoDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31)); - } - - @Test(groups={"tck"}) - public void test_adjust2() { - MinguoDate base = MinguoChronology.INSTANCE.date(1728, 12, 2); - MinguoDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, MinguoChronology.INSTANCE.date(1728, 12, 31)); - } - - //----------------------------------------------------------------------- - // MinguoDate.with(Local*) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust_toLocalDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(99, 1, 4); - MinguoDate test = minguo.with(LocalDate.of(2012, 7, 6)); - assertEquals(test, MinguoChronology.INSTANCE.date(101, 7, 6)); - } - - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_adjust_toMonth() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(1726, 1, 4); - minguo.with(Month.APRIL); - } - - //----------------------------------------------------------------------- - // LocalDate.with(MinguoDate) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_LocalDate_adjustToMinguoDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); - LocalDate test = LocalDate.MIN.with(minguo); - assertEquals(test, LocalDate.of(2012, 10, 29)); - } - - @Test(groups={"tck"}) - public void test_LocalDateTime_adjustToMinguoDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); - LocalDateTime test = LocalDateTime.MIN.with(minguo); - assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); - } - - //----------------------------------------------------------------------- - // toString() - //----------------------------------------------------------------------- - @DataProvider(name="toString") - Object[][] data_toString() { - return new Object[][] { - {MinguoChronology.INSTANCE.date(1, 1, 1), "Minguo ROC 1-01-01"}, - {MinguoChronology.INSTANCE.date(1728, 10, 28), "Minguo ROC 1728-10-28"}, - {MinguoChronology.INSTANCE.date(1728, 10, 29), "Minguo ROC 1728-10-29"}, - {MinguoChronology.INSTANCE.date(1727, 12, 5), "Minguo ROC 1727-12-05"}, - {MinguoChronology.INSTANCE.date(1727, 12, 6), "Minguo ROC 1727-12-06"}, - }; - } - - @Test(dataProvider="toString", groups={"tck"}) - public void test_toString(MinguoDate minguo, String expected) { - assertEquals(minguo.toString(), expected); - } - - //----------------------------------------------------------------------- - // equals() - //----------------------------------------------------------------------- - @Test(groups="tck") - public void test_equals_true() { - assertTrue(MinguoChronology.INSTANCE.equals(MinguoChronology.INSTANCE)); - } - - @Test(groups="tck") - public void test_equals_false() { - assertFalse(MinguoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); - } - -} --- old/test/java/time/tck/java/time/chrono/TestThaiBuddhistChronology.java 2013-04-11 23:19:04.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,394 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static java.time.temporal.ChronoField.DAY_OF_YEAR; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.YEAR; -import static java.time.temporal.ChronoField.YEAR_OF_ERA; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Month; -import java.time.Year; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ThaiBuddhistDate; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.Era; -import java.time.chrono.IsoChronology; -import java.time.temporal.Adjusters; -import java.time.temporal.ChronoField; -import java.time.temporal.ValueRange; -import java.util.Locale; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestThaiBuddhistChronology { - - private static final int YDIFF = 543; - - //----------------------------------------------------------------------- - // Chronology.of(String) - //----------------------------------------------------------------------- - @Test - public void test_chrono_byName() { - Chronology c = ThaiBuddhistChronology.INSTANCE; - Chronology test = Chronology.of("ThaiBuddhist"); - Assert.assertNotNull(test, "The ThaiBuddhist calendar could not be found byName"); - Assert.assertEquals(test.getId(), "ThaiBuddhist", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "buddhist", "Type mismatch"); - Assert.assertEquals(test, c); - } - - //----------------------------------------------------------------------- - // Chronology.ofLocale(Locale) - //----------------------------------------------------------------------- - @Test - public void test_chrono_byLocale_fullTag_thaiCalendarFromThai() { - Chronology test = Chronology.ofLocale(Locale.forLanguageTag("th-TH-u-ca-buddhist")); - Assert.assertEquals(test.getId(), "ThaiBuddhist"); - Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_fullTag_thaiCalendarFromElsewhere() { - Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-buddhist")); - Assert.assertEquals(test.getId(), "ThaiBuddhist"); - Assert.assertEquals(test, ThaiBuddhistChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_oldTH_noVariant() { // deliberately different to Calendar - Chronology test = Chronology.ofLocale(new Locale("th", "TH")); - Assert.assertEquals(test.getId(), "ISO"); - Assert.assertEquals(test, IsoChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_oldTH_variant() { - Chronology test = Chronology.ofLocale(new Locale("th", "TH", "TH")); - Assert.assertEquals(test.getId(), "ISO"); - Assert.assertEquals(test, IsoChronology.INSTANCE); - } - - @Test - public void test_chrono_byLocale_iso() { - Assert.assertEquals(Chronology.ofLocale(new Locale("th", "TH")).getId(), "ISO"); - Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH")).getId(), "ISO"); - Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("th-TH-TH")).getId(), "ISO"); - } - - //----------------------------------------------------------------------- - // creation, toLocalDate() - //----------------------------------------------------------------------- - @DataProvider(name="samples") - Object[][] data_samples() { - return new Object[][] { - {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 1), LocalDate.of(1, 1, 1)}, - {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 2), LocalDate.of(1, 1, 2)}, - {ThaiBuddhistChronology.INSTANCE.date(1 + YDIFF, 1, 3), LocalDate.of(1, 1, 3)}, - - {ThaiBuddhistChronology.INSTANCE.date(2 + YDIFF, 1, 1), LocalDate.of(2, 1, 1)}, - {ThaiBuddhistChronology.INSTANCE.date(3 + YDIFF, 1, 1), LocalDate.of(3, 1, 1)}, - {ThaiBuddhistChronology.INSTANCE.date(3 + YDIFF, 12, 6), LocalDate.of(3, 12, 6)}, - {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 1, 1), LocalDate.of(4, 1, 1)}, - {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 7, 3), LocalDate.of(4, 7, 3)}, - {ThaiBuddhistChronology.INSTANCE.date(4 + YDIFF, 7, 4), LocalDate.of(4, 7, 4)}, - {ThaiBuddhistChronology.INSTANCE.date(5 + YDIFF, 1, 1), LocalDate.of(5, 1, 1)}, - {ThaiBuddhistChronology.INSTANCE.date(1662 + YDIFF, 3, 3), LocalDate.of(1662, 3, 3)}, - {ThaiBuddhistChronology.INSTANCE.date(1728 + YDIFF, 10, 28), LocalDate.of(1728, 10, 28)}, - {ThaiBuddhistChronology.INSTANCE.date(1728 + YDIFF, 10, 29), LocalDate.of(1728, 10, 29)}, - {ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29), LocalDate.of(2012, 8, 29)}, - - {ThaiBuddhistChronology.INSTANCE.dateYearDay(4 + YDIFF, 60), LocalDate.of(4, 2, 29)}, - {ThaiBuddhistChronology.INSTANCE.dateYearDay(400 + YDIFF, 60), LocalDate.of(400, 2, 29)}, - {ThaiBuddhistChronology.INSTANCE.dateYearDay(2000 + YDIFF, 60), LocalDate.of(2000, 2, 29)}, - - }; - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_toLocalDate(ThaiBuddhistDate jdate, LocalDate iso) { - assertEquals(LocalDate.from(jdate), iso); - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_fromCalendrical(ThaiBuddhistDate jdate, LocalDate iso) { - assertEquals(ThaiBuddhistChronology.INSTANCE.date(iso), jdate); - } - - @DataProvider(name="badDates") - Object[][] data_badDates() { - return new Object[][] { - {1728, 0, 0}, - - {1728, -1, 1}, - {1728, 0, 1}, - {1728, 14, 1}, - {1728, 15, 1}, - - {1728, 1, -1}, - {1728, 1, 0}, - {1728, 1, 32}, - - {1728, 12, -1}, - {1728, 12, 0}, - {1728, 12, 32}, - - {3 + YDIFF, 2, 29}, - {600 + YDIFF, 2, 29}, - {1501 + YDIFF, 2, 29}, - }; - } - - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_badDates(int year, int month, int dom) { - ThaiBuddhistChronology.INSTANCE.date(year, month, dom); - } - - //----------------------------------------------------------------------- - // prolepticYear() and is LeapYear() - //----------------------------------------------------------------------- - @DataProvider(name="prolepticYear") - Object[][] data_prolepticYear() { - return new Object[][] { - {1, ThaiBuddhistChronology.ERA_BE, 4 + YDIFF, 4 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 7 + YDIFF, 7 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, 8 + YDIFF, 8 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 1000 + YDIFF, 1000 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, 2000 + YDIFF, 2000 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 0, 0, false}, - {1, ThaiBuddhistChronology.ERA_BE, -4 + YDIFF, -4 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, -7 + YDIFF, -7 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, -100 + YDIFF, -100 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, -800 + YDIFF, -800 + YDIFF, true}, - - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -3 - YDIFF, 4 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -6 - YDIFF, 7 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -7 - YDIFF, 8 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -999 - YDIFF, 1000 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -1999 - YDIFF, 2000 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 1, 0, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 5 - YDIFF, -4 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 8 - YDIFF, -7 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 101 - YDIFF, -100 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 801 - YDIFF, -800 + YDIFF, true}, - - }; - } - - @Test(dataProvider="prolepticYear", groups={"tck"}) - public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { - Era eraObj = ThaiBuddhistChronology.INSTANCE.eraOf(eraValue) ; - assertTrue(ThaiBuddhistChronology.INSTANCE.eras().contains(eraObj)); - assertEquals(eraObj, era); - assertEquals(ThaiBuddhistChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); - assertEquals(ThaiBuddhistChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; - assertEquals(ThaiBuddhistChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear - YDIFF).isLeap()) ; - } - - //----------------------------------------------------------------------- - // with(WithAdjuster) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 10, 29); - ThaiBuddhistDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 10, 31)); - } - - @Test(groups={"tck"}) - public void test_adjust2() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2); - ThaiBuddhistDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31)); - } - - //----------------------------------------------------------------------- - // withYear() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_withYear_BE() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); - ThaiBuddhistDate test = base.with(YEAR, 2554); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2554, 8, 29)); - } - - @Test(groups={"tck"}) - public void test_withYear_BBE() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); - ThaiBuddhistDate test = base.with(YEAR_OF_ERA, 2554); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(-2553, 8, 29)); - } - - //----------------------------------------------------------------------- - // withEra() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_withEra_BE() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BE.getValue()); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); - } - - @Test(groups={"tck"}) - public void test_withEra_BBE() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BEFORE_BE.getValue()); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29)); - } - - @Test(groups={"tck"}) - public void test_withEra_swap() { - ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BE.getValue()); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); - } - - //----------------------------------------------------------------------- - // BuddhistDate.with(Local*) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust_toLocalDate() { - ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); - ThaiBuddhistDate test = jdate.with(LocalDate.of(2012, 7, 6)); - assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 7, 6)); - } - - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_adjust_toMonth() { - ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); - jdate.with(Month.APRIL); - } - - //----------------------------------------------------------------------- - // LocalDate.with(BuddhistDate) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_LocalDate_adjustToBuddhistDate() { - ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); - LocalDate test = LocalDate.MIN.with(jdate); - assertEquals(test, LocalDate.of(2012, 10, 29)); - } - - @Test(groups={"tck"}) - public void test_LocalDateTime_adjustToBuddhistDate() { - ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); - LocalDateTime test = LocalDateTime.MIN.with(jdate); - assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); - } - - //----------------------------------------------------------------------- - // toString() - //----------------------------------------------------------------------- - @DataProvider(name="toString") - Object[][] data_toString() { - return new Object[][] { - {ThaiBuddhistChronology.INSTANCE.date(544, 1, 1), "ThaiBuddhist BE 544-01-01"}, - {ThaiBuddhistChronology.INSTANCE.date(2271, 10, 28), "ThaiBuddhist BE 2271-10-28"}, - {ThaiBuddhistChronology.INSTANCE.date(2271, 10, 29), "ThaiBuddhist BE 2271-10-29"}, - {ThaiBuddhistChronology.INSTANCE.date(2270, 12, 5), "ThaiBuddhist BE 2270-12-05"}, - {ThaiBuddhistChronology.INSTANCE.date(2270, 12, 6), "ThaiBuddhist BE 2270-12-06"}, - }; - } - - @Test(dataProvider="toString", groups={"tck"}) - public void test_toString(ThaiBuddhistDate jdate, String expected) { - assertEquals(jdate.toString(), expected); - } - - //----------------------------------------------------------------------- - // chronology range(ChronoField) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_Chrono_range() { - long minYear = LocalDate.MIN.getYear() + YDIFF; - long maxYear = LocalDate.MAX.getYear() + YDIFF; - assertEquals(ThaiBuddhistChronology.INSTANCE.range(YEAR), ValueRange.of(minYear, maxYear)); - assertEquals(ThaiBuddhistChronology.INSTANCE.range(YEAR_OF_ERA), ValueRange.of(1, -minYear + 1, maxYear)); - - assertEquals(ThaiBuddhistChronology.INSTANCE.range(DAY_OF_MONTH), DAY_OF_MONTH.range()); - assertEquals(ThaiBuddhistChronology.INSTANCE.range(DAY_OF_YEAR), DAY_OF_YEAR.range()); - assertEquals(ThaiBuddhistChronology.INSTANCE.range(MONTH_OF_YEAR), MONTH_OF_YEAR.range()); - } - - //----------------------------------------------------------------------- - // equals() - //----------------------------------------------------------------------- - @Test(groups="tck") - public void test_equals_true() { - assertTrue(ThaiBuddhistChronology.INSTANCE.equals(ThaiBuddhistChronology.INSTANCE)); - } - - @Test(groups="tck") - public void test_equals_false() { - assertFalse(ThaiBuddhistChronology.INSTANCE.equals(IsoChronology.INSTANCE)); - } - -} --- old/test/java/time/tck/java/time/temporal/TCKDateTimeAdjusters.java 2013-04-11 23:19:04.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,601 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.temporal; - -import java.time.temporal.*; - -import static java.time.DayOfWeek.MONDAY; -import static java.time.DayOfWeek.TUESDAY; -import static java.time.Month.DECEMBER; -import static java.time.Month.JANUARY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.Month; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test Adjusters. - */ -@Test -public class TCKDateTimeAdjusters { - - //----------------------------------------------------------------------- - // firstDayOfMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_firstDayOfMonth() { - assertNotNull(Adjusters.firstDayOfMonth()); - } - - @Test(groups={"tck"}) - public void test_firstDayOfMonth_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfMonth().adjustInto(date); - assertEquals(test.getYear(), 2007); - assertEquals(test.getMonth(), month); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - @Test(groups={"tck"}) - public void test_firstDayOfMonth_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfMonth().adjustInto(date); - assertEquals(test.getYear(), 2008); - assertEquals(test.getMonth(), month); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - //----------------------------------------------------------------------- - // lastDayOfMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_lastDayOfMonth() { - assertNotNull(Adjusters.lastDayOfMonth()); - } - - @Test(groups={"tck"}) - public void test_lastDayOfMonth_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfMonth().adjustInto(date); - assertEquals(test.getYear(), 2007); - assertEquals(test.getMonth(), month); - assertEquals(test.getDayOfMonth(), month.length(false)); - } - } - } - - @Test(groups={"tck"}) - public void test_lastDayOfMonth_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfMonth().adjustInto(date); - assertEquals(test.getYear(), 2008); - assertEquals(test.getMonth(), month); - assertEquals(test.getDayOfMonth(), month.length(true)); - } - } - } - - //----------------------------------------------------------------------- - // firstDayOfNextMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_firstDayOfNextMonth() { - assertNotNull(Adjusters.firstDayOfNextMonth()); - } - - @Test(groups={"tck"}) - public void test_firstDayOfNextMonth_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextMonth().adjustInto(date); - assertEquals(test.getYear(), month == DECEMBER ? 2008 : 2007); - assertEquals(test.getMonth(), month.plus(1)); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - @Test(groups={"tck"}) - public void test_firstDayOfNextMonth_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextMonth().adjustInto(date); - assertEquals(test.getYear(), month == DECEMBER ? 2009 : 2008); - assertEquals(test.getMonth(), month.plus(1)); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - //----------------------------------------------------------------------- - // firstDayOfYear() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_firstDayOfYear() { - assertNotNull(Adjusters.firstDayOfYear()); - } - - @Test(groups={"tck"}) - public void test_firstDayOfYear_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfYear().adjustInto(date); - assertEquals(test.getYear(), 2007); - assertEquals(test.getMonth(), Month.JANUARY); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - @Test(groups={"tck"}) - public void test_firstDayOfYear_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfYear().adjustInto(date); - assertEquals(test.getYear(), 2008); - assertEquals(test.getMonth(), Month.JANUARY); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - //----------------------------------------------------------------------- - // lastDayOfYear() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_lastDayOfYear() { - assertNotNull(Adjusters.lastDayOfYear()); - } - - @Test(groups={"tck"}) - public void test_lastDayOfYear_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfYear().adjustInto(date); - assertEquals(test.getYear(), 2007); - assertEquals(test.getMonth(), Month.DECEMBER); - assertEquals(test.getDayOfMonth(), 31); - } - } - } - - @Test(groups={"tck"}) - public void test_lastDayOfYear_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfYear().adjustInto(date); - assertEquals(test.getYear(), 2008); - assertEquals(test.getMonth(), Month.DECEMBER); - assertEquals(test.getDayOfMonth(), 31); - } - } - } - - //----------------------------------------------------------------------- - // firstDayOfNextYear() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_firstDayOfNextYear() { - assertNotNull(Adjusters.firstDayOfNextYear()); - } - - @Test(groups={"tck"}) - public void test_firstDayOfNextYear_nonLeap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextYear().adjustInto(date); - assertEquals(test.getYear(), 2008); - assertEquals(test.getMonth(), JANUARY); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - @Test(groups={"tck"}) - public void test_firstDayOfNextYear_leap() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(true); i++) { - LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextYear().adjustInto(date); - assertEquals(test.getYear(), 2009); - assertEquals(test.getMonth(), JANUARY); - assertEquals(test.getDayOfMonth(), 1); - } - } - } - - //----------------------------------------------------------------------- - // dayOfWeekInMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_dayOfWeekInMonth() { - assertNotNull(Adjusters.dayOfWeekInMonth(1, MONDAY)); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void factory_dayOfWeekInMonth_nullDayOfWeek() { - Adjusters.dayOfWeekInMonth(1, null); - } - - @DataProvider(name = "dayOfWeekInMonth_positive") - Object[][] data_dayOfWeekInMonth_positive() { - return new Object[][] { - {2011, 1, TUESDAY, date(2011, 1, 4)}, - {2011, 2, TUESDAY, date(2011, 2, 1)}, - {2011, 3, TUESDAY, date(2011, 3, 1)}, - {2011, 4, TUESDAY, date(2011, 4, 5)}, - {2011, 5, TUESDAY, date(2011, 5, 3)}, - {2011, 6, TUESDAY, date(2011, 6, 7)}, - {2011, 7, TUESDAY, date(2011, 7, 5)}, - {2011, 8, TUESDAY, date(2011, 8, 2)}, - {2011, 9, TUESDAY, date(2011, 9, 6)}, - {2011, 10, TUESDAY, date(2011, 10, 4)}, - {2011, 11, TUESDAY, date(2011, 11, 1)}, - {2011, 12, TUESDAY, date(2011, 12, 6)}, - }; - } - - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_positive") - public void test_dayOfWeekInMonth_positive(int year, int month, DayOfWeek dow, LocalDate expected) { - for (int ordinal = 1; ordinal <= 5; ordinal++) { - for (int day = 1; day <= Month.of(month).length(false); day++) { - LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(ordinal, dow).adjustInto(date); - assertEquals(test, expected.plusWeeks(ordinal - 1)); - } - } - } - - @DataProvider(name = "dayOfWeekInMonth_zero") - Object[][] data_dayOfWeekInMonth_zero() { - return new Object[][] { - {2011, 1, TUESDAY, date(2010, 12, 28)}, - {2011, 2, TUESDAY, date(2011, 1, 25)}, - {2011, 3, TUESDAY, date(2011, 2, 22)}, - {2011, 4, TUESDAY, date(2011, 3, 29)}, - {2011, 5, TUESDAY, date(2011, 4, 26)}, - {2011, 6, TUESDAY, date(2011, 5, 31)}, - {2011, 7, TUESDAY, date(2011, 6, 28)}, - {2011, 8, TUESDAY, date(2011, 7, 26)}, - {2011, 9, TUESDAY, date(2011, 8, 30)}, - {2011, 10, TUESDAY, date(2011, 9, 27)}, - {2011, 11, TUESDAY, date(2011, 10, 25)}, - {2011, 12, TUESDAY, date(2011, 11, 29)}, - }; - } - - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_zero") - public void test_dayOfWeekInMonth_zero(int year, int month, DayOfWeek dow, LocalDate expected) { - for (int day = 1; day <= Month.of(month).length(false); day++) { - LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(0, dow).adjustInto(date); - assertEquals(test, expected); - } - } - - @DataProvider(name = "dayOfWeekInMonth_negative") - Object[][] data_dayOfWeekInMonth_negative() { - return new Object[][] { - {2011, 1, TUESDAY, date(2011, 1, 25)}, - {2011, 2, TUESDAY, date(2011, 2, 22)}, - {2011, 3, TUESDAY, date(2011, 3, 29)}, - {2011, 4, TUESDAY, date(2011, 4, 26)}, - {2011, 5, TUESDAY, date(2011, 5, 31)}, - {2011, 6, TUESDAY, date(2011, 6, 28)}, - {2011, 7, TUESDAY, date(2011, 7, 26)}, - {2011, 8, TUESDAY, date(2011, 8, 30)}, - {2011, 9, TUESDAY, date(2011, 9, 27)}, - {2011, 10, TUESDAY, date(2011, 10, 25)}, - {2011, 11, TUESDAY, date(2011, 11, 29)}, - {2011, 12, TUESDAY, date(2011, 12, 27)}, - }; - } - - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_negative") - public void test_dayOfWeekInMonth_negative(int year, int month, DayOfWeek dow, LocalDate expected) { - for (int ordinal = 0; ordinal < 5; ordinal++) { - for (int day = 1; day <= Month.of(month).length(false); day++) { - LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); - assertEquals(test, expected.minusWeeks(ordinal)); - } - } - } - - //----------------------------------------------------------------------- - // firstInMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_firstInMonth() { - assertNotNull(Adjusters.firstInMonth(MONDAY)); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void factory_firstInMonth_nullDayOfWeek() { - Adjusters.firstInMonth(null); - } - - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_positive") - public void test_firstInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { - for (int day = 1; day <= Month.of(month).length(false); day++) { - LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.firstInMonth(dow).adjustInto(date); - assertEquals(test, expected, "day-of-month=" + day); - } - } - - //----------------------------------------------------------------------- - // lastInMonth() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_lastInMonth() { - assertNotNull(Adjusters.lastInMonth(MONDAY)); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void factory_lastInMonth_nullDayOfWeek() { - Adjusters.lastInMonth(null); - } - - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_negative") - public void test_lastInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { - for (int day = 1; day <= Month.of(month).length(false); day++) { - LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.lastInMonth(dow).adjustInto(date); - assertEquals(test, expected, "day-of-month=" + day); - } - } - - //----------------------------------------------------------------------- - // next() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_next() { - assertNotNull(Adjusters.next(MONDAY)); - } - - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) - public void factory_next_nullDayOfWeek() { - Adjusters.next(null); - } - - @Test(groups={"tck"}) - public void test_next() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - - for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.next(dow).adjustInto(date); - - assertSame(test.getDayOfWeek(), dow, date + " " + test); - - if (test.getYear() == 2007) { - int dayDiff = test.getDayOfYear() - date.getDayOfYear(); - assertTrue(dayDiff > 0 && dayDiff < 8); - } else { - assertSame(month, Month.DECEMBER); - assertTrue(date.getDayOfMonth() > 24); - assertEquals(test.getYear(), 2008); - assertSame(test.getMonth(), Month.JANUARY); - assertTrue(test.getDayOfMonth() < 8); - } - } - } - } - } - - //----------------------------------------------------------------------- - // nextOrSame() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_nextOrCurrent() { - assertNotNull(Adjusters.nextOrSame(MONDAY)); - } - - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) - public void factory_nextOrCurrent_nullDayOfWeek() { - Adjusters.nextOrSame(null); - } - - @Test(groups={"tck"}) - public void test_nextOrCurrent() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - - for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.nextOrSame(dow).adjustInto(date); - - assertSame(test.getDayOfWeek(), dow); - - if (test.getYear() == 2007) { - int dayDiff = test.getDayOfYear() - date.getDayOfYear(); - assertTrue(dayDiff < 8); - assertEquals(date.equals(test), date.getDayOfWeek() == dow); - } else { - assertFalse(date.getDayOfWeek() == dow); - assertSame(month, Month.DECEMBER); - assertTrue(date.getDayOfMonth() > 24); - assertEquals(test.getYear(), 2008); - assertSame(test.getMonth(), Month.JANUARY); - assertTrue(test.getDayOfMonth() < 8); - } - } - } - } - } - - //----------------------------------------------------------------------- - // previous() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_previous() { - assertNotNull(Adjusters.previous(MONDAY)); - } - - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) - public void factory_previous_nullDayOfWeek() { - Adjusters.previous(null); - } - - @Test(groups={"tck"}) - public void test_previous() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - - for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.previous(dow).adjustInto(date); - - assertSame(test.getDayOfWeek(), dow, date + " " + test); - - if (test.getYear() == 2007) { - int dayDiff = test.getDayOfYear() - date.getDayOfYear(); - assertTrue(dayDiff < 0 && dayDiff > -8, dayDiff + " " + test); - } else { - assertSame(month, Month.JANUARY); - assertTrue(date.getDayOfMonth() < 8); - assertEquals(test.getYear(), 2006); - assertSame(test.getMonth(), Month.DECEMBER); - assertTrue(test.getDayOfMonth() > 24); - } - } - } - } - } - - //----------------------------------------------------------------------- - // previousOrSame() - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void factory_previousOrCurrent() { - assertNotNull(Adjusters.previousOrSame(MONDAY)); - } - - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) - public void factory_previousOrCurrent_nullDayOfWeek() { - Adjusters.previousOrSame(null); - } - - @Test(groups={"tck"}) - public void test_previousOrCurrent() { - for (Month month : Month.values()) { - for (int i = 1; i <= month.length(false); i++) { - LocalDate date = date(2007, month, i); - - for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.previousOrSame(dow).adjustInto(date); - - assertSame(test.getDayOfWeek(), dow); - - if (test.getYear() == 2007) { - int dayDiff = test.getDayOfYear() - date.getDayOfYear(); - assertTrue(dayDiff <= 0 && dayDiff > -7); - assertEquals(date.equals(test), date.getDayOfWeek() == dow); - } else { - assertFalse(date.getDayOfWeek() == dow); - assertSame(month, Month.JANUARY); - assertTrue(date.getDayOfMonth() < 7); - assertEquals(test.getYear(), 2006); - assertSame(test.getMonth(), Month.DECEMBER); - assertTrue(test.getDayOfMonth() > 25); - } - } - } - } - } - - private LocalDate date(int year, Month month, int day) { - return LocalDate.of(year, month, day); - } - - private LocalDate date(int year, int month, int day) { - return LocalDate.of(year, month, day); - } - -} --- old/test/java/time/tck/java/time/temporal/TestChronoLocalDate.java 2013-04-11 23:19:04.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.temporal; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for the built-in ISO chronology. - */ -@Test -public class TestChronoLocalDate { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of ISO calendar - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {IsoChronology.INSTANCE}, - }; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAdjuster adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.plus(1, adjuster); - Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.minus(1, adjuster); - Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalField adjuster = new FixedTemporalField(date2); - if (chrono != chrono2) { - try { - date.with(adjuster, 1); - Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster, 1); - assertEquals(result, date2, "TemporalField doWith() failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual, DATE_COMPARATOR - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_date_comparisons(Chronology chrono) { - List dates = new ArrayList<>(); - - ChronoLocalDate date = chrono.date(LocalDate.of(1900, 1, 1)); - - // Insert dates in order, no duplicates - dates.add(date.minus(1000, ChronoUnit.YEARS)); - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - dates.add(date.plus(1000, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDate d : dates) { - otherDates.add(chrono2.date(d)); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDate a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDate b = otherDates.get(j); - int cmp = ChronoLocalDate.DATE_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - public void test_date_comparator_checkGenerics_ISO() { - List dates = new ArrayList<>(); - LocalDate date = LocalDate.of(1900, 1, 1); - - // Insert dates in order, no duplicates - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - - List copy = new ArrayList<>(dates); - Collections.shuffle(copy); - Collections.sort(copy, ChronoLocalDate.DATE_COMPARATOR); - assertEquals(copy, dates); - assertTrue(ChronoLocalDate.DATE_COMPARATOR.compare(copy.get(0), copy.get(1)) < 0); - } - - public void test_date_comparator_checkGenerics_LocalDate() { - List dates = new ArrayList<>(); - LocalDate date = LocalDate.of(1900, 1, 1); - - // Insert dates in order, no duplicates - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - - List copy = new ArrayList<>(dates); - Collections.shuffle(copy); - Collections.sort(copy, ChronoLocalDate.DATE_COMPARATOR); - assertEquals(copy, dates); - assertTrue(ChronoLocalDate.DATE_COMPARATOR.compare(copy.get(0), copy.get(1)) < 0); - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoSerialization(Chronology chrono) throws Exception { - LocalDate ref = LocalDate.of(2000, 1, 5); - ChronoLocalDate orginal = chrono.date(ref); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") - ChronoLocalDate ser = (ChronoLocalDate) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} --- old/test/java/time/tck/java/time/temporal/TestChronoLocalDateTime.java 2013-04-11 23:19:05.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,471 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.temporal; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for all built-in chronologies. - */ -@Test -public class TestChronoLocalDateTime { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {HijrahChronology.INSTANCE}, - {IsoChronology.INSTANCE}, - {JapaneseChronology.INSTANCE}, - {MinguoChronology.INSTANCE}, - {ThaiBuddhistChronology.INSTANCE}}; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAdjuster adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - cdt.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - cdt.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date time"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - cdt.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - cdt.plus(1, adjuster); - Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt - + ", can not be cast to " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - cdt.minus(1, adjuster); - Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalField adjuster = new FixedTemporalField(cdt2); - if (chrono != chrono2) { - try { - cdt.with(adjuster, 1); - Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster, 1); - assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_datetime_comparisons(Chronology chrono) { - List> dates = new ArrayList<>(); - - ChronoLocalDateTime date = chrono.date(LocalDate.of(1900, 1, 1)).atTime(LocalTime.MIN); - - // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date.minus(1, ChronoUnit.HOURS)); - dates.add(date.minus(1, ChronoUnit.MINUTES)); - dates.add(date.minus(1, ChronoUnit.SECONDS)); - dates.add(date.minus(1, ChronoUnit.NANOS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.NANOS)); - dates.add(date.plus(1, ChronoUnit.SECONDS)); - dates.add(date.plus(1, ChronoUnit.MINUTES)); - dates.add(date.plus(1, ChronoUnit.HOURS)); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List> otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDateTime d : dates) { - otherDates.add(chrono2.date(d).atTime(d.toLocalTime())); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDateTime a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDateTime b = otherDates.get(j); - int cmp = ChronoLocalDateTime.DATE_TIME_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception { - LocalDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3); - ChronoLocalDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") - ChronoLocalDateTime ser = (ChronoLocalDateTime) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} --- old/test/java/time/tck/java/time/temporal/TestChronoZonedDateTime.java 2013-04-11 23:19:05.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,476 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.temporal; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for all built-in chronologies. - */ -@Test -public class TestChronoZonedDateTime { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {HijrahChronology.INSTANCE}, - {IsoChronology.INSTANCE}, - {JapaneseChronology.INSTANCE}, - {MinguoChronology.INSTANCE}, - {ThaiBuddhistChronology.INSTANCE}, - }; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalAdjuster adjuster = new FixedAdjuster(czdt2); - if (chrono != chrono2) { - try { - czdt.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + czdt + ", supplied: " + czdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - ChronoZonedDateTime result = czdt.with(adjuster); - assertEquals(result, czdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalAmount adjuster = new FixedAdjuster(czdt2); - if (chrono != chrono2) { - try { - czdt.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + czdt + ", supplied: " + czdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoZonedDateTime result = czdt.plus(adjuster); - assertEquals(result, czdt2, "WithAdjuster failed to replace date time"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalAmount adjuster = new FixedAdjuster(czdt2); - if (chrono != chrono2) { - try { - czdt.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + czdt + ", supplied: " + czdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoZonedDateTime result = czdt.minus(adjuster); - assertEquals(result, czdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalUnit adjuster = new FixedTemporalUnit(czdt2); - if (chrono != chrono2) { - try { - czdt.plus(1, adjuster); - Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException, " + czdt - + " can not be cast to " + czdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoZonedDateTime result = czdt.plus(1, adjuster); - assertEquals(result, czdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalUnit adjuster = new FixedTemporalUnit(czdt2); - if (chrono != chrono2) { - try { - czdt.minus(1, adjuster); - Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException, " + czdt.getClass() - + " can not be cast to " + czdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoZonedDateTime result = czdt.minus(1, adjuster); - assertEquals(result, czdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoZonedDateTime czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); - TemporalField adjuster = new FixedTemporalField(czdt2); - if (chrono != chrono2) { - try { - czdt.with(adjuster, 1); - Assert.fail("TemporalField doWith() should have thrown a ClassCastException, " + czdt.getClass() - + " can not be cast to " + czdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoZonedDateTime result = czdt.with(adjuster, 1); - assertEquals(result, czdt2, "TemporalField doWith() failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual, INSTANT_COMPARATOR test a Chronology against the other Chronos - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_zonedDateTime_comparisons(Chronology chrono) { - List> dates = new ArrayList<>(); - - ChronoZonedDateTime date = chrono.date(LocalDate.of(1900, 1, 1)) - .atTime(LocalTime.MIN) - .atZone(ZoneOffset.UTC); - - // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date.minus(1, ChronoUnit.HOURS)); - dates.add(date.minus(1, ChronoUnit.MINUTES)); - dates.add(date.minus(1, ChronoUnit.SECONDS)); - dates.add(date.minus(1, ChronoUnit.NANOS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.NANOS)); - dates.add(date.plus(1, ChronoUnit.SECONDS)); - dates.add(date.plus(1, ChronoUnit.MINUTES)); - dates.add(date.plus(1, ChronoUnit.HOURS)); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List> otherDates = new ArrayList<>(); - Chronology chrono2 = IsoChronology.INSTANCE; //clist[0]; - for (ChronoZonedDateTime d : dates) { - otherDates.add(chrono2.date(d).atTime(d.toLocalTime()).atZone(d.getZone())); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoZonedDateTime a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoZonedDateTime b = otherDates.get(j); - int cmp = ChronoZonedDateTime.INSTANT_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " ifAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " ifAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " ifAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception { - ZonedDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23")); - ChronoZonedDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") - ChronoZonedDateTime ser = (ChronoZonedDateTime) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} --- old/test/java/time/test/java/time/temporal/TestDateTimeAdjusters.java 2013-04-11 23:19:06.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package test.java.time.temporal; - -import java.time.temporal.*; - -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.util.Collections; - -import org.testng.annotations.Test; - -/** - * Test Adjusters. - */ -@Test(groups={"implementation"}) -public class TestDateTimeAdjusters { - - @SuppressWarnings("rawtypes") - public void test_constructor() throws Exception { - for (Constructor constructor : Adjusters.class.getDeclaredConstructors()) { - assertTrue(Modifier.isPrivate(constructor.getModifiers())); - constructor.setAccessible(true); - constructor.newInstance(Collections.nCopies(constructor.getParameterTypes().length, null).toArray()); - } - } - - public void factory_firstDayOfMonthSame() { - assertSame(Adjusters.firstDayOfMonth(), Adjusters.firstDayOfMonth()); - } - - public void factory_lastDayOfMonthSame() { - assertSame(Adjusters.lastDayOfMonth(), Adjusters.lastDayOfMonth()); - } - - public void factory_firstDayOfNextMonthSame() { - assertSame(Adjusters.firstDayOfNextMonth(), Adjusters.firstDayOfNextMonth()); - } - - public void factory_firstDayOfYearSame() { - assertSame(Adjusters.firstDayOfYear(), Adjusters.firstDayOfYear()); - } - - public void factory_lastDayOfYearSame() { - assertSame(Adjusters.lastDayOfYear(), Adjusters.lastDayOfYear()); - } - - public void factory_firstDayOfNextYearSame() { - assertSame(Adjusters.firstDayOfNextYear(), Adjusters.firstDayOfNextYear()); - } - -} --- old/test/java/time/test/java/time/temporal/TestJapaneseChronoImpl.java 2013-04-11 23:19:06.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package test.java.time.temporal; - -import static org.testng.Assert.assertEquals; - -import java.util.Calendar; -import java.util.Locale; -import java.util.TimeZone; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.temporal.ChronoField; -import java.time.chrono.ChronoLocalDate; -import java.time.temporal.ChronoUnit; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.JapaneseDate; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestJapaneseChronoImpl { - - /** - * Range of years to check consistency with java.util.Calendar - */ - @DataProvider(name="RangeVersusCalendar") - Object[][] provider_rangeVersusCalendar() { - return new Object[][] { - {LocalDate.of(1868, 1, 1), LocalDate.of(2100, 1, 1)}, - }; - } - - //----------------------------------------------------------------------- - // Verify Japanese Calendar matches java.util.Calendar for range - //----------------------------------------------------------------------- - @Test(groups={"implementation"}, dataProvider="RangeVersusCalendar") - public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { - Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); - - Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type"); - - JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate); - - // Convert to millis and set Japanese Calendar to that start date (at GMT) - OffsetDateTime jodt = OffsetDateTime.of(isoStartDate, LocalTime.MIN, ZoneOffset.UTC); - long millis = jodt.toInstant().toEpochMilli(); - cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); - cal.setTimeInMillis(millis); - - while (jDate.isBefore(isoEndDate)) { - assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); - assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate); - assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate); - - jDate = jDate.plus(1, ChronoUnit.DAYS); - cal.add(Calendar.DAY_OF_MONTH, 1); - } - } - -} --- old/test/java/time/test/java/time/temporal/TestThaiBuddhistChronoImpl.java 2013-04-11 23:19:07.000000000 -0700 +++ /dev/null 2013-02-25 15:01:43.885878341 -0800 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package test.java.time.temporal; - -import static org.testng.Assert.assertEquals; - -import java.util.Calendar; -import java.util.Locale; -import java.util.TimeZone; - -import java.time.LocalDate; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ThaiBuddhistDate; - -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; - -/** - * Test. - */ -@Test -public class TestThaiBuddhistChronoImpl { - - /** - * Range of years to check consistency with java.util.Calendar - */ - @DataProvider(name="RangeVersusCalendar") - Object[][] provider_rangeVersusCalendar() { - return new Object[][] { - {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, - }; - } - - //----------------------------------------------------------------------- - // Verify ThaiBuddhist Calendar matches java.util.Calendar for range - //----------------------------------------------------------------------- - @Test(groups={"implementation"}, dataProvider="RangeVersusCalendar") - public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { - Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist"); - assertEquals(locale.toString(), "th_TH", "Unexpected locale"); - Calendar cal = java.util.Calendar.getInstance(locale); - assertEquals(cal.getCalendarType(), "buddhist", "Unexpected calendar type"); - - ThaiBuddhistDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(isoStartDate); - - cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); - cal.set(Calendar.YEAR, thaiDate.get(ChronoField.YEAR)); - cal.set(Calendar.MONTH, thaiDate.get(ChronoField.MONTH_OF_YEAR) - 1); - cal.set(Calendar.DAY_OF_MONTH, thaiDate.get(ChronoField.DAY_OF_MONTH)); - - while (thaiDate.isBefore(isoEndDate)) { - assertEquals(thaiDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + thaiDate + "; cal: " + cal); - assertEquals(thaiDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + thaiDate); - assertEquals(thaiDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + thaiDate); - - thaiDate = thaiDate.plus(1, ChronoUnit.DAYS); - cal.add(Calendar.DAY_OF_MONTH, 1); - } - } - - private String calToString(Calendar cal) { - return String.format("%04d-%02d-%02d", - cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH)); - } - -}