You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2019/07/22 21:42:10 UTC
[juneau] branch master updated: JUNEAU-101 Update handling of dates
to use new Java 8 libraries.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 4cfab1e JUNEAU-101 Update handling of dates to use new Java 8 libraries.
4cfab1e is described below
commit 4cfab1e5a1f46ea9f46fdbe127462d5c99f7b9f4
Author: JamesBognar <ja...@apache.org>
AuthorDate: Mon Jul 22 17:41:46 2019 -0400
JUNEAU-101 Update handling of dates to use new Java 8 libraries.
---
eclipse-preferences/user-dictionary.txt | 1 +
.../org/apache/juneau/testutils/TestUtils.java | 4 +-
.../transforms/InputStreamBase64SwapTest.java | 72 +
.../apache/juneau/transforms/LocaleSwapTest.java} | 82 +-
.../juneau/transforms/OneWayStringSwapTest.java} | 62 +-
.../apache/juneau/transforms/ReaderFilterTest.java | 12 +-
.../apache/juneau/transforms/ReaderSwapTest.java} | 83 +-
.../juneau/transforms/RoundTripStringSwapTest.java | 73 +
.../transforms/TemporalCalendarSwapTest.java | 365 +++
.../juneau/transforms/TemporalDateSwapTest.java | 362 +++
.../apache/juneau/transforms/TemporalSwapTest.java | 3321 ++++++++++++++++++++
.../main/java/org/apache/juneau/BeanSession.java | 19 +
.../java/org/apache/juneau/BeanSessionArgs.java | 9 +
.../java/org/apache/juneau/internal/DateUtils.java | 471 +++
.../java/org/apache/juneau/internal/IOUtils.java | 2 +-
.../org/apache/juneau/internal/StringUtils.java | 2 +
.../java/org/apache/juneau/reflect/ClassInfo.java | 56 +-
.../org/apache/juneau/transform/StringSwap.java | 16 +
.../apache/juneau/transforms/CalendarLongSwap.java | 3 +
.../apache/juneau/transforms/CalendarMapSwap.java | 3 +
.../org/apache/juneau/transforms/CalendarSwap.java | 3 +
.../org/apache/juneau/transforms/DateLongSwap.java | 3 +
.../org/apache/juneau/transforms/DateMapSwap.java | 3 +
.../org/apache/juneau/transforms/DateSwap.java | 3 +
...darLongSwap.java => InputStreamBase64Swap.java} | 30 +-
.../{CalendarLongSwap.java => LocaleSwap.java} | 81 +-
.../{ReaderSwap.java => ParsedReaderSwap.java} | 16 +-
...CalendarLongSwap.java => ReaderStringSwap.java} | 28 +-
.../org/apache/juneau/transforms/ReaderSwap.java | 100 +-
.../juneau/transforms/TemporalCalendarSwap.java | 286 ++
.../apache/juneau/transforms/TemporalDateSwap.java | 276 ++
.../{CalendarMapSwap.java => TemporalParser.java} | 125 +-
...endarLongSwap.java => TemporalParserCache.java} | 89 +-
.../org/apache/juneau/transforms/TemporalSwap.java | 435 +++
.../{CalendarLongSwap.java => TimeZoneSwap.java} | 81 +-
juneau-doc/docs/ReleaseNotes/8.0.1.html | 7 +
36 files changed, 6139 insertions(+), 445 deletions(-)
diff --git a/eclipse-preferences/user-dictionary.txt b/eclipse-preferences/user-dictionary.txt
index 9e79ec3..f879e8b 100644
--- a/eclipse-preferences/user-dictionary.txt
+++ b/eclipse-preferences/user-dictionary.txt
@@ -498,3 +498,4 @@ transactional
rollback
enablement
stacktraces
+timezones
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/TestUtils.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/TestUtils.java
index cd9aec1..0df5ed2 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/TestUtils.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/testutils/TestUtils.java
@@ -433,12 +433,12 @@ public class TestUtils {
*
* @param name
*/
- public static final void setTimeZone(String name) {
+ public synchronized static final void setTimeZone(String name) {
systemTimeZone.set(TimeZone.getDefault());
TimeZone.setDefault(TimeZone.getTimeZone(name));
}
- public static final void unsetTimeZone() {
+ public synchronized static final void unsetTimeZone() {
TimeZone.setDefault(systemTimeZone.get());
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/InputStreamBase64SwapTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/InputStreamBase64SwapTest.java
new file mode 100644
index 0000000..f15511b
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/InputStreamBase64SwapTest.java
@@ -0,0 +1,72 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.transform.*;
+import org.apache.juneau.utils.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+@RunWith(Parameterized.class)
+public class InputStreamBase64SwapTest extends OneWayStringSwapTest<InputStream> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ private static BeanSession BS = BeanContext.DEFAULT.createBeanSession();
+ private static InputStreamBase64Swap SWAP = new InputStreamBase64Swap();
+
+ public InputStreamBase64SwapTest(String label, InputStream o, StringSwap<InputStream> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] Basic string",
+ new StringInputStream("foo"),
+ SWAP,
+ "Zm9v",
+ BS
+ },
+ {
+ "[1] Blank string",
+ new StringInputStream(""),
+ SWAP,
+ "",
+ BS
+ },
+ {
+ "[2] null",
+ null,
+ SWAP,
+ null,
+ BS
+ },
+ });
+ }
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/LocaleSwapTest.java
similarity index 50%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
copy to juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/LocaleSwapTest.java
index 0893bbb..250da50 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/LocaleSwapTest.java
@@ -15,42 +15,56 @@ package org.apache.juneau.transforms;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
-/**
- * Transforms {@link Date Dates} to {@link Map Maps} of the format <tt>{value:long}</tt>.
- */
-@SuppressWarnings("rawtypes")
-public class DateMapSwap extends PojoSwap<Date,Map> {
-
- /**
- * Converts the specified {@link Date} to a {@link Map}.
- */
- @Override /* PojoSwap */
- public Map swap(BeanSession session, Date o) {
- if (o == null)
- return null;
- ObjectMap m = new ObjectMap();
- m.put("time", o.getTime());
- return m;
+@RunWith(Parameterized.class)
+public class LocaleSwapTest extends RoundTripStringSwapTest<Locale> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ private static BeanSession BS = BeanContext.DEFAULT.createBeanSession();
+ private static LocaleSwap SWAP = new LocaleSwap();
+
+ public LocaleSwapTest(String label, Locale o, StringSwap<Locale> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
}
- /**
- * Converts the specified {@link Map} to a {@link Date}.
- */
- @Override /* PojoSwap */
- public Date unswap(BeanSession session, Map o, ClassMeta<?> hint) throws Exception {
- Class<?> c = (hint == null ? java.util.Date.class : hint.getInnerClass());
- long l = Long.parseLong(((Map<?,?>)o).get("time").toString());
- if (c == java.util.Date.class)
- return new java.util.Date(l);
- if (c == java.sql.Date.class)
- return new java.sql.Date(l);
- if (c == java.sql.Time.class)
- return new java.sql.Time(l);
- if (c == java.sql.Timestamp.class)
- return new java.sql.Timestamp(l);
- throw new ParseException("DateMapSwap is unable to narrow object of type ''{0}''", c);
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] Language only ",
+ Locale.ENGLISH,
+ SWAP,
+ "en",
+ BS
+ },
+ {
+ "[1] Language and country",
+ Locale.JAPAN,
+ SWAP,
+ "ja-JP",
+ BS
+ },
+ {
+ "[2] null",
+ null,
+ SWAP,
+ null,
+ BS
+ },
+ });
}
-}
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/OneWayStringSwapTest.java
similarity index 58%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java
copy to juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/OneWayStringSwapTest.java
index 27c373f..7f1978e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/OneWayStringSwapTest.java
@@ -12,41 +12,49 @@
// ***************************************************************************************************************************
package org.apache.juneau.transforms;
-import java.util.*;
+import static org.apache.juneau.internal.StringUtils.*;
import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
+import org.junit.*;
/**
- * Transforms {@link Date Dates} to {@link Long Longs}.
+ * Tests designed to serialize and parse objects to make sure we end up
+ * with the same objects for all serializers and parsers.
*/
-public class DateLongSwap extends PojoSwap<Date,Long> {
+public abstract class OneWayStringSwapTest<T> {
- /**
- * Converts the specified {@link Date} to a {@link Long}.
- */
- @Override /* PojoSwap */
- public Long swap(BeanSession session, Date o) {
- if (o == null)
- return null;
- return o.getTime();
+ private final String label;
+ private final T o;
+ private final StringSwap<T> ss;
+ private final String expected;
+ private final BeanSession bs;
+
+ public OneWayStringSwapTest(String label, T o, StringSwap<T> ss, String expected, BeanSession bs) throws Exception {
+ this.label = label;
+ this.o = o;
+ this.ss = ss;
+ this.expected = expected;
+ this.bs = bs;
+ }
+
+ @Test
+ public void testSwap() throws Exception {
+ String s = (String)ss.swap(bs, o);
+ if (! isEquals(expected, s)) {
+ if (expected.isEmpty()) {
+ if (! label.startsWith("[]"))
+ System.err.println(label.substring(0, label.indexOf(']')+1) + " "+s);
+ Assert.fail();
+ } else {
+ fail("Test [{0} swap] failed. Expected=[{1}], Actual=[{2}]", label, expected, s);
+ }
+ }
}
- /**
- * Converts the specified {@link Long} to a {@link Date}.
- */
- @Override /* PojoSwap */
- public Date unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- Class<?> c = (hint == null ? java.util.Date.class : hint.getInnerClass());
- if (c == java.util.Date.class)
- return new java.util.Date(o);
- if (c == java.sql.Date.class)
- return new java.sql.Date(o);
- if (c == java.sql.Time.class)
- return new java.sql.Time(o);
- if (c == java.sql.Timestamp.class)
- return new java.sql.Timestamp(o);
- throw new ParseException("DateLongSwap is unable to narrow object of type ''{0}''", c);
+ private void fail(String msg, Object...args) {
+ String s = format(msg, args);
+ System.err.println(s);
+ Assert.fail(s);
}
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderFilterTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderFilterTest.java
index 5bcb362..d122002 100755
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderFilterTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderFilterTest.java
@@ -32,7 +32,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testJson() throws Exception {
- JsonSerializer s = JsonSerializer.create().ssq().pojoSwaps(ReaderSwap.Json.class).build();
+ JsonSerializer s = JsonSerializer.create().ssq().pojoSwaps(ParsedReaderSwap.Json.class).build();
Reader r;
Map<String,Object> m;
@@ -48,7 +48,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testXml() throws Exception {
- XmlSerializer s = XmlSerializer.create().sq().pojoSwaps(ReaderSwap.Xml.class).build();
+ XmlSerializer s = XmlSerializer.create().sq().pojoSwaps(ParsedReaderSwap.Xml.class).build();
Reader r;
Map<String,Object> m;
@@ -64,7 +64,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testHtml() throws Exception {
- HtmlSerializer s = HtmlSerializer.create().sq().pojoSwaps(ReaderSwap.Html.class).build();
+ HtmlSerializer s = HtmlSerializer.create().sq().pojoSwaps(ParsedReaderSwap.Html.class).build();
Reader r;
Map<String,Object> m;
@@ -80,7 +80,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testPlainText() throws Exception {
- PlainTextSerializer s = PlainTextSerializer.create().pojoSwaps(ReaderSwap.PlainText.class).build();
+ PlainTextSerializer s = PlainTextSerializer.create().pojoSwaps(ParsedReaderSwap.PlainText.class).build();
Reader r;
Map<String,Object> m;
@@ -96,7 +96,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testUon() throws Exception {
- UonSerializer s = UonSerializer.create().pojoSwaps(ReaderSwap.Uon.class).build();
+ UonSerializer s = UonSerializer.create().pojoSwaps(ParsedReaderSwap.Uon.class).build();
Reader r;
Map<String,Object> m;
@@ -112,7 +112,7 @@ public class ReaderFilterTest {
//====================================================================================================
@Test
public void testUrlEncoding() throws Exception {
- UrlEncodingSerializer s = UrlEncodingSerializer.create().pojoSwaps(ReaderSwap.PlainText.class).build();
+ UrlEncodingSerializer s = UrlEncodingSerializer.create().pojoSwaps(ParsedReaderSwap.PlainText.class).build();
Reader r;
Map<String,Object> m;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderSwapTest.java
similarity index 50%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
copy to juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderSwapTest.java
index 0893bbb..18bcc58 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/ReaderSwapTest.java
@@ -12,45 +12,60 @@
// ***************************************************************************************************************************
package org.apache.juneau.transforms;
+import java.io.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
-/**
- * Transforms {@link Date Dates} to {@link Map Maps} of the format <tt>{value:long}</tt>.
- */
-@SuppressWarnings("rawtypes")
-public class DateMapSwap extends PojoSwap<Date,Map> {
-
- /**
- * Converts the specified {@link Date} to a {@link Map}.
- */
- @Override /* PojoSwap */
- public Map swap(BeanSession session, Date o) {
- if (o == null)
- return null;
- ObjectMap m = new ObjectMap();
- m.put("time", o.getTime());
- return m;
+@RunWith(Parameterized.class)
+public class ReaderSwapTest extends OneWayStringSwapTest<Reader> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ private static BeanSession BS = BeanContext.DEFAULT.createBeanSession();
+ private static ReaderSwap SWAP = new ReaderSwap();
+
+ public ReaderSwapTest(String label, Reader o, StringSwap<Reader> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
}
- /**
- * Converts the specified {@link Map} to a {@link Date}.
- */
- @Override /* PojoSwap */
- public Date unswap(BeanSession session, Map o, ClassMeta<?> hint) throws Exception {
- Class<?> c = (hint == null ? java.util.Date.class : hint.getInnerClass());
- long l = Long.parseLong(((Map<?,?>)o).get("time").toString());
- if (c == java.util.Date.class)
- return new java.util.Date(l);
- if (c == java.sql.Date.class)
- return new java.sql.Date(l);
- if (c == java.sql.Time.class)
- return new java.sql.Time(l);
- if (c == java.sql.Timestamp.class)
- return new java.sql.Timestamp(l);
- throw new ParseException("DateMapSwap is unable to narrow object of type ''{0}''", c);
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] Basic string",
+ new StringReader("foo"),
+ SWAP,
+ "foo",
+ BS
+ },
+ {
+ "[1] Blank string",
+ new StringReader(""),
+ SWAP,
+ "",
+ BS
+ },
+ {
+ "[2] null",
+ null,
+ SWAP,
+ null,
+ BS
+ },
+ });
}
-}
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/RoundTripStringSwapTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/RoundTripStringSwapTest.java
new file mode 100755
index 0000000..9828374
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/RoundTripStringSwapTest.java
@@ -0,0 +1,73 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import static org.apache.juneau.internal.StringUtils.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.transform.*;
+import org.junit.*;
+
+/**
+ * Tests designed to serialize and parse objects to make sure we end up
+ * with the same objects for all serializers and parsers.
+ */
+public abstract class RoundTripStringSwapTest<T> {
+
+ private final String label;
+ private final T o;
+ private final StringSwap<T> ss;
+ private final String expected;
+ private final BeanSession bs;
+
+ public RoundTripStringSwapTest(String label, T o, StringSwap<T> ss, String expected, BeanSession bs) throws Exception {
+ this.label = label;
+ this.o = o;
+ this.ss = ss;
+ this.expected = expected;
+ this.bs = bs;
+ }
+
+ @Test
+ public void testSwap() throws Exception {
+ String s = (String)ss.swap(bs, o);
+ if (! isEquals(expected, s)) {
+ if (expected.isEmpty()) {
+ if (! label.startsWith("[]"))
+ System.err.println(label.substring(0, label.indexOf(']')+1) + " "+s);
+ Assert.fail();
+ } else {
+ fail("Test [{0} swap] failed. Expected=[{1}], Actual=[{2}]", label, expected, s);
+ }
+ }
+ }
+
+ @Test
+ public void testUnswap() throws Exception {
+ String s = (String)ss.swap(bs, o);
+ T o2 = ss.unswap(bs, s, bs.getClassMetaForObject(o));
+ String s2 = (String)ss.swap(bs, o2);
+ if (! isEquals(s, s2)) {
+ if (expected.isEmpty())
+ Assert.fail();
+ System.err.println("s=["+s+"], o=["+o+"], o.type=["+o.getClass().getName()+"], o2=["+o2+"], o2.type=["+o2.getClass().getName()+"]");
+ fail("Test [{0} unswap] failed. Expected=[{1}], Actual=[{2}]", label, s, s2);
+ }
+ }
+
+ private void fail(String msg, Object...args) {
+ String s = format(msg, args);
+ System.err.println(s);
+ Assert.fail(s);
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalCalendarSwapTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalCalendarSwapTest.java
new file mode 100644
index 0000000..655b435
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalCalendarSwapTest.java
@@ -0,0 +1,365 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.format.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.testutils.*;
+import org.apache.juneau.transform.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+@RunWith(Parameterized.class)
+public class TemporalCalendarSwapTest extends RoundTripStringSwapTest<Calendar> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ @BeforeClass
+ public static void beforeClass() {
+ TestUtils.setTimeZone("GMT-5");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ TestUtils.unsetTimeZone();
+ }
+
+ private static BeanSession
+ BS_DEFAULT = BeanContext.DEFAULT.createBeanSession(),
+ BS_PST = BeanContext.DEFAULT.createBeanSession(BeanSessionArgs.create().timeZone(TimeZone.getTimeZone("PST")));
+
+ private static GregorianCalendar T_Calendar = GregorianCalendar.from(ZonedDateTime.from(DateTimeFormatter.ISO_ZONED_DATE_TIME.parse("2012-12-21T12:34:56Z")));
+ static {
+ T_Calendar.setTimeZone(TimeZone.getDefault());
+ }
+
+ public TemporalCalendarSwapTest(String label, Calendar o, StringSwap<Calendar> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // BasicIsoDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] BasicIsoDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[1] BasicIsoDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[2] IsoDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[3] IsoDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoDate(),
+ "2012-12-21-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[4] IsoDateTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoDateTime(),
+ "2012-12-21T07:34:56-05:00[America/New_York]",
+ BS_DEFAULT
+ },
+ {
+ "[5] IsoDateTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoDateTime(),
+ "2012-12-21T07:34:56-05:00[America/New_York]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoInstant
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[6] IsoInstant, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[7] IsoInstant, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[8] IsoLocalDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[9] IsoLocalDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[10] IsoLocalDateTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalDateTime(),
+ "2012-12-21T07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[11] IsoLocalDateTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalDateTime(),
+ "2012-12-21T07:34:56",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[12] IsoLocalTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalTime(),
+ "07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[13] IsoLocalTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoLocalTime(),
+ "07:34:56",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[14] IsoOffsetDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[15] IsoOffsetDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[16] IsoOffsetDateTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetDateTime(),
+ "2012-12-21T07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[17] IsoOffsetDateTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetDateTime(),
+ "2012-12-21T07:34:56-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[18] IsoOffsetTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[19] IsoOffsetTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOffsetTime(),
+ "07:34:56-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOrdinalDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[20] IsoOrdinalDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOrdinalDate(),
+ "2012-356-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[21] IsoOrdinalDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoOrdinalDate(),
+ "2012-356-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[22] IsoTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[23] IsoTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoTime(),
+ "07:34:56-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoWeekDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[24] IsoWeekDate, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoWeekDate(),
+ "2012-W51-5-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[25] IsoWeekDate, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoWeekDate(),
+ "2012-W51-5-05:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoZonedDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[26] IsoZonedDateTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoZonedDateTime(),
+ "2012-12-21T07:34:56-05:00[America/New_York]",
+ BS_DEFAULT
+ },
+ {
+ "[27] IsoZonedDateTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.IsoZonedDateTime(),
+ "2012-12-21T07:34:56-05:00[America/New_York]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Rfc1123DateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[28] Rfc1123DateTime, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 07:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[29] Rfc1123DateTime, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 07:34:56 -0500",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Custom, Year
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[30] YEAR, Default timezone",
+ T_Calendar,
+ new TemporalCalendarSwap("uuuu", Year.class, false, false),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[31] YEAR, Pacific timezone",
+ T_Calendar,
+ new TemporalCalendarSwap("uuuu", Year.class, false, false),
+ "2012",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Edge cases
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[32] BasicIsoDate, null",
+ null,
+ new TemporalCalendarSwap.BasicIsoDate(),
+ null,
+ BS_DEFAULT
+ },
+
+ });
+ }
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalDateSwapTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalDateSwapTest.java
new file mode 100644
index 0000000..6907f40
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalDateSwapTest.java
@@ -0,0 +1,362 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.format.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.testutils.*;
+import org.apache.juneau.transform.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+@RunWith(Parameterized.class)
+public class TemporalDateSwapTest extends RoundTripStringSwapTest<Date> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ @BeforeClass
+ public static void beforeClass() {
+ TestUtils.setTimeZone("GMT-5");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ TestUtils.unsetTimeZone();
+ }
+
+ private static BeanSession
+ BS_DEFAULT = BeanContext.DEFAULT.createBeanSession(),
+ BS_PST = BeanContext.DEFAULT.createBeanSession(BeanSessionArgs.create().timeZone(TimeZone.getTimeZone("PST")));
+
+ private static Date T_Date = Date.from(Instant.from(DateTimeFormatter.ISO_INSTANT.parse("2012-12-21T12:34:56Z")));
+
+ public TemporalDateSwapTest(String label, Date o, StringSwap<Date> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // BasicIsoDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] BasicIsoDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[1] BasicIsoDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[2] IsoDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[3] IsoDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[4] IsoDateTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoDateTime(),
+ "2012-12-21T07:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[5] IsoDateTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoDateTime(),
+ "2012-12-21T04:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoInstant
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[6] IsoInstant, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[7] IsoInstant, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[8] IsoLocalDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[9] IsoLocalDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[10] IsoLocalDateTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalDateTime(),
+ "2012-12-21T07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[11] IsoLocalDateTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalDateTime(),
+ "2012-12-21T04:34:56",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[12] IsoLocalTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalTime(),
+ "07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[13] IsoLocalTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoLocalTime(),
+ "04:34:56",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[14] IsoOffsetDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[15] IsoOffsetDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[16] IsoOffsetDateTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetDateTime(),
+ "2012-12-21T07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[17] IsoOffsetDateTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetDateTime(),
+ "2012-12-21T04:34:56-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[18] IsoOffsetTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[19] IsoOffsetTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOffsetTime(),
+ "04:34:56-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOrdinalDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[20] IsoOrdinalDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOrdinalDate(),
+ "2012-356-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[21] IsoOrdinalDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoOrdinalDate(),
+ "2012-356-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[22] IsoTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[23] IsoTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoTime(),
+ "04:34:56-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoWeekDate
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[24] IsoWeekDate, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoWeekDate(),
+ "2012-W51-5-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[25] IsoWeekDate, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoWeekDate(),
+ "2012-W51-5-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoZonedDateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[26] IsoZonedDateTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.IsoZonedDateTime(),
+ "2012-12-21T07:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[27] IsoZonedDateTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.IsoZonedDateTime(),
+ "2012-12-21T04:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Rfc1123DateTime
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[28] Rfc1123DateTime, Default timezone",
+ T_Date,
+ new TemporalDateSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 07:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[29] Rfc1123DateTime, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 04:34:56 -0800",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Custom, Year
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[30] YEAR, Default timezone",
+ T_Date,
+ new TemporalDateSwap("uuuu", Year.class, false),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[31] YEAR, Pacific timezone",
+ T_Date,
+ new TemporalDateSwap("uuuu", Year.class, false),
+ "2012",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Edge cases
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[32] BasicIsoDate, null",
+ null,
+ new TemporalDateSwap.BasicIsoDate(),
+ null,
+ BS_DEFAULT
+ },
+
+ });
+ }
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalSwapTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalSwapTest.java
new file mode 100644
index 0000000..7a860d5
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/transforms/TemporalSwapTest.java
@@ -0,0 +1,3321 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.chrono.*;
+import java.time.temporal.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.testutils.*;
+import org.apache.juneau.transform.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+@RunWith(Parameterized.class)
+public class TemporalSwapTest extends RoundTripStringSwapTest<Temporal> {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Setup
+ //------------------------------------------------------------------------------------------------------------------
+
+ @BeforeClass
+ public static void beforeClass() {
+ TestUtils.setTimeZone("GMT-5");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ TestUtils.unsetTimeZone();
+ }
+
+ private static BeanSession
+ BS_DEFAULT = BeanContext.DEFAULT.createBeanSession(),
+ BS_PST = BeanContext.DEFAULT.createBeanSession(BeanSessionArgs.create().timeZone(TimeZone.getTimeZone("PST")));
+
+ private static Temporal
+ DT_ZonedDateTime = ZonedDateTime.parse("2012-12-21T12:34:56Z"),
+ DT_Instant = Instant.parse("2012-12-21T12:34:56Z"),
+ DT_LocalDate = LocalDate.parse("2012-12-21"),
+ DT_LocalDateTime = LocalDateTime.parse("2012-12-21T12:34:56"),
+ DT_LocalTime = LocalTime.parse("12:34:56"),
+ DT_OffsetDateTime = OffsetDateTime.parse("2012-12-21T12:34:56-05:00"),
+ DT_OffsetTime = OffsetTime.parse("12:34:56-05:00"),
+ DT_Year = Year.parse("2012"),
+ DT_YearMonth = YearMonth.parse("2012-12");
+
+ private static Temporal
+ DT_HijrahDate = HijrahDate.from(DT_ZonedDateTime),
+ DT_JapaneseDate = JapaneseDate.from(DT_ZonedDateTime),
+ DT_MinguoDate = MinguoDate.from(DT_ZonedDateTime),
+ DT_ThaiBuddhistDate = ThaiBuddhistDate.from(DT_ZonedDateTime);
+
+ public TemporalSwapTest(String label, Temporal o, StringSwap<Temporal> s, String r, BeanSession bs) throws Exception {
+ super(label, o, s, r, bs);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getPairs() {
+ return Arrays.asList(new Object[][] {
+
+ //----------------------------------------------------------------------------------------------------------
+ // BasicIsoDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[0] BasicIsoDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[1] BasicIsoDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[2] BasicIsoDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[3] BasicIsoDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[4] BasicIsoDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.BasicIsoDate(),
+ "19700101",
+ BS_DEFAULT
+ },
+ {
+ "[5] BasicIsoDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[6] BasicIsoDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.BasicIsoDate(),
+ "19700101",
+ BS_DEFAULT
+ },
+ {
+ "[7] BasicIsoDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.BasicIsoDate(),
+ "20120101",
+ BS_DEFAULT
+ },
+ {
+ "[8] BasicIsoDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.BasicIsoDate(),
+ "20121201",
+ BS_DEFAULT
+ },
+ {
+ "[9] BasicIsoDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[10] BasicIsoDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[11] BasicIsoDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+ {
+ "[12] BasicIsoDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // BasicIsoDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+
+ {
+ "[13] BasicIsoDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[14] BasicIsoDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[15] BasicIsoDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[16] BasicIsoDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[17] BasicIsoDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.BasicIsoDate(),
+ "19700101",
+ BS_PST
+ },
+ {
+ "[18] BasicIsoDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[19] BasicIsoDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.BasicIsoDate(),
+ "19700101",
+ BS_PST
+ },
+ {
+ "[20] BasicIsoDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.BasicIsoDate(),
+ "20120101",
+ BS_PST
+ },
+ {
+ "[21] BasicIsoDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.BasicIsoDate(),
+ "20121201",
+ BS_PST
+ },
+ {
+ "[22] BasicIsoDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[23] BasicIsoDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[24] BasicIsoDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+ {
+ "[25] BasicIsoDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.BasicIsoDate(),
+ "20121221",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[26] IsoDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21Z",
+ BS_DEFAULT
+ },
+ {
+ "[27] IsoDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[28] IsoDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[29] IsoDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[30] IsoDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoDate(),
+ "1970-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[31] IsoDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[32] IsoDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoDate(),
+ "1970-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[33] IsoDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoDate(),
+ "2012-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[34] IsoDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoDate(),
+ "2012-12-01",
+ BS_DEFAULT
+ },
+ {
+ "[35] IsoDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[36] IsoDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[37] IsoDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[38] IsoDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[39] IsoDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21Z",
+ BS_PST
+ },
+ {
+ "[40] IsoDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[41] IsoDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[42] IsoDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[43] IsoDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoDate(),
+ "1970-01-01",
+ BS_PST
+ },
+ {
+ "[44] IsoDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21-05:00",
+ BS_PST
+ },
+ {
+ "[45] IsoDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoDate(),
+ "1970-01-01",
+ BS_PST
+ },
+ {
+ "[46] IsoDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoDate(),
+ "2012-01-01",
+ BS_PST
+ },
+ {
+ "[47] IsoDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoDate(),
+ "2012-12-01",
+ BS_PST
+ },
+ {
+ "[48] IsoDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[49] IsoDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[50] IsoDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[51] IsoDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoDate(),
+ "2012-12-21",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDateTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[52] IsoDateTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[53] IsoDateTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T07:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[54] IsoDateTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[55] IsoDateTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[56] IsoDateTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoDateTime(),
+ "1970-01-01T12:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[57] IsoDateTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[58] IsoDateTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[59] IsoDateTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoDateTime(),
+ "2012-01-01T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[60] IsoDateTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-01T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[61] IsoDateTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[62] IsoDateTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[63] IsoDateTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[64] IsoDateTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoDateTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[65] IsoDateTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+ {
+ "[66] IsoDateTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T04:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[67] IsoDateTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[68] IsoDateTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[69] IsoDateTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoDateTime(),
+ "1970-01-01T12:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[70] IsoDateTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[71] IsoDateTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[72] IsoDateTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoDateTime(),
+ "2012-01-01T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[73] IsoDateTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-01T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[74] IsoDateTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[75] IsoDateTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[76] IsoDateTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[77] IsoDateTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoInstant, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[78] IsoInstant, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[79] IsoInstant, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[80] IsoInstant, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[81] IsoInstant, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T17:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[82] IsoInstant, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoInstant(),
+ "1970-01-01T17:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[83] IsoInstant, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T17:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[84] IsoInstant, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoInstant(),
+ "1970-01-01T17:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[85] IsoInstant, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoInstant(),
+ "2012-01-01T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[86] IsoInstant, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-01T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[87] IsoInstant, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[88] IsoInstant, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[89] IsoInstant, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T05:00:00Z",
+ BS_DEFAULT
+ },
+ {
+ "[90] IsoInstant, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T05:00:00Z",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoInstant, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[91] IsoInstant, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+ {
+ "[92] IsoInstant, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+ {
+ "[93] IsoInstant, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[94] IsoInstant, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T20:34:56Z",
+ BS_PST
+ },
+ {
+ "[95] IsoInstant, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoInstant(),
+ "1970-01-01T20:34:56Z",
+ BS_PST
+ },
+ {
+ "[96] IsoInstant, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T17:34:56Z",
+ BS_PST
+ },
+ {
+ "[97] IsoInstant, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoInstant(),
+ "1970-01-01T17:34:56Z",
+ BS_PST
+ },
+ {
+ "[98] IsoInstant, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoInstant(),
+ "2012-01-01T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[99] IsoInstant, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-01T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[100] IsoInstant, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[101] IsoInstant, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[102] IsoInstant, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T08:00:00Z",
+ BS_PST
+ },
+ {
+ "[103] IsoInstant, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoInstant(),
+ "2012-12-21T08:00:00Z",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[104] IsoLocalDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[105] IsoLocalDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[106] IsoLocalDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[107] IsoLocalDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[108] IsoLocalDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalDate(),
+ "1970-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[109] IsoLocalDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[110] IsoLocalDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalDate(),
+ "1970-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[111] IsoLocalDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-01-01",
+ BS_DEFAULT
+ },
+ {
+ "[112] IsoLocalDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-01",
+ BS_DEFAULT
+ },
+ {
+ "[113] IsoLocalDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[114] IsoLocalDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[115] IsoLocalDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+ {
+ "[116] IsoLocalDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[117] IsoLocalDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[118] IsoLocalDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[119] IsoLocalDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[120] IsoLocalDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[121] IsoLocalDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalDate(),
+ "1970-01-01",
+ BS_PST
+ },
+ {
+ "[122] IsoLocalDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[123] IsoLocalDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalDate(),
+ "1970-01-01",
+ BS_PST
+ },
+ {
+ "[124] IsoLocalDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-01-01",
+ BS_PST
+ },
+ {
+ "[125] IsoLocalDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-01",
+ BS_PST
+ },
+ {
+ "[126] IsoLocalDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[127] IsoLocalDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[128] IsoLocalDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+ {
+ "[129] IsoLocalDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalDate(),
+ "2012-12-21",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDateTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[130] IsoLocalDateTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[131] IsoLocalDateTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[132] IsoLocalDateTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[133] IsoLocalDateTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[134] IsoLocalDateTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "1970-01-01T12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[135] IsoLocalDateTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[136] IsoLocalDateTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "1970-01-01T12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[137] IsoLocalDateTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-01-01T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[138] IsoLocalDateTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-01T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[139] IsoLocalDateTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[140] IsoLocalDateTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[141] IsoLocalDateTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[142] IsoLocalDateTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalDateTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[143] IsoLocalDateTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_PST
+ },
+ {
+ "[144] IsoLocalDateTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T04:34:56",
+ BS_PST
+ },
+ {
+ "[145] IsoLocalDateTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_PST
+ },
+ {
+ "[146] IsoLocalDateTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_PST
+ },
+ {
+ "[147] IsoLocalDateTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "1970-01-01T12:34:56",
+ BS_PST
+ },
+ {
+ "[148] IsoLocalDateTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T12:34:56",
+ BS_PST
+ },
+ {
+ "[149] IsoLocalDateTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalDateTime(),
+ "1970-01-01T12:34:56",
+ BS_PST
+ },
+ {
+ "[150] IsoLocalDateTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-01-01T00:00:00",
+ BS_PST
+ },
+ {
+ "[151] IsoLocalDateTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-01T00:00:00",
+ BS_PST
+ },
+ {
+ "[152] IsoLocalDateTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_PST
+ },
+ {
+ "[153] IsoLocalDateTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_PST
+ },
+ {
+ "[154] IsoLocalDateTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_PST
+ },
+ {
+ "[155] IsoLocalDateTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalDateTime(),
+ "2012-12-21T00:00:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[156] IsoLocalTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[157] IsoLocalTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalTime(),
+ "07:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[158] IsoLocalTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[159] IsoLocalTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[160] IsoLocalTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[161] IsoLocalTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[162] IsoLocalTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[163] IsoLocalTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[164] IsoLocalTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[165] IsoLocalTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[166] IsoLocalTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[167] IsoLocalTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+ {
+ "[168] IsoLocalTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoLocalTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[169] IsoLocalTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[170] IsoLocalTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoLocalTime(),
+ "04:34:56",
+ BS_PST
+ },
+ {
+ "[171] IsoLocalTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[172] IsoLocalTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[173] IsoLocalTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[174] IsoLocalTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[175] IsoLocalTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoLocalTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[176] IsoLocalTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[177] IsoLocalTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[178] IsoLocalTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[179] IsoLocalTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[180] IsoLocalTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+ {
+ "[181] IsoLocalTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoLocalTime(),
+ "00:00:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[182] IsoOffsetDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21Z",
+ BS_DEFAULT
+ },
+ {
+ "[183] IsoOffsetDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[184] IsoOffsetDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[185] IsoOffsetDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[186] IsoOffsetDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "1970-01-01-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[187] IsoOffsetDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[188] IsoOffsetDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "1970-01-01-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[189] IsoOffsetDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-01-01-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[190] IsoOffsetDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-01-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[191] IsoOffsetDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[192] IsoOffsetDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[193] IsoOffsetDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[194] IsoOffsetDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[195] IsoOffsetDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21Z",
+ BS_PST
+ },
+ {
+ "[196] IsoOffsetDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[197] IsoOffsetDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[198] IsoOffsetDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[199] IsoOffsetDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "1970-01-01-08:00",
+ BS_PST
+ },
+ {
+ "[200] IsoOffsetDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-05:00",
+ BS_PST
+ },
+ {
+ "[201] IsoOffsetDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetDate(),
+ "1970-01-01-05:00",
+ BS_PST
+ },
+ {
+ "[202] IsoOffsetDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-01-01-08:00",
+ BS_PST
+ },
+ {
+ "[203] IsoOffsetDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-01-08:00",
+ BS_PST
+ },
+ {
+ "[204] IsoOffsetDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[205] IsoOffsetDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[206] IsoOffsetDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+ {
+ "[207] IsoOffsetDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetDate(),
+ "2012-12-21-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDateTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[208] IsoOffsetDateTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[209] IsoOffsetDateTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[210] IsoOffsetDateTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[211] IsoOffsetDateTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[212] IsoOffsetDateTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[213] IsoOffsetDateTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[214] IsoOffsetDateTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[215] IsoOffsetDateTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-01-01T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[216] IsoOffsetDateTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-01T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[217] IsoOffsetDateTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[218] IsoOffsetDateTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[219] IsoOffsetDateTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[220] IsoOffsetDateTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-05:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetDateTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[221] IsoOffsetDateTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+ {
+ "[222] IsoOffsetDateTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T04:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[223] IsoOffsetDateTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[224] IsoOffsetDateTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[225] IsoOffsetDateTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "1970-01-01T12:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[226] IsoOffsetDateTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[227] IsoOffsetDateTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[228] IsoOffsetDateTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-01-01T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[229] IsoOffsetDateTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-01T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[230] IsoOffsetDateTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[231] IsoOffsetDateTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[232] IsoOffsetDateTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[233] IsoOffsetDateTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetDateTime(),
+ "2012-12-21T00:00:00-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[234] IsoOffsetTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[235] IsoOffsetTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[236] IsoOffsetTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[237] IsoOffsetTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[238] IsoOffsetTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[239] IsoOffsetTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[240] IsoOffsetTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[241] IsoOffsetTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[242] IsoOffsetTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[243] IsoOffsetTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[244] IsoOffsetTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[245] IsoOffsetTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[246] IsoOffsetTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOffsetTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[247] IsoOffsetTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56Z",
+ BS_PST
+ },
+ {
+ "[248] IsoOffsetTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOffsetTime(),
+ "04:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[249] IsoOffsetTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[250] IsoOffsetTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[251] IsoOffsetTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[252] IsoOffsetTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[253] IsoOffsetTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOffsetTime(),
+ "12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[254] IsoOffsetTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[255] IsoOffsetTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[256] IsoOffsetTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[257] IsoOffsetTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[258] IsoOffsetTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[259] IsoOffsetTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOffsetTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOrdinalDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[260] IsoOrdinalDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356Z",
+ BS_DEFAULT
+ },
+ {
+ "[261] IsoOrdinalDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[262] IsoOrdinalDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[263] IsoOrdinalDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[264] IsoOrdinalDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "1970-001",
+ BS_DEFAULT
+ },
+ {
+ "[265] IsoOrdinalDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[266] IsoOrdinalDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "1970-001",
+ BS_DEFAULT
+ },
+ {
+ "[267] IsoOrdinalDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-001",
+ BS_DEFAULT
+ },
+ {
+ "[268] IsoOrdinalDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-336",
+ BS_DEFAULT
+ },
+ {
+ "[269] IsoOrdinalDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[270] IsoOrdinalDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[271] IsoOrdinalDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+ {
+ "[272] IsoOrdinalDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoOrdinalDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[273] IsoOrdinalDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356Z",
+ BS_PST
+ },
+ {
+ "[274] IsoOrdinalDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[275] IsoOrdinalDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[276] IsoOrdinalDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[277] IsoOrdinalDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "1970-001",
+ BS_PST
+ },
+ {
+ "[278] IsoOrdinalDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356-05:00",
+ BS_PST
+ },
+ {
+ "[279] IsoOrdinalDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoOrdinalDate(),
+ "1970-001",
+ BS_PST
+ },
+ {
+ "[280] IsoOrdinalDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-001",
+ BS_PST
+ },
+ {
+ "[281] IsoOrdinalDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-336",
+ BS_PST
+ },
+ {
+ "[282] IsoOrdinalDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[283] IsoOrdinalDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[284] IsoOrdinalDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+ {
+ "[285] IsoOrdinalDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoOrdinalDate(),
+ "2012-356",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[286] IsoTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[287] IsoTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoTime(),
+ "07:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[288] IsoTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[289] IsoTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[290] IsoTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56",
+ BS_DEFAULT
+ },
+ {
+ "[291] IsoTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[292] IsoTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[293] IsoTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[294] IsoTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[295] IsoTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[296] IsoTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[297] IsoTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[298] IsoTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-05:00",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[299] IsoTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56Z",
+ BS_PST
+ },
+ {
+ "[300] IsoTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoTime(),
+ "04:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[301] IsoTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[302] IsoTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-08:00",
+ BS_PST
+ },
+ {
+ "[303] IsoTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56",
+ BS_PST
+ },
+ {
+ "[304] IsoTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[305] IsoTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoTime(),
+ "12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[306] IsoTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[307] IsoTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[308] IsoTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[309] IsoTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[310] IsoTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+ {
+ "[311] IsoTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoTime(),
+ "00:00:00-08:00",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoWeekDate, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[312] IsoWeekDate, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5Z",
+ BS_DEFAULT
+ },
+ {
+ "[313] IsoWeekDate, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[314] IsoWeekDate, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[315] IsoWeekDate, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[316] IsoWeekDate, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoWeekDate(),
+ "1970-W01-4",
+ BS_DEFAULT
+ },
+ {
+ "[317] IsoWeekDate, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[318] IsoWeekDate, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoWeekDate(),
+ "1970-W01-4",
+ BS_DEFAULT
+ },
+ {
+ "[319] IsoWeekDate, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoWeekDate(),
+ "2011-W52-7",
+ BS_DEFAULT
+ },
+ {
+ "[320] IsoWeekDate, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W48-6",
+ BS_DEFAULT
+ },
+ {
+ "[321] IsoWeekDate, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[322] IsoWeekDate, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[323] IsoWeekDate, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+ {
+ "[324] IsoWeekDate, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoWeekDate, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[325] IsoWeekDate, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5Z",
+ BS_PST
+ },
+ {
+ "[326] IsoWeekDate, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[327] IsoWeekDate, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[328] IsoWeekDate, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[329] IsoWeekDate, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoWeekDate(),
+ "1970-W01-4",
+ BS_PST
+ },
+ {
+ "[330] IsoWeekDate, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5-05:00",
+ BS_PST
+ },
+ {
+ "[331] IsoWeekDate, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoWeekDate(),
+ "1970-W01-4",
+ BS_PST
+ },
+ {
+ "[332] IsoWeekDate, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoWeekDate(),
+ "2011-W52-7",
+ BS_PST
+ },
+ {
+ "[333] IsoWeekDate, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W48-6",
+ BS_PST
+ },
+ {
+ "[334] IsoWeekDate, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[335] IsoWeekDate, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[336] IsoWeekDate, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+ {
+ "[337] IsoWeekDate, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoWeekDate(),
+ "2012-W51-5",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoYear, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[338] IsoYear, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[339] IsoYear, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[340] IsoYear, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[341] IsoYear, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[342] IsoYear, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoYear(),
+ "1970",
+ BS_DEFAULT
+ },
+ {
+ "[343] IsoYear, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[344] IsoYear, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoYear(),
+ "1970",
+ BS_DEFAULT
+ },
+ {
+ "[345] IsoYear, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[346] IsoYear, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[347] IsoYear, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[348] IsoYear, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[349] IsoYear, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+ {
+ "[350] IsoYear, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoYear, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[351] IsoYear, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[352] IsoYear, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[353] IsoYear, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[354] IsoYear, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[355] IsoYear, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoYear(),
+ "1970",
+ BS_PST
+ },
+ {
+ "[356] IsoYear, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[357] IsoYear, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoYear(),
+ "1970",
+ BS_PST
+ },
+ {
+ "[358] IsoYear, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[359] IsoYear, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[360] IsoYear, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[361] IsoYear, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[362] IsoYear, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+ {
+ "[363] IsoYear, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoYear(),
+ "2012",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoYearMonth, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[364] IsoYearMonth, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[365] IsoYearMonth, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[366] IsoYearMonth, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[367] IsoYearMonth, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[368] IsoYearMonth, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoYearMonth(),
+ "1970-01",
+ BS_DEFAULT
+ },
+ {
+ "[369] IsoYearMonth, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[370] IsoYearMonth, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoYearMonth(),
+ "1970-01",
+ BS_DEFAULT
+ },
+ {
+ "[371] IsoYearMonth, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-01",
+ BS_DEFAULT
+ },
+ {
+ "[372] IsoYearMonth, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[373] IsoYearMonth, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[374] IsoYearMonth, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[375] IsoYearMonth, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[376] IsoYearMonth, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoYearMonth, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[377] IsoYearMonth, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[378] IsoYearMonth, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[379] IsoYearMonth, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[380] IsoYearMonth, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[381] IsoYearMonth, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoYearMonth(),
+ "1970-01",
+ BS_PST
+ },
+ {
+ "[382] IsoYearMonth, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[383] IsoYearMonth, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoYearMonth(),
+ "1970-01",
+ BS_PST
+ },
+ {
+ "[384] IsoYearMonth, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-01",
+ BS_PST
+ },
+ {
+ "[385] IsoYearMonth, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[386] IsoYearMonth, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[387] IsoYearMonth, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[388] IsoYearMonth, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[389] IsoYearMonth, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoZonedDateTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[390] IsoZonedDateTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_DEFAULT
+ },
+ {
+ "[391] IsoZonedDateTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T07:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[392] IsoYearMonth, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_DEFAULT
+ },
+ {
+ "[393] IsoZonedDateTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[394] IsoZonedDateTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "1970-01-01T12:34:56-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[395] IsoZonedDateTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[396] IsoZonedDateTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_DEFAULT
+ },
+ {
+ "[397] IsoZonedDateTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-01-01T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[398] IsoZonedDateTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-01T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[399] IsoZonedDateTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[400] IsoZonedDateTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[401] IsoZonedDateTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+ {
+ "[402] IsoZonedDateTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-05:00[GMT-05:00]",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // IsoZonedDateTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[403] IsoZonedDateTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56Z",
+ BS_PST
+ },
+ {
+ "[404] IsoZonedDateTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T04:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[405] IsoYearMonth, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.IsoYearMonth(),
+ "2012-12",
+ BS_PST
+ },
+ {
+ "[406] IsoZonedDateTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[407] IsoZonedDateTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "1970-01-01T12:34:56-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[408] IsoZonedDateTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[409] IsoZonedDateTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.IsoZonedDateTime(),
+ "1970-01-01T12:34:56-05:00",
+ BS_PST
+ },
+ {
+ "[410] IsoZonedDateTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-01-01T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[411] IsoZonedDateTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-01T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[412] IsoZonedDateTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[413] IsoZonedDateTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[414] IsoZonedDateTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+ {
+ "[415] IsoZonedDateTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.IsoZonedDateTime(),
+ "2012-12-21T00:00:00-08:00[America/Los_Angeles]",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Rfc1123DateTime, Default timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[416] Rfc1123DateTime, DT_ZonedDateTime, Default timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 GMT",
+ BS_DEFAULT
+ },
+ {
+ "[417] Rfc1123DateTime, DT_Instant, Default timezone",
+ DT_Instant,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 07:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[418] Rfc1123DateTime, DT_LocalDate, Default timezone",
+ DT_LocalDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[419] Rfc1123DateTime, DT_LocalDateTime, Default timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[420] Rfc1123DateTime, DT_LocalTime, Default timezone",
+ DT_LocalTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Thu, 1 Jan 1970 12:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[421] Rfc1123DateTime, DT_OffsetDateTime, Default timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[422] Rfc1123DateTime, DT_OffsetTime, Default timezone",
+ DT_OffsetTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Thu, 1 Jan 1970 12:34:56 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[423] Rfc1123DateTime, DT_Year, Default timezone",
+ DT_Year,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Sun, 1 Jan 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[424] Rfc1123DateTime, DT_YearMonth, Default timezone",
+ DT_YearMonth,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Sat, 1 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[425] Rfc1123DateTime, DT_HijrahDate, Default timezone",
+ DT_HijrahDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[426] Rfc1123DateTime, DT_JapaneseDate, Default timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[427] Rfc1123DateTime, DT_MinguoDate, Default timezone",
+ DT_MinguoDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+ {
+ "[428] Rfc1123DateTime, DT_ThaiBuddhistDate, Default timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0500",
+ BS_DEFAULT
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Rfc1123DateTime, PST timezone
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[429] Rfc1123DateTime, DT_ZonedDateTime, PST timezone",
+ DT_ZonedDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 GMT",
+ BS_PST
+ },
+ {
+ "[430] Rfc1123DateTime, DT_Instant, PST timezone",
+ DT_Instant,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 04:34:56 -0800",
+ BS_PST
+ },
+ {
+ "[431] Rfc1123DateTime, DT_LocalDate, PST timezone",
+ DT_LocalDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[432] Rfc1123DateTime, DT_LocalDateTime, PST timezone",
+ DT_LocalDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 -0800",
+ BS_PST
+ },
+ {
+ "[433] Rfc1123DateTime, DT_LocalTime, PST timezone",
+ DT_LocalTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Thu, 1 Jan 1970 12:34:56 -0800",
+ BS_PST
+ },
+ {
+ "[434] Rfc1123DateTime, DT_OffsetDateTime, PST timezone",
+ DT_OffsetDateTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 12:34:56 -0500",
+ BS_PST
+ },
+ {
+ "[435] Rfc1123DateTime, DT_OffsetTime, PST timezone",
+ DT_OffsetTime,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Thu, 1 Jan 1970 12:34:56 -0500",
+ BS_PST
+ },
+ {
+ "[436] Rfc1123DateTime, DT_Year, PST timezone",
+ DT_Year,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Sun, 1 Jan 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[437] Rfc1123DateTime, DT_YearMonth, PST timezone",
+ DT_YearMonth,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Sat, 1 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[438] Rfc1123DateTime, DT_HijrahDate, PST timezone",
+ DT_HijrahDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[439] Rfc1123DateTime, DT_JapaneseDate, PST timezone",
+ DT_JapaneseDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[440] Rfc1123DateTime, DT_MinguoDate, PST timezone",
+ DT_MinguoDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+ {
+ "[441] Rfc1123DateTime, DT_ThaiBuddhistDate, PST timezone",
+ DT_ThaiBuddhistDate,
+ new TemporalSwap.Rfc1123DateTime(),
+ "Fri, 21 Dec 2012 00:00:00 -0800",
+ BS_PST
+ },
+
+ //----------------------------------------------------------------------------------------------------------
+ // Edge cases
+ //----------------------------------------------------------------------------------------------------------
+ {
+ "[442] BasicIsoDate, null",
+ null,
+ new TemporalCalendarSwap.BasicIsoDate(),
+ null,
+ BS_DEFAULT
+ },
+
+ });
+ }
+}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index 15513d4..8b00b67 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -18,6 +18,7 @@ import static org.apache.juneau.BeanContext.*;
import java.io.*;
import java.lang.reflect.*;
+import java.time.*;
import java.util.*;
import java.util.Date;
import java.util.concurrent.atomic.*;
@@ -1503,6 +1504,24 @@ public class BeanSession extends Session {
}
/**
+ * Configuration property: Time zone.
+ *
+ * <p>
+ * The timezone is determined in the following order:
+ * <ol>
+ * <li><c>timeZone</c> parameter passed in through constructor.
+ * <li>{@link BeanContext#BEAN_timeZone} entry in parameter passed in through constructor.
+ * <li>{@link BeanContext#BEAN_timeZone} setting on bean context.
+ * </ol>
+ *
+ * @see BeanContext#BEAN_timeZone
+ * @return The session timezone, or the system timezone if not specified. Never <jk>null</jk>.
+ */
+ public final ZoneId getTimeZoneId() {
+ return timeZone == null ? ZoneId.systemDefault() : timeZone.toZoneId();
+ }
+
+ /**
* Configuration property: Use enum names.
*
* @see BeanContext#BEAN_useEnumNames
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
index 6be8f5d..5bce04d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
@@ -36,6 +36,15 @@ public class BeanSessionArgs extends SessionArgs {
*/
public BeanSessionArgs() {}
+ /**
+ * Static creator method.
+ *
+ * @return A new {@link BeanSessionArgs} object.
+ */
+ public static BeanSessionArgs create() {
+ return new BeanSessionArgs();
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Properties.
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
index e6732b1..8db1995 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
@@ -16,10 +16,16 @@ import static org.apache.juneau.internal.StringUtils.*;
import java.lang.ref.*;
import java.text.*;
+import java.time.*;
+import java.time.chrono.*;
+import java.time.format.*;
+import java.time.temporal.*;
import java.util.*;
import javax.xml.bind.*;
+import org.apache.juneau.reflect.*;
+
/**
* A utility class for parsing and formatting HTTP dates as used in cookies and other headers.
*
@@ -285,4 +291,469 @@ public final class DateUtils {
default: return in;
}
}
+
+
+ /**
+ * Returns a {@link DateTimeFormatter} using either a pattern or predefined pattern name.
+ *
+ * @param pattern The pattern (e.g. <js>"yyyy-MM-dd"</js>) or pattern name (e.g. <js>"ISO_INSTANT"</js>).
+ * @return The formatter.
+ */
+ public static DateTimeFormatter getFormatter(String pattern) {
+ if (isEmpty(pattern))
+ return DateTimeFormatter.ISO_INSTANT;
+ try {
+ FieldInfo fi = ClassInfo.of(DateTimeFormatter.class).getStaticPublicField(pattern);
+ if (fi != null)
+ return (DateTimeFormatter)fi.inner().get(null);
+ return DateTimeFormatter.ofPattern(pattern);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Returns the specified {@link Temporal} object to an {@link Instant} object.
+ *
+ * @param t The temporal object to convert.
+ * @param zoneId The time zone if not already included in temporal.
+ * @return The timestamp.
+ */
+ public static Instant toInstant(Temporal t, ZoneId zoneId) {
+ return toTemporal(t, Instant.class, zoneId);
+ }
+
+ /**
+ * Returns the specified {@link Temporal} object to a {@link ZonedDateTime} object.
+ *
+ * @param t The temporal object to convert.
+ * @param zoneId The time zone if not already included in temporal.
+ * @return The timestamp.
+ */
+ public static ZonedDateTime toZonedDateTime(Temporal t, ZoneId zoneId) {
+ return toTemporal(t, ZonedDateTime.class, zoneId);
+ }
+
+ /**
+ * Returns the specified {@link Temporal} object to a {@link Date} object.
+ *
+ * @param t The temporal object to convert.
+ * @param zoneId The time zone if not already included in temporal.
+ * @return The date.
+ */
+ public static Date toDate(Temporal t, ZoneId zoneId) {
+ return Date.from(toInstant(t, zoneId));
+ }
+
+ /**
+ * Returns the specified {@link Temporal} object to a {@link Calendar} object.
+ *
+ * @param t The temporal object to convert.
+ * @param zoneId The time zone if not already included in temporal.
+ * @return The date.
+ */
+ public static Calendar toCalendar(Temporal t, ZoneId zoneId) {
+ return GregorianCalendar.from(toZonedDateTime(t, zoneId));
+ }
+
+ private static final LocalDate ZERO_DATE = LocalDate.ofEpochDay(0);
+ private static final MonthDay ZERO_MONTHDAY = MonthDay.of(1, 1);
+ private static final LocalTime ZERO_TIME = LocalTime.MIDNIGHT;
+
+ /**
+ * Converts an arbitrary {@link Temporal} to another arbitrary {@link Temporal}
+ *
+ * @param o The temporal to convert.
+ * @param tc The target temporal class.
+ * @param zoneId The time zone if not already included in temporal.
+ * @return The converted temporal.
+ * @param <T> The target temporal class.
+ */
+ public static <T> T toTemporal(Temporal o, Class<T> tc, ZoneId zoneId) {
+ if (o == null)
+ return null;
+ T t = toTemporal2(o, tc, zoneId);
+ if (t.getClass() != tc)
+ throw new RuntimeException("Temporal=["+o.getClass().getName()+"], wanted=["+tc.getName()+"], actual=["+t.getClass().getName()+"]");
+ return t;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> T toTemporal2(Temporal o, Class<T> tc, ZoneId zoneId) {
+
+ if (o == null)
+ return null;
+
+ Class<? extends Temporal> oc = o.getClass();
+
+ if (oc == tc)
+ return (T)o;
+
+ if (zoneId == null)
+ zoneId = ZoneId.systemDefault();
+
+ if (oc == Instant.class) {
+ Instant t = (Instant)o;
+ if (tc == LocalDate.class) {
+ return (T)t.atZone(zoneId).toLocalDate();
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atZone(zoneId).toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.atZone(zoneId).toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atZone(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atZone(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atZone(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atZone(zoneId));
+ }
+ } else if (oc == LocalDate.class) {
+ LocalDate t = (LocalDate)o;
+ if (tc == Instant.class) {
+ return (T)t.atStartOfDay(zoneId).toInstant();
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atStartOfDay(zoneId).toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.atStartOfDay(zoneId).toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atStartOfDay(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atStartOfDay(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atStartOfDay(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atStartOfDay(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atStartOfDay(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atStartOfDay(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atStartOfDay(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atStartOfDay(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atStartOfDay(zoneId));
+ }
+ } else if (oc == LocalDateTime.class) {
+ LocalDateTime t = (LocalDateTime)o;
+ if (tc == Instant.class) {
+ return (T)t.atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)t.toLocalDate();
+ } else if (tc == LocalTime.class) {
+ return (T)t.toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atZone(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atZone(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atZone(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atZone(zoneId));
+ }
+ } else if (oc == LocalTime.class) {
+ LocalTime t = (LocalTime)o;
+ if (tc == Instant.class) {
+ return (T)t.atDate(ZERO_DATE).atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(0);
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atDate(ZERO_DATE);
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atDate(ZERO_DATE).atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atDate(ZERO_DATE).atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.of(1970);
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.of(1970, 1);
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atDate(ZERO_DATE).atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(ZERO_DATE.atStartOfDay(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(ZERO_DATE.atStartOfDay(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(ZERO_DATE.atStartOfDay(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(ZERO_DATE.atStartOfDay(zoneId));
+ }
+ } else if (oc == OffsetDateTime.class) {
+ OffsetDateTime t = (OffsetDateTime)o;
+ if (tc == Instant.class) {
+ return (T)t.toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)t.toLocalDate();
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.toLocalTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t);
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t);
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.toZonedDateTime();
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t);
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t);
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t);
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t);
+ }
+ } else if (oc == OffsetTime.class) {
+ OffsetTime t = (OffsetTime)o;
+ if (tc == Instant.class) {
+ return (T)t.atDate(ZERO_DATE).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(0);
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atDate(ZERO_DATE).toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.atDate(ZERO_DATE).toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atDate(ZERO_DATE);
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atDate(ZERO_DATE));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atDate(ZERO_DATE));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atDate(ZERO_DATE).toZonedDateTime();
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atDate(ZERO_DATE));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atDate(ZERO_DATE));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atDate(ZERO_DATE));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atDate(ZERO_DATE));
+ }
+ } else if (oc == Year.class) {
+ Year t = (Year)o;
+ if (tc == Instant.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY);
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId).toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)ZERO_TIME;
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == YearMonth.class) {
+ return (T)t.atMonth(1);
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atMonthDay(ZERO_MONTHDAY).atStartOfDay(zoneId));
+ }
+ } else if (oc == YearMonth.class) {
+ YearMonth t = (YearMonth)o;
+ if (tc == Instant.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toLocalDate();
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t);
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atDay(1).atStartOfDay(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atDay(1).atStartOfDay(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atDay(1).atStartOfDay(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atDay(1).atStartOfDay(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atDay(1).atStartOfDay(zoneId));
+ }
+ } else if (oc == ZonedDateTime.class) {
+ ZonedDateTime t = (ZonedDateTime)o;
+ if (tc == Instant.class) {
+ return (T)t.toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)t.toLocalDate();
+ } else if (tc == LocalDateTime.class) {
+ return (T)t.toLocalDateTime();
+ } else if (tc == LocalTime.class) {
+ return (T)t.toLocalTime();
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t);
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t);
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t);
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t);
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t);
+ }
+ } else if (oc == HijrahDate.class) {
+ HijrahDate t = (HijrahDate)o;
+ if (tc == Instant.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay());
+ } else if (tc == LocalDateTime.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay()).atTime(ZERO_TIME);
+ } else if (tc == LocalTime.class) {
+ return (T)ZERO_TIME;
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId);
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ }
+ } else if (oc == JapaneseDate.class) {
+ JapaneseDate t = (JapaneseDate)o;
+ if (tc == Instant.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay());
+ } else if (tc == LocalDateTime.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay()).atTime(ZERO_TIME);
+ } else if (tc == LocalTime.class) {
+ return (T)ZERO_TIME;
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ }
+ } else if (oc == MinguoDate.class) {
+ MinguoDate t = (MinguoDate)o;
+ if (tc == Instant.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay());
+ } else if (tc == LocalDateTime.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay()).atTime(ZERO_TIME);
+ } else if (tc == LocalTime.class) {
+ return (T)ZERO_TIME;
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ThaiBuddhistDate.class) {
+ return (T)ThaiBuddhistDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ }
+ } else if (oc == ThaiBuddhistDate.class) {
+ ThaiBuddhistDate t = (ThaiBuddhistDate)o;
+ if (tc == Instant.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant();
+ } else if (tc == LocalDate.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay());
+ } else if (tc == LocalDateTime.class) {
+ return (T)LocalDate.ofEpochDay(t.toEpochDay()).atTime(ZERO_TIME);
+ } else if (tc == LocalTime.class) {
+ return (T)ZERO_TIME;
+ } else if (tc == OffsetDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime();
+ } else if (tc == OffsetTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId).toOffsetDateTime().toOffsetTime();
+ } else if (tc == Year.class) {
+ return (T)Year.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == YearMonth.class) {
+ return (T)YearMonth.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == ZonedDateTime.class) {
+ return (T)t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId);
+ } else if (tc == HijrahDate.class) {
+ return (T)HijrahDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == JapaneseDate.class) {
+ return (T)JapaneseDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ } else if (tc == MinguoDate.class) {
+ return (T)MinguoDate.from(t.atTime(ZERO_TIME).atZone(zoneId).toInstant().atZone(zoneId));
+ }
+ }
+
+ // Last chance...try to use a static from(TemporalAccessor) method if present.
+ ClassInfo ci = ClassInfo.of(tc);
+ MethodInfo mi = ci.getStaticPublicMethod("from", tc, TemporalAccessor.class);
+ if (mi != null) {
+ try {
+ return (T)mi.inner().invoke(null, o);
+ } catch (Exception e) {}
+ }
+
+ throw new RuntimeException("Temporal type '"+o.getClass().getName()+"' cannot be converted to type '"+tc.getName()+"'.");
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
index 14475cc..63417ca 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
@@ -219,7 +219,7 @@ public final class IOUtils {
* @throws IOException Thrown by underlying stream.
*/
public static byte[] readBytes(InputStream in) throws IOException {
- return readBytes(in, 1024);
+ return in == null ? null : readBytes(in, 1024);
}
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
index 618cad1..0b5baa8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -1182,6 +1182,8 @@ public final class StringUtils {
* @return The byte array converted to a BASE-64 encoded string.
*/
public static String base64Encode(byte[] in) {
+ if (in == null)
+ return null;
int outLength = (in.length * 4 + 2) / 3; // Output length without padding
char[] out = new char[((in.length + 2) / 3) * 4]; // Length includes padding.
int iIn = 0;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
index a282b6f..ae59767 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
@@ -463,6 +463,35 @@ public final class ClassInfo {
}
/**
+ * Find the public static method with the specified name and args.
+ *
+ * @param name The method name.
+ * @param rt The method return type.
+ * @param args The method arguments
+ * @return The method, or <jk>null</jk> if it couldn't be found.
+ */
+ public MethodInfo getStaticPublicMethod(String name, Class<?> rt, Class<?>...args) {
+ if (c != null)
+ for (MethodInfo m : getPublicMethods())
+ if (m.isAll(STATIC, PUBLIC, NOT_DEPRECATED) && name.equals(m.getSimpleName()) && m.hasReturnType(rt) && m.hasArgs(args))
+ return m;
+ return null;
+ }
+
+ /**
+ * Find the public static method with the specified name and args.
+ *
+ * @param name The method name.
+ * @param rt The method return type.
+ * @param args The method arguments
+ * @return The method, or <jk>null</jk> if it couldn't be found.
+ */
+ public Method getStaticPublicMethodInner(String name, Class<?> rt, Class<?>...args) {
+ MethodInfo mi = getStaticPublicMethod(name, rt, args);
+ return mi == null ? null : mi.inner();
+ }
+
+ /**
* Returns the <c>public static Builder create()</c> method on this class.
*
* @return The <c>public static Builder create()</c> method on this class, or <jk>null</jk> if it doesn't exist.
@@ -750,7 +779,6 @@ public final class ClassInfo {
return m;
}
-
/**
* Returns the public field with the specified name.
*
@@ -777,6 +805,32 @@ public final class ClassInfo {
return null;
}
+ /**
+ * Returns the static public field with the specified name.
+ *
+ * @param name The field name.
+ * @return The public field, or <jk>null</jk> if not found.
+ */
+ public FieldInfo getStaticPublicField(String name) {
+ for (FieldInfo f : getPublicFields())
+ if (f.isStatic() && f.getName().equals(name))
+ return f;
+ return null;
+ }
+
+ /**
+ * Returns the static public field with the specified name.
+ *
+ * @param name The field name.
+ * @return The public field, or <jk>null</jk> if not found.
+ */
+ public Field getStaticPublicFieldInner(String name) {
+ for (FieldInfo f : getPublicFields())
+ if (f.isStatic() && f.getName().equals(name))
+ return f.inner();
+ return null;
+ }
+
//-----------------------------------------------------------------------------------------------------------------
// Annotations
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/StringSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/StringSwap.java
index 70159bb..3c1852d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/StringSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/StringSwap.java
@@ -42,6 +42,22 @@ import org.apache.juneau.*;
*/
public abstract class StringSwap<T> extends PojoSwap<T,String> {
+ /**
+ * Constructor.
+ */
+ protected StringSwap() {
+ super();
+ }
+
+ /**
+ * Constructor for when the normal and transformed classes are already known.
+ *
+ * @param normalClass The normal class (cannot be serialized).
+ */
+ protected StringSwap(Class<T> normalClass) {
+ super(normalClass, String.class);
+ }
+
@Override /* PojoSwap */
public String swap(BeanSession session, T o) throws Exception {
return super.swap(session, o);
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
index 7da3952..844be81 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
@@ -19,7 +19,10 @@ import org.apache.juneau.transform.*;
/**
* Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
+ *
+ * @deprecated Use {@link TemporalCalendarSwap}
*/
+@Deprecated
public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
index 06e7c33..227faf5 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
@@ -19,7 +19,10 @@ import org.apache.juneau.transform.*;
/**
* Transforms {@link Calendar Calendars} to {@link Map Maps} of the format <c>{time:long,timeZone:string}</c>.
+ *
+ * @deprecated Use {@link TemporalCalendarSwap}
*/
+@Deprecated
@SuppressWarnings("rawtypes")
public class CalendarMapSwap extends PojoSwap<Calendar,Map> {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
index 8f82cf9..3c54828 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
@@ -53,7 +53,10 @@ import org.apache.juneau.utils.*;
* <li>{@link DateTimeMedium} - To {@link DateFormat#MEDIUM} date-time strings.
* <li>{@link DateTimeShort} - To {@link DateFormat#SHORT} date-time strings.
* </ul>
+ *
+ * @deprecated Use {@link TemporalCalendarSwap}
*/
+@Deprecated
public class CalendarSwap extends StringSwap<Calendar> {
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java
index 27c373f..bc489fc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateLongSwap.java
@@ -20,7 +20,10 @@ import org.apache.juneau.transform.*;
/**
* Transforms {@link Date Dates} to {@link Long Longs}.
+ *
+ * @deprecated Use {@link TemporalDateSwap}
*/
+@Deprecated
public class DateLongSwap extends PojoSwap<Date,Long> {
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
index 0893bbb..22a8c95 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateMapSwap.java
@@ -20,7 +20,10 @@ import org.apache.juneau.transform.*;
/**
* Transforms {@link Date Dates} to {@link Map Maps} of the format <tt>{value:long}</tt>.
+ *
+ * @deprecated Use {@link TemporalDateSwap}
*/
+@Deprecated
@SuppressWarnings("rawtypes")
public class DateMapSwap extends PojoSwap<Date,Map> {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateSwap.java
index 0c14bcb..d6a92dd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/DateSwap.java
@@ -53,7 +53,10 @@ import org.apache.juneau.utils.*;
* <li>{@link DateTimeMedium} - To {@link DateFormat#MEDIUM} date-time strings.
* <li>{@link DateTimeShort} - To {@link DateFormat#SHORT} date-time strings.
* </ul>
+ *
+ * @deprecated Use {@link TemporalDateSwap}
*/
+@Deprecated
public class DateSwap extends StringSwap<Date> {
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/InputStreamBase64Swap.java
similarity index 65%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/InputStreamBase64Swap.java
index 7da3952..39c8444 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/InputStreamBase64Swap.java
@@ -12,36 +12,24 @@
// ***************************************************************************************************************************
package org.apache.juneau.transforms;
-import java.util.*;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.io.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.transform.*;
/**
- * Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
+ * Transforms <code>InputStreams</code> to BASE-64 encoded {@link String Strings}.
*/
-public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
-
- /**
- * Converts the specified {@link Calendar} to a {@link Long}.
- */
- @Override /* PojoSwap */
- public Long swap(BeanSession session, Calendar o) {
- return o.getTime().getTime();
- }
+public class InputStreamBase64Swap extends StringSwap<InputStream> {
/**
- * Converts the specified {@link Long} to a {@link Calendar}.
+ * Converts the specified {@link InputStream} to a {@link String}.
*/
@Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- Calendar c = tt.newInstance();
- c.setTimeInMillis(o);
- return c;
+ public String swap(BeanSession session, InputStream is) throws Exception {
+ return base64Encode(IOUtils.readBytes(is));
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/LocaleSwap.java
similarity index 68%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/LocaleSwap.java
index 7da3952..7d6dc80 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/LocaleSwap.java
@@ -1,47 +1,34 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.transforms;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.transform.*;
-
-/**
- * Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
- */
-public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
-
- /**
- * Converts the specified {@link Calendar} to a {@link Long}.
- */
- @Override /* PojoSwap */
- public Long swap(BeanSession session, Calendar o) {
- return o.getTime().getTime();
- }
-
- /**
- * Converts the specified {@link Long} to a {@link Calendar}.
- */
- @Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- Calendar c = tt.newInstance();
- c.setTimeInMillis(o);
- return c;
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * Transforms {@link Locale} objects to and from language tag {@link String Strings}.
+ */
+public class LocaleSwap extends StringSwap<Locale> {
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Locale o) throws Exception {
+ return o == null ? null : o.toLanguageTag();
+ }
+
+ @Override /* PojoSwap */
+ public Locale unswap(BeanSession session, String o, ClassMeta<?> hint) throws Exception {
+ return o == null ? null : Locale.forLanguageTag(o);
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ParsedReaderSwap.java
similarity index 87%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ParsedReaderSwap.java
index 943574c..836ed42 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ParsedReaderSwap.java
@@ -49,10 +49,10 @@ import org.apache.juneau.xml.*;
* <li>{@link PlainText} - Parses plain text.
* </ul>
*/
-public class ReaderSwap extends PojoSwap<Reader,Object> {
+public class ParsedReaderSwap extends PojoSwap<Reader,Object> {
/** Reader transform for reading JSON text. */
- public static class Json extends ReaderSwap {
+ public static class Json extends ParsedReaderSwap {
/** Constructor */
public Json() {
super(JsonParser.DEFAULT);
@@ -60,7 +60,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
}
/** Reader transform for reading XML text. */
- public static class Xml extends ReaderSwap {
+ public static class Xml extends ParsedReaderSwap {
/** Constructor */
public Xml() {
super(XmlParser.DEFAULT);
@@ -68,7 +68,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
}
/** Reader transform for reading HTML text. */
- public static class Html extends ReaderSwap {
+ public static class Html extends ParsedReaderSwap {
/** Constructor */
public Html() {
super(HtmlParser.DEFAULT);
@@ -76,7 +76,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
}
/** Reader transform for reading plain text. */
- public static class PlainText extends ReaderSwap {
+ public static class PlainText extends ParsedReaderSwap {
/** Constructor */
public PlainText() {
super(null);
@@ -84,7 +84,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
}
/** Reader transform for reading plain text. */
- public static class Uon extends ReaderSwap {
+ public static class Uon extends ParsedReaderSwap {
/** Constructor */
public Uon() {
super(UonParser.DEFAULT);
@@ -92,7 +92,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
}
/** Reader transform for reading plain text. */
- public static class UrlEncoding extends ReaderSwap {
+ public static class UrlEncoding extends ParsedReaderSwap {
/** Constructor */
public UrlEncoding() {
super(UrlEncodingParser.DEFAULT);
@@ -105,7 +105,7 @@ public class ReaderSwap extends PojoSwap<Reader,Object> {
/**
* @param parser The parser to use to convert the contents of the reader to Java objects.
*/
- public ReaderSwap(ReaderParser parser) {
+ public ParsedReaderSwap(ReaderParser parser) {
this.parser = parser;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderStringSwap.java
similarity index 65%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderStringSwap.java
index 7da3952..23e3c23 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderStringSwap.java
@@ -12,36 +12,22 @@
// ***************************************************************************************************************************
package org.apache.juneau.transforms;
-import java.util.*;
+import java.io.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.transform.*;
/**
- * Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
+ * Transforms the contents of a {@link Reader} into a {@code String}.
*/
-public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
+public class ReaderStringSwap extends StringSwap<Reader> {
/**
- * Converts the specified {@link Calendar} to a {@link Long}.
+ * Converts the specified {@link Reader} to a {@link String}.
*/
@Override /* PojoSwap */
- public Long swap(BeanSession session, Calendar o) {
- return o.getTime().getTime();
- }
-
- /**
- * Converts the specified {@link Long} to a {@link Calendar}.
- */
- @Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- Calendar c = tt.newInstance();
- c.setTimeInMillis(o);
- return c;
+ public String swap(BeanSession session, Reader o) throws Exception {
+ return IOUtils.read(o);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java
index 943574c..3b635af 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/ReaderSwap.java
@@ -12,110 +12,22 @@
// ***************************************************************************************************************************
package org.apache.juneau.transforms;
-import static org.apache.juneau.internal.IOUtils.*;
-
import java.io.*;
import org.apache.juneau.*;
-import org.apache.juneau.html.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.transform.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.xml.*;
/**
- * Transforms the contents of a {@link Reader} into an {@code Object}.
- *
- * <h5 class='topic'>Description</h5>
- *
- * The {@code Reader} must contain JSON, Juneau-generated XML (output from {@link XmlSerializer}), or Juneau-generated
- * HTML (output from {@link JsonSerializer}) in order to be parsed correctly.
- *
- * <p>
- * Useful for serializing models that contain {@code Readers} created by {@code RestCall} instances.
- *
- * <p>
- * This is a one-way transform, since {@code Readers} cannot be reconstituted.
- *
- * <h5 class='topic'>Behavior-specific subclasses</h5>
- *
- * The following direct subclasses are provided for convenience:
- * <ul>
- * <li>{@link Json} - Parses JSON text.
- * <li>{@link Xml} - Parses XML text.
- * <li>{@link Html} - Parses HTML text.
- * <li>{@link PlainText} - Parses plain text.
- * </ul>
+ * Transforms <code>Readers</code> to {@link String Strings}.
*/
-public class ReaderSwap extends PojoSwap<Reader,Object> {
-
- /** Reader transform for reading JSON text. */
- public static class Json extends ReaderSwap {
- /** Constructor */
- public Json() {
- super(JsonParser.DEFAULT);
- }
- }
-
- /** Reader transform for reading XML text. */
- public static class Xml extends ReaderSwap {
- /** Constructor */
- public Xml() {
- super(XmlParser.DEFAULT);
- }
- }
-
- /** Reader transform for reading HTML text. */
- public static class Html extends ReaderSwap {
- /** Constructor */
- public Html() {
- super(HtmlParser.DEFAULT);
- }
- }
-
- /** Reader transform for reading plain text. */
- public static class PlainText extends ReaderSwap {
- /** Constructor */
- public PlainText() {
- super(null);
- }
- }
-
- /** Reader transform for reading plain text. */
- public static class Uon extends ReaderSwap {
- /** Constructor */
- public Uon() {
- super(UonParser.DEFAULT);
- }
- }
-
- /** Reader transform for reading plain text. */
- public static class UrlEncoding extends ReaderSwap {
- /** Constructor */
- public UrlEncoding() {
- super(UrlEncodingParser.DEFAULT);
- }
- }
-
- /** The parser to use to parse the contents of the Reader. */
- private ReaderParser parser;
-
- /**
- * @param parser The parser to use to convert the contents of the reader to Java objects.
- */
- public ReaderSwap(ReaderParser parser) {
- this.parser = parser;
- }
+public class ReaderSwap extends StringSwap<Reader> {
/**
- * Converts the specified {@link Reader} to an {@link Object} whose type is determined by the contents of the reader.
+ * Converts the specified {@link InputStream} to a {@link String}.
*/
@Override /* PojoSwap */
- public Object swap(BeanSession session, Reader o) throws Exception {
- if (parser == null)
- return read(o);
- return parser.parse(o, Object.class);
+ public String swap(BeanSession session, Reader r) throws Exception {
+ return IOUtils.read(r);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalCalendarSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalCalendarSwap.java
new file mode 100644
index 0000000..82afa6d
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalCalendarSwap.java
@@ -0,0 +1,286 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.format.*;
+import java.time.temporal.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * Swap that converts {@link Calendar} objects to and from strings.
+ *
+ * <p>
+ * Uses the {@link DateTimeFormatter} class for converting {@link Calendar} objects.
+ *
+ * <p>
+ * Serialization is relatively straightforward. The <c>Calendar</c> object is converted to a {@linked ZonedDateTime}.
+ * Then the <c>ZonedDateTime</c> object is passed to the {@link DateTimeFormatter#format(TemporalAccessor)} method to produce
+ * the string value.
+ *
+ * <p>
+ * Parsing is a little more complicated. The <js>string</js> is parsed into an intermediate {@link Temporal} object before
+ * being converted into a <c>Calendar</c>. The intermediate type can be any of the following:
+ * <ul>
+ * <li>{@link LocalDate} - For patterns containing dates without timezones.
+ * <li>{@link LocalTime} - For patterns containing times without timezones.
+ * <li>{@link LocalDateTime} - For patterns containing date-times without timezones.
+ * <li>{@link ZonedDateTime} - For patterns containing date-times with timezones.
+ * <li>{@link Instant} - For date-times with Zulu timezone.
+ * <li>{@link OffsetDateTime} - For date-times with timezone offsets.
+ * <li>{@link OffsetTime} - For times with timezone offsets.
+ * </ul>
+ */
+public class TemporalCalendarSwap extends StringSwap<Calendar> {
+
+ /**
+ * Default swap to {@link DateTimeFormatter#BASIC_ISO_DATE}.
+ * <p>
+ * Example: <js>"20111203"</js>
+ */
+ public static class BasicIsoDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public BasicIsoDate() {
+ super("BASIC_ISO_DATE", LocalDate.class, true, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03+01:00"</js> or <js>"2011-12-03"</js>
+ */
+ public static class IsoDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoDate() {
+ super("ISO_DATE", LocalDate.class, false, true);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoDateTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoDateTime() {
+ super("ISO_DATE_TIME", ZonedDateTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_INSTANT}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30Z"</js>
+ */
+ public static class IsoInstant extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoInstant() {
+ super("ISO_INSTANT", Instant.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoLocalDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoLocalDate() {
+ super("ISO_LOCAL_DATE", LocalDate.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30"</js>
+ */
+ public static class IsoLocalDateTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoLocalDateTime() {
+ super("ISO_LOCAL_DATE_TIME", LocalDateTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_TIME}.
+ * <p>
+ * Example: <js>"10:15:30"</js>
+ */
+ public static class IsoLocalTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoLocalTime() {
+ super("ISO_LOCAL_TIME", LocalTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoOffsetDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoOffsetDate() {
+ super("ISO_OFFSET_DATE", LocalDate.class, false, true);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetDateTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoOffsetDateTime() {
+ super("ISO_OFFSET_DATE_TIME", OffsetDateTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoOffsetTime() {
+ super("ISO_OFFSET_TIME", OffsetTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ORDINAL_DATE}.
+ * <p>
+ * Example: <js>"2012-337"</js>
+ */
+ public static class IsoOrdinalDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoOrdinalDate() {
+ super("ISO_ORDINAL_DATE", LocalDate.class, false, true);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js> or <js>"10:15:30"</js>
+ */
+ public static class IsoTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoTime() {
+ super("ISO_TIME", OffsetTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_WEEK_DATE}.
+ * <p>
+ * Example: <js>"2012-W48-6"</js>
+ */
+ public static class IsoWeekDate extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoWeekDate() {
+ super("ISO_WEEK_DATE", LocalDate.class, false, true);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ZONED_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoZonedDateTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public IsoZonedDateTime() {
+ super("ISO_ZONED_DATE_TIME", ZonedDateTime.class, false, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#RFC_1123_DATE_TIME}.
+ * <p>
+ * Example: <js>"Tue, 3 Jun 2008 11:05:30 GMT"</js>
+ */
+ public static class Rfc1123DateTime extends TemporalCalendarSwap {
+ /** Constructor.*/
+ public Rfc1123DateTime() {
+ super("RFC_1123_DATE_TIME", ZonedDateTime.class, false, false);
+ }
+ };
+
+
+ private final TemporalParser<? extends Temporal> intermediateParser;
+ private final DateTimeFormatter formatter;
+ private final boolean serializeWithoutTimezone, parseTimezoneSeparately;
+
+ /**
+ * Constructor.
+ *
+ * @param pattern The timestamp format or name of predefined {@link DateTimeFormatter}.
+ * @param intermediateType The intermediate Java 8 data type to parse into before converting to a Calendar object.
+ * @param serializeWithoutTimezone <jk>true</jk> if the date should be converted to local-date-time before serialization.
+ * @param parseTimezoneSeparately <jk>true</jk> if the time zone should be persisted on parsing when {@link LocalDate} is the intermediate type.
+ */
+ public TemporalCalendarSwap(String pattern, Class<? extends Temporal> intermediateType, boolean serializeWithoutTimezone, boolean parseTimezoneSeparately) {
+ super(Calendar.class);
+ this.intermediateParser = TemporalParserCache.getTemporalParser(intermediateType);
+ this.formatter = DateUtils.getFormatter(pattern);
+ this.serializeWithoutTimezone = serializeWithoutTimezone;
+ this.parseTimezoneSeparately = parseTimezoneSeparately;
+ }
+
+ /**
+ * Converts the specified intermediate {@link Temporal} object to a {@link Calendar} object.
+ *
+ * @param bs The current bean session.
+ * @param temporal The intermediate temporal object.
+ * @return The converted date.
+ */
+ protected Calendar toCalendar(BeanSession bs, Temporal temporal) {
+ return DateUtils.toCalendar(temporal, bs.getTimeZoneId());
+ }
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Calendar o) throws Exception {
+ if (o == null)
+ return null;
+ ZonedDateTime t = o instanceof GregorianCalendar ? ((GregorianCalendar)o).toZonedDateTime() : o.toInstant().atZone(session.getTimeZoneId());
+ return formatter.format(serializeWithoutTimezone ? t.toLocalDateTime() : t);
+ }
+
+ @Override /* PojoSwap */
+ public Calendar unswap(BeanSession session, String f, ClassMeta<?> hint) throws Exception {
+ if (f == null)
+ return null;
+ Temporal t = intermediateParser.parse(f, formatter);
+
+ if (parseTimezoneSeparately) {
+ TemporalAccessor ta = formatter.parse(f);
+ if (ta.query(TemporalQueries.zone()) != null) {
+ ZoneId offset = ZoneId.from(ta);
+ t = ((LocalDate)t).atStartOfDay(offset);
+ }
+ }
+
+ return toCalendar(session, t);
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalDateSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalDateSwap.java
new file mode 100644
index 0000000..d17cade
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalDateSwap.java
@@ -0,0 +1,276 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.format.*;
+import java.time.temporal.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * Swap that converts {@link Date} objects to and from strings.
+ *
+ * <p>
+ * Uses the {@link DateTimeFormatter} class for converting {@link Date} objects.
+ *
+ * <p>
+ * Serialization is relatively straightforward. The <c>Date</c> object is converted to a {@linked ZonedDateTime}
+ * object using the time zone defined by the {@link BeanSession#getTimeZoneId()} method. Then the
+ * <c>ZonedDateTime</c> object is passed to the {@link DateTimeFormatter#format(TemporalAccessor)} method to produce
+ * the string value.
+ *
+ * <p>
+ * Parsing is a little more complicated. The string is parsed into an intermediate {@link Temporal} object before
+ * being converted into a <c>Date</c>. The intermediate type can be any of the following:
+ * <ul>
+ * <li>{@link LocalDate} - For patterns containing dates without timezones.
+ * <li>{@link LocalTime} - For patterns containing times without timezones.
+ * <li>{@link LocalDateTime} - For patterns containing date-times without timezones.
+ * <li>{@link ZonedDateTime} - For patterns containing date-times with timezones.
+ * <li>{@link Instant} - For date-times with Zulu timezone.
+ * <li>{@link OffsetDateTime} - For date-times with timezone offsets.
+ * <li>{@link OffsetTime} - For times with timezone offsets.
+ * </ul>
+ */
+public class TemporalDateSwap extends StringSwap<Date> {
+
+ /**
+ * Default swap to {@link DateTimeFormatter#BASIC_ISO_DATE}.
+ * <p>
+ * Example: <js>"20111203"</js>
+ */
+ public static class BasicIsoDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public BasicIsoDate() {
+ super("BASIC_ISO_DATE", LocalDate.class, true);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03+01:00"</js> or <js>"2011-12-03"</js>
+ */
+ public static class IsoDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoDate() {
+ super("ISO_DATE", LocalDate.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoDateTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoDateTime() {
+ super("ISO_DATE_TIME", ZonedDateTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_INSTANT}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30Z"</js>
+ */
+ public static class IsoInstant extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoInstant() {
+ super("ISO_INSTANT", Instant.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoLocalDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoLocalDate() {
+ super("ISO_LOCAL_DATE", LocalDate.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30"</js>
+ */
+ public static class IsoLocalDateTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoLocalDateTime() {
+ super("ISO_LOCAL_DATE_TIME", LocalDateTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_TIME}.
+ * <p>
+ * Example: <js>"10:15:30"</js>
+ */
+ public static class IsoLocalTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoLocalTime() {
+ super("ISO_LOCAL_TIME", LocalTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoOffsetDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoOffsetDate() {
+ super("ISO_OFFSET_DATE", LocalDate.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetDateTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoOffsetDateTime() {
+ super("ISO_OFFSET_DATE_TIME", OffsetDateTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoOffsetTime() {
+ super("ISO_OFFSET_TIME", OffsetTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ORDINAL_DATE}.
+ * <p>
+ * Example: <js>"2012-337"</js>
+ */
+ public static class IsoOrdinalDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoOrdinalDate() {
+ super("ISO_ORDINAL_DATE", LocalDate.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js> or <js>"10:15:30"</js>
+ */
+ public static class IsoTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoTime() {
+ super("ISO_TIME", OffsetTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_WEEK_DATE}.
+ * <p>
+ * Example: <js>"2012-W48-6"</js>
+ */
+ public static class IsoWeekDate extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoWeekDate() {
+ super("ISO_WEEK_DATE", LocalDate.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ZONED_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoZonedDateTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public IsoZonedDateTime() {
+ super("ISO_ZONED_DATE_TIME", ZonedDateTime.class, false);
+ }
+ };
+
+ /**
+ * Default swap to {@link DateTimeFormatter#RFC_1123_DATE_TIME}.
+ * <p>
+ * Example: <js>"Tue, 3 Jun 2008 11:05:30 GMT"</js>
+ */
+ public static class Rfc1123DateTime extends TemporalDateSwap {
+ /** Constructor.*/
+ public Rfc1123DateTime() {
+ super("RFC_1123_DATE_TIME", ZonedDateTime.class, false);
+ }
+ };
+
+
+ private final TemporalParser<? extends Temporal> intermediateParser;
+ private final DateTimeFormatter formatter;
+ private final boolean serializeWithoutTimezone;
+
+ /**
+ * Constructor.
+ *
+ * @param pattern The timestamp format or name of predefined {@link DateTimeFormatter}.
+ * @param intermediateType The intermediate Java 8 data type to parse into before converting to a Date object.
+ * @param serializeWithoutTimezone <jk>true</jk> if the date should be converted to local-date-time before serialization.
+ */
+ public TemporalDateSwap(String pattern, Class<? extends Temporal> intermediateType, boolean serializeWithoutTimezone) {
+ super(Date.class);
+ this.intermediateParser = TemporalParserCache.getTemporalParser(intermediateType);
+ this.formatter = DateUtils.getFormatter(pattern);
+ this.serializeWithoutTimezone = serializeWithoutTimezone;
+ }
+
+ /**
+ * Converts the specified intermediate {@link Temporal} object to a {@link Date} object.
+ *
+ * @param bs The current bean session.
+ * @param temporal The intermediate temporal object.
+ * @return The converted date.
+ */
+ protected Date toDate(BeanSession bs, Temporal temporal) {
+ return DateUtils.toDate(temporal, bs.getTimeZoneId());
+ }
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Date o) throws Exception {
+ if (o == null)
+ return null;
+ ZonedDateTime t = o.toInstant().atZone(session.getTimeZoneId());
+ return formatter.format(serializeWithoutTimezone ? t.toLocalDateTime() : t);
+ }
+
+ @Override /* PojoSwap */
+ public Date unswap(BeanSession session, String f, ClassMeta<?> hint) throws Exception {
+ if (f == null)
+ return null;
+ Temporal t = intermediateParser.parse(f, formatter);
+ return toDate(session, t);
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParser.java
similarity index 50%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParser.java
index 06e7c33..a22bf0a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParser.java
@@ -1,55 +1,70 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.transforms;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.transform.*;
-
-/**
- * Transforms {@link Calendar Calendars} to {@link Map Maps} of the format <c>{time:long,timeZone:string}</c>.
- */
-@SuppressWarnings("rawtypes")
-public class CalendarMapSwap extends PojoSwap<Calendar,Map> {
-
- /**
- * Converts the specified {@link Calendar} to a {@link Map}.
- */
- @Override /* PojoSwap */
- public Map swap(BeanSession session, Calendar o) {
- ObjectMap m = new ObjectMap();
- m.put("time", o.getTime().getTime());
- m.put("timeZone", o.getTimeZone().getID());
- return m;
- }
-
- /**
- * Converts the specified {@link Map} to a {@link Calendar}.
- */
- @Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Map o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- long time = Long.parseLong(o.get("time").toString());
- String timeZone = o.get("timeZone").toString();
- Date d = new Date(time);
- Calendar c = tt.newInstance();
- c.setTime(d);
- c.setTimeZone(TimeZone.getTimeZone(timeZone));
- return c;
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.lang.reflect.*;
+import java.time.format.*;
+import java.time.temporal.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.reflect.*;
+
+/**
+ * A helper class for converting strings to {@link Temporal} objects.
+ *
+ * <p>
+ * Looks for static <cb>from()</cb> or <cb>parse()</cb> methods to use on the temporal class to instantiate instances.
+ *
+ * @param <T> The temporal class type.
+ */
+class TemporalParser<T extends Temporal> {
+
+ private final Method fromMethod;
+ private final Method parseMethod;
+ private final ClassInfo ci;
+
+ /**
+ * Constructor.
+ *
+ * @param c The temporal class type.
+ */
+ public TemporalParser(Class<T> c) {
+ this.ci = ClassInfo.of(c);
+ this.fromMethod = ci.getStaticPublicMethodInner("from", c, TemporalAccessor.class);
+ this.parseMethod = ci.getStaticPublicMethodInner("parse", c, String.class, DateTimeFormatter.class);
+ }
+
+ /**
+ * Parses the specified input using the specified formatter.
+ *
+ * @param input The input string.
+ * @param formatter The formatter.
+ * @return The parsed string.
+ * @throws ExecutableException If input could not be parsed using the specified formatter.
+ */
+ @SuppressWarnings("unchecked")
+ public T parse(String input, DateTimeFormatter formatter) throws ExecutableException {
+ try {
+ if (parseMethod != null) {
+ return (T)parseMethod.invoke(null, input, formatter);
+ }
+ if (fromMethod != null) {
+ TemporalAccessor ta = formatter.parse(input);
+ return (T)fromMethod.invoke(null, ta);
+ }
+ throw new ExecutableException("From or Parse methods not found on temporal class ''{0}''", ci.getSimpleName());
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new ExecutableException(e);
+ }
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParserCache.java
similarity index 63%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParserCache.java
index 7da3952..5a61933 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalParserCache.java
@@ -1,47 +1,42 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.transforms;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.transform.*;
-
-/**
- * Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
- */
-public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
-
- /**
- * Converts the specified {@link Calendar} to a {@link Long}.
- */
- @Override /* PojoSwap */
- public Long swap(BeanSession session, Calendar o) {
- return o.getTime().getTime();
- }
-
- /**
- * Converts the specified {@link Long} to a {@link Calendar}.
- */
- @Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- Calendar c = tt.newInstance();
- c.setTimeInMillis(o);
- return c;
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.temporal.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ * Cache of reusable <c>TemporalParser</c> objects.
+ */
+class TemporalParserCache {
+
+ private static final Map<Class<? extends Temporal>,TemporalParser<? extends Temporal>> TO_TEMPORAL_CACHE = new ConcurrentHashMap<>();
+
+ /**
+ * Retrieves a temporal parser for the specified {@link Temporal} class.
+ *
+ * @param <T> The temporal class.
+ * @param c The temporal class.
+ * @return The parser for the specified class.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static <T extends Temporal> TemporalParser<T> getTemporalParser(Class<T> c) {
+ TemporalParser tt = TO_TEMPORAL_CACHE.get(c);
+ if (tt == null) {
+ tt = new TemporalParser(c);
+ TO_TEMPORAL_CACHE.put(c, tt);
+ }
+ return tt;
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalSwap.java
new file mode 100644
index 0000000..5f54421
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TemporalSwap.java
@@ -0,0 +1,435 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.time.*;
+import java.time.chrono.*;
+import java.time.format.*;
+import java.time.temporal.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.transform.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Swap that converts {@link Temporal} objects to strings.
+ *
+ * <p>
+ * Uses the {@link DateTimeFormatter} class for converting {@link Temporal} objects to and from strings.
+ *
+ * <p>
+ * Supports any of the following temporal objects:
+ * <ul>
+ * <li>{@link HijrahDate}
+ * <li>{@link Instant}
+ * <li>{@link JapaneseDate}
+ * <li>{@link LocalDate}
+ * <li>{@link LocalDateTime}
+ * <li>{@link LocalTime}
+ * <li>{@link MinguoDate}
+ * <li>{@link OffsetDateTime}
+ * <li>{@link OffsetTime}
+ * <li>{@link ThaiBuddhistDate}
+ * <li>{@link Year}
+ * <li>{@link YearMonth}
+ * <li>{@link ZonedDateTime}
+ * </ul>
+ */
+public class TemporalSwap extends StringSwap<Temporal> {
+
+ /**
+ * Default swap to {@link DateTimeFormatter#BASIC_ISO_DATE}.
+ * <p>
+ * Example: <js>"20111203"</js>
+ */
+ public static class BasicIsoDate extends TemporalSwap {
+ /** Constructor.*/
+ public BasicIsoDate() {
+ super(
+ "BASIC_ISO_DATE",
+ LocalDate.class,
+ ASet.create(LocalDate.class, LocalDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class, Year.class, YearMonth.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03+01:00"</js> or <js>"2011-12-03"</js>
+ */
+ public static class IsoDate extends TemporalSwap {
+ /** Constructor.*/
+ public IsoDate() {
+ super(
+ "ISO_DATE",
+ LocalDate.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, ZonedDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class),
+ true
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoDateTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoDateTime() {
+ super(
+ "ISO_DATE_TIME",
+ ZonedDateTime.class,
+ ASet.create(OffsetDateTime.class, ZonedDateTime.class),
+ ZonedDateTime.class,
+ ASet.create(Instant.class, LocalDate.class, LocalDateTime.class, LocalTime.class, OffsetDateTime.class, OffsetTime.class, Year.class, YearMonth.class, ZonedDateTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_INSTANT}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30Z"</js>
+ */
+ public static class IsoInstant extends TemporalSwap {
+ /** Constructor.*/
+ public IsoInstant() {
+ super(
+ "ISO_INSTANT",
+ Instant.class,
+ ASet.create(Instant.class, OffsetDateTime.class, ZonedDateTime.class),
+ Instant.class,
+ ASet.create(Instant.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoLocalDate extends TemporalSwap {
+ /** Constructor.*/
+ public IsoLocalDate() {
+ super(
+ "ISO_LOCAL_DATE",
+ LocalDate.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, ZonedDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class, Year.class, YearMonth.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30"</js>
+ */
+ public static class IsoLocalDateTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoLocalDateTime() {
+ super(
+ "ISO_LOCAL_DATE_TIME",
+ LocalDateTime.class,
+ ASet.create(LocalDateTime.class, OffsetDateTime.class, ZonedDateTime.class),
+ LocalDateTime.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, LocalTime.class, Year.class, YearMonth.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_LOCAL_TIME}.
+ * <p>
+ * Example: <js>"10:15:30"</js>
+ */
+ public static class IsoLocalTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoLocalTime() {
+ super(
+ "ISO_LOCAL_TIME",
+ LocalTime.class,
+ ASet.create(LocalDateTime.class, LocalTime.class, OffsetDateTime.class, OffsetTime.class, ZonedDateTime.class),
+ LocalTime.class,
+ ASet.create(LocalTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE}.
+ * <p>
+ * Example: <js>"2011-12-03"</js>
+ */
+ public static class IsoOffsetDate extends TemporalSwap {
+ /** Constructor.*/
+ public IsoOffsetDate() {
+ super(
+ "ISO_OFFSET_DATE",
+ ZonedDateTime.class,
+ ASet.create(OffsetDateTime.class, ZonedDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class, Year.class, YearMonth.class),
+ true
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetDateTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoOffsetDateTime() {
+ super(
+ "ISO_OFFSET_DATE_TIME",
+ OffsetDateTime.class,
+ ASet.create(OffsetDateTime.class, ZonedDateTime.class),
+ OffsetDateTime.class,
+ ASet.create(Instant.class, LocalDate.class, LocalDateTime.class, LocalTime.class, OffsetDateTime.class, OffsetTime.class, Year.class, YearMonth.class, ZonedDateTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_OFFSET_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js>
+ */
+ public static class IsoOffsetTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoOffsetTime() {
+ super(
+ "ISO_OFFSET_TIME",
+ OffsetTime.class,
+ ASet.create(OffsetDateTime.class, OffsetTime.class, ZonedDateTime.class),
+ OffsetTime.class,
+ ASet.create(LocalTime.class, OffsetTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ORDINAL_DATE}.
+ * <p>
+ * Example: <js>"2012-337"</js>
+ */
+ public static class IsoOrdinalDate extends TemporalSwap {
+ /** Constructor.*/
+ public IsoOrdinalDate() {
+ super(
+ "ISO_ORDINAL_DATE",
+ LocalDate.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, ZonedDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class, Year.class, YearMonth.class),
+ true
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_TIME}.
+ * <p>
+ * Example: <js>"10:15:30+01:00"</js> or <js>"10:15:30"</js>
+ */
+ public static class IsoTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoTime() {
+ super(
+ "ISO_TIME",
+ OffsetTime.class,
+ ASet.create(LocalTime.class, OffsetDateTime.class, OffsetTime.class, ZonedDateTime.class),
+ OffsetTime.class,
+ ASet.create(LocalTime.class, OffsetTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_WEEK_DATE}.
+ * <p>
+ * Example: <js>"2012-W48-6"</js>
+ */
+ public static class IsoWeekDate extends TemporalSwap {
+ /** Constructor.*/
+ public IsoWeekDate() {
+ super(
+ "ISO_WEEK_DATE",
+ LocalDate.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, ZonedDateTime.class),
+ LocalDate.class,
+ ASet.create(LocalDate.class, Year.class, YearMonth.class),
+ true
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_WEEK_DATE}.
+ * <p>
+ * Example: <js>"2011"</js>
+ */
+ public static class IsoYear extends TemporalSwap {
+ /** Constructor.*/
+ public IsoYear() {
+ super(
+ "uuuu",
+ Year.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, Year.class, YearMonth.class, ZonedDateTime.class),
+ Year.class,
+ ASet.create(Year.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_WEEK_DATE}.
+ * <p>
+ * Example: <js>"2011-12"</js>
+ */
+ public static class IsoYearMonth extends TemporalSwap {
+ /** Constructor.*/
+ public IsoYearMonth() {
+ super(
+ "uuuu-MM",
+ YearMonth.class,
+ ASet.create(LocalDate.class, LocalDateTime.class, OffsetDateTime.class, YearMonth.class, ZonedDateTime.class),
+ YearMonth.class,
+ ASet.create(Year.class, YearMonth.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#ISO_ZONED_DATE_TIME}.
+ * <p>
+ * Example: <js>"2011-12-03T10:15:30+01:00[Europe/Paris]"</js>
+ */
+ public static class IsoZonedDateTime extends TemporalSwap {
+ /** Constructor.*/
+ public IsoZonedDateTime() {
+ super(
+ "ISO_ZONED_DATE_TIME",
+ ZonedDateTime.class,
+ ASet.create(LocalDate.class, OffsetDateTime.class, ZonedDateTime.class),
+ ZonedDateTime.class,
+ ASet.create(Instant.class, LocalDate.class, LocalDateTime.class, LocalTime.class, OffsetDateTime.class, OffsetTime.class, Year.class, YearMonth.class, ZonedDateTime.class),
+ false
+ );
+ }
+ }
+
+ /**
+ * Default swap to {@link DateTimeFormatter#RFC_1123_DATE_TIME}.
+ * <p>
+ * Example: <js>"Tue, 3 Jun 2008 11:05:30 GMT"</js>
+ */
+ public static class Rfc1123DateTime extends TemporalSwap {
+ /** Constructor.*/
+ public Rfc1123DateTime() {
+ super(
+ "RFC_1123_DATE_TIME",
+ ZonedDateTime.class,
+ ASet.create(OffsetDateTime.class, ZonedDateTime.class),
+ ZonedDateTime.class,
+ ASet.create(Instant.class, LocalDate.class, LocalDateTime.class, LocalTime.class, OffsetDateTime.class, OffsetTime.class, Year.class, YearMonth.class, ZonedDateTime.class),
+ false
+ );
+ }
+ }
+
+
+ private final TemporalParser<? extends Temporal> intermediateParser;
+ private final Class<? extends Temporal> intermediateSerializeType;
+ private final DateTimeFormatter formatter;
+ private final Set<Class<? extends Temporal>> directSerializeClasses, directParseClasses;
+ private final boolean parseTimezoneSeparately;
+
+ /**
+ * Constructor.
+ *
+ * @param pattern The timestamp format or name of predefined {@link DateTimeFormatter}.
+ * @param intermediateSerializeType The intermediate Java 8 data type to convert to before serializing.
+ * @param directSerializeClasses Classes that can be serialized directly into without having to go through the intermediate type.
+ * @param intermediateParseType The intermediate Java 8 data type to parse into before converting to a Date object.
+ * @param directParseClasses Classes that can be parsed directly into without having to go through the intermediate type.
+ * @param parseTimezoneSeparately <jk>true</jk> if the time zone should be persisted on parsing when {@link LocalDate} is the intermediate type.
+ */
+ public TemporalSwap(String pattern, Class<? extends Temporal> intermediateSerializeType, Set<Class<? extends Temporal>> directSerializeClasses, Class<? extends Temporal> intermediateParseType, Set<Class<? extends Temporal>> directParseClasses, boolean parseTimezoneSeparately) {
+ super(Temporal.class);
+ this.intermediateParser = TemporalParserCache.getTemporalParser(intermediateParseType);
+ this.formatter = DateUtils.getFormatter(pattern);
+ this.directSerializeClasses = directSerializeClasses == null ? Collections.emptySet() : directSerializeClasses;
+ this.directParseClasses = directParseClasses == null ? Collections.emptySet() : directParseClasses;
+ this.intermediateSerializeType = intermediateSerializeType;
+ this.parseTimezoneSeparately = parseTimezoneSeparately;
+ }
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Temporal o) throws Exception {
+ if (o == null)
+ return null;
+ if (directSerializeClasses.contains(o.getClass()))
+ return formatter.format(o);
+ Temporal o2 = DateUtils.toTemporal(o, intermediateSerializeType, session.getTimeZoneId());
+ return formatter.format(o2);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override /* PojoSwap */
+ public Temporal unswap(BeanSession session, String f, ClassMeta<?> hint) throws Exception {
+ if (hint == null)
+ hint = session.getClassMeta(Instant.class);
+
+ Class<? extends Temporal> tc = (Class<? extends Temporal>)hint.getInnerClass();
+
+ if (directParseClasses.contains(tc))
+ return TemporalParserCache.getTemporalParser(tc).parse(f, formatter);
+
+ Temporal t = intermediateParser.parse(f, formatter);
+
+ if (parseTimezoneSeparately) {
+ TemporalAccessor ta = formatter.parse(f);
+ if (ta.query(TemporalQueries.zone()) != null) {
+ ZoneId offset = ZoneId.from(ta);
+ t = ((LocalDate)t).atStartOfDay(offset);
+ }
+ }
+
+ return DateUtils.toTemporal(t, tc, session.getTimeZoneId());
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TimeZoneSwap.java
similarity index 67%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TimeZoneSwap.java
index 7da3952..8501d5f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/CalendarLongSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transforms/TimeZoneSwap.java
@@ -1,47 +1,34 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.transforms;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.transform.*;
-
-/**
- * Transforms {@link Calendar Calendars} to {@link Long Longs} using {@code Calender.getTime().getTime()}.
- */
-public class CalendarLongSwap extends PojoSwap<Calendar,Long> {
-
- /**
- * Converts the specified {@link Calendar} to a {@link Long}.
- */
- @Override /* PojoSwap */
- public Long swap(BeanSession session, Calendar o) {
- return o.getTime().getTime();
- }
-
- /**
- * Converts the specified {@link Long} to a {@link Calendar}.
- */
- @Override /* PojoSwap */
- @SuppressWarnings("unchecked")
- public Calendar unswap(BeanSession session, Long o, ClassMeta<?> hint) throws Exception {
- ClassMeta<? extends Calendar> tt;
- if (hint == null || ! hint.canCreateNewInstance())
- hint = session.getClassMeta(GregorianCalendar.class);
- tt = (ClassMeta<? extends Calendar>)hint;
- Calendar c = tt.newInstance();
- c.setTimeInMillis(o);
- return c;
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.transforms;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * Transforms {@link TimeZone} objects to and from {@link String Strings}.
+ */
+public class TimeZoneSwap extends StringSwap<TimeZone> {
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, TimeZone o) throws Exception {
+ return o.toString();
+ }
+
+ @Override /* PojoSwap */
+ public TimeZone unswap(BeanSession session, String o, ClassMeta<?> hint) throws Exception {
+ return TimeZone.getTimeZone(o);
+ }
+}
diff --git a/juneau-doc/docs/ReleaseNotes/8.0.1.html b/juneau-doc/docs/ReleaseNotes/8.0.1.html
index 3ee1f43..b911bfe 100644
--- a/juneau-doc/docs/ReleaseNotes/8.0.1.html
+++ b/juneau-doc/docs/ReleaseNotes/8.0.1.html
@@ -57,6 +57,13 @@
<li>
Serializer and parser APIs now throw <c>IOExceptions</c> in addition to <c>SerializeException</c> and <c>ParseException</c> to make it
easier to determine if problems are stream based or syntax based.
+ <li>
+ New Java 8 date-time transforms:
+ <ul class='doctree'>
+ <li class='jc'>{@link oaj.transforms.TemporalSwap} - For all Java 8 temporal types (e.g. {@link java.time.ZonedDateTime})
+ <li class='jc'>{@link oaj.transforms.TemporalDateSwap} - For {@link java.util.Date}
+ <li class='jc'>{@link oaj.transforms.TemporalCalendarSwap} - For {@link java.util.Calendar}
+ </ul>
</ul>
<h5 class='topic w800'>juneau-config</h5>