This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new fbb22ebd79 ISIS-3105: value-semantics: honor ZoneId name if any 
(affects formatting)
fbb22ebd79 is described below

commit fbb22ebd79abdbb3ef8ed629611ae6ed135bf675
Author: Andi Huber <[email protected]>
AuthorDate: Tue Aug 2 14:40:33 2022 +0200

    ISIS-3105: value-semantics: honor ZoneId name if any (affects
    formatting)
---
 .../value/semantics/TemporalValueSemantics.java    | 63 ++++++++++++++++++----
 .../isis/testdomain/value/ValueSemanticsTest.java  |  4 +-
 .../jodatime/JodaDateTimeConverterTest.java        |  2 +-
 3 files changed, 56 insertions(+), 13 deletions(-)

diff --git 
a/api/applib/src/main/java/org/apache/isis/applib/value/semantics/TemporalValueSemantics.java
 
b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/TemporalValueSemantics.java
index 737f253c75..fea1271159 100644
--- 
a/api/applib/src/main/java/org/apache/isis/applib/value/semantics/TemporalValueSemantics.java
+++ 
b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/TemporalValueSemantics.java
@@ -201,6 +201,29 @@ extends
          * Z       zone-offset                 offset-Z          +0000; -0800; 
-08:00;
          *</pre>
          *
+         * TODO no <i>tempus-dominus</i> date/time-picker support yet.
+         */
+        @NotNull @NotEmpty
+        private String zoneIdPatternForOutput = "VV";
+
+        /**
+         * TODO no <i>tempus-dominus</i> date/time-picker support yet.
+         */
+        @NotNull @NotEmpty
+        private String zoneIdPatternForInput = "VV";
+
+        /**
+         * The locale-independent (canonical) pattern used for editing 
time-offset in the UI.
+         * <p>
+         * Java time-zone formats<pre>
+         * V       time-zone ID                zone-id           
America/Los_Angeles; Z; -08:30
+         * z       time-zone name              zone-name         Pacific 
Standard Time; PST
+         * O       localized zone-offset       offset-O          GMT+8; 
GMT+08:00; UTC-08:00;
+         * X       zone-offset 'Z' for zero    offset-X          Z; -08; 
-0830; -08:30; -083015; -08:30:15;
+         * x       zone-offset                 offset-x          +0000; -08; 
-0830; -08:30; -083015; -08:30:15;
+         * Z       zone-offset                 offset-Z          +0000; -0800; 
-08:00;
+         *</pre>
+         *
          * @apiNote Yet only tested with {@literal XXX}, as there needs to be 
a format correspondence with
          * <i>momentJs</i> for the <i>tempus-dominus</i> date/time-picker to 
work
          * (as used by the <i>Wicket Viewer</i>).
@@ -208,7 +231,7 @@ extends
          * does the format conversion.
          */
         @NotNull @NotEmpty
-        private String zonePatternForOutput = "XXX";
+        private String offsetPatternForOutput = "XXX";
 
         /**
          * Support both forms for parsing, with or without colon.
@@ -217,7 +240,7 @@ extends
          * @see 
"https://stackoverflow.com/questions/34637626/java-datetimeformatter-for-time-zone-with-an-optional-colon-separator";
          */
         @NotNull @NotEmpty
-        private String zonePatternForInput = "[XXX][X]";
+        private String offsetPatternForInput = "[XXX][X]";
 
         // -- JOINING PATTERNS
 
@@ -251,27 +274,47 @@ extends
             switch (temporalCharacteristic) {
             case DATE_TIME:
                 val dateTimePattern =
-                    String.format(getDateTimeJoiningPattern(), 
getDatePattern(), timePattern(timePrecision, direction));
+                    String.format(getDateTimeJoiningPattern(),
+                            getDatePattern(),
+                            timePattern(timePrecision, direction));
                 return offsetCharacteristic.isLocal()
                         ? dateTimePattern
-                        : String.format(getZoneJoiningPattern(), 
dateTimePattern, zonePattern(direction));
+                        : String.format(getZoneJoiningPattern(),
+                                dateTimePattern,
+                                zonePattern(offsetCharacteristic, direction));
             case DATE_ONLY:
                 return offsetCharacteristic.isLocal()
                         ? getDatePattern()
-                        : String.format(getZoneJoiningPattern(), 
getDatePattern(), zonePattern(direction));
+                        : String.format(getZoneJoiningPattern(),
+                                getDatePattern(),
+                                zonePattern(offsetCharacteristic,direction));
             case TIME_ONLY:
                 return offsetCharacteristic.isLocal()
                         ? timePattern(timePrecision, direction)
-                        : String.format(getZoneJoiningPattern(), 
timePattern(timePrecision, direction), zonePattern(direction));
+                        : String.format(getZoneJoiningPattern(),
+                                timePattern(timePrecision, direction),
+                                zonePattern(offsetCharacteristic, direction));
             default:
                 throw _Exceptions.unmatchedCase(temporalCharacteristic);
             }
         }
 
-        private String zonePattern(@NonNull final EditingFormatDirection 
direction) {
-            return direction.isInput()
-                    ? getZonePatternForInput()
-                    : getZonePatternForOutput();
+        private String zonePattern(
+                final @NonNull OffsetCharacteristic offsetCharacteristic,
+                final @NonNull EditingFormatDirection direction) {
+
+            switch(offsetCharacteristic) {
+            case OFFSET:
+                return direction.isInput()
+                        ? getOffsetPatternForInput()
+                        : getOffsetPatternForOutput();
+            case ZONED:
+                return direction.isInput()
+                        ? getZoneIdPatternForInput()
+                        : getZoneIdPatternForOutput();
+            default:
+                throw _Exceptions.unexpectedCodeReach();
+            }
         }
 
         // -- HELPER
diff --git 
a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
 
b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
index d7ad02045c..0ba600df51 100644
--- 
a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
+++ 
b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
@@ -20,7 +20,6 @@ package org.apache.isis.testdomain.value;
 
 import java.time.OffsetDateTime;
 import java.time.OffsetTime;
-import java.time.ZonedDateTime;
 import java.util.Locale;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -249,7 +248,8 @@ class ValueSemanticsTest {
 
                                 if(valueType.equals(OffsetDateTime.class)
                                         || valueType.equals(OffsetTime.class)
-                                        || 
valueType.equals(ZonedDateTime.class)) {
+                                        //|| 
valueType.equals(ZonedDateTime.class)
+                                        ) {
 
                                     if(stringified.endsWith("Z")) {
                                         // skip format variations on UTC 
time-zone
diff --git 
a/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/jodatime/JodaDateTimeConverterTest.java
 
b/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/jodatime/JodaDateTimeConverterTest.java
index 78d1519b74..6b191585d5 100644
--- 
a/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/jodatime/JodaDateTimeConverterTest.java
+++ 
b/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/components/scalars/jodatime/JodaDateTimeConverterTest.java
@@ -53,7 +53,7 @@ class JodaDateTimeConverterTest {
 
     @Test
     void happy_case() {
-        converterTester.assertRoundtrip(valid, "2013-05-11 17:59:00 +01:00");
+        converterTester.assertRoundtrip(valid, "2013-05-11 17:59:00 
GMT+01:00");
     }
 
     @Test

Reply via email to