Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't replace yy by yyyy if format is explicitly specified

 * only replace yy by yyyy if using the defaultFormat binding
 * in the default binding, also replace yy by yyyy if it does not stand at the end of the format string
  • Loading branch information...
commit 0139bce8517cd5988bd4e4c448afbd5cd14a63c1 1 parent acf0fd8
@jochenberger jochenberger authored
View
2  tapx-datefield/src/main/java/com/howardlewisship/tapx/datefield/components/DateField.java
@@ -187,7 +187,7 @@ public Object get()
String pattern = simpleDateFormat.toPattern();
- String revised = pattern.replaceAll("([^y])yy$", "$1yyyy");
+ String revised = pattern.replaceAll("(?<!y)yy(?!y)", "yyyy");
return new SimpleDateFormat(revised);
}
View
2  ...eld/src/main/java/com/howardlewisship/tapx/internal/datefield/services/DateFieldFormatConverterImpl.java
@@ -28,7 +28,7 @@
// year
"yyyy", "Y",
- "yy", "Y",
+ "yy", "y",
// month
"MMMM", "B",
View
4 tapx-datefield/src/test/groovy/com/howardlewisship/tapx/datefield/integration/IntegrationTests.groovy
@@ -44,7 +44,7 @@ class IntegrationTests extends SeleniumTestCase
clickAndWait SUBMIT
- assertFieldValue "date", "3/13/09 12:00 AM"
+ assertFieldValue "date", "3/13/2009 12:00 AM"
assertText "outputdate", "March 13, 2009 12:00:00 AM"
}
@@ -58,6 +58,6 @@ class IntegrationTests extends SeleniumTestCase
// That's about as far as we take it; this demonstrates that the tapx DateField was used,
// and that it picked up on the @TimeSignificant annotation.
- assertFieldValue "date", "3/16/09 12:00 AM"
+ assertFieldValue "date", "3/16/2009 12:00 AM"
}
}
View
5 ...src/test/java/com/howardlewisship/tapx/internal/datefield/services/DateFieldFormatConverterImplTest.java
@@ -81,10 +81,7 @@ public void english_default_locale_with_time()
{
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH);
- // Note that DateField manipulates the Java "yy" format into "yyyy" before passing into the converter.
- // But this works because of an additional (and otherwise unnecessary) mapping from "yy".
-
- assertEquals(converter.convertToClient(format), "%o/%e/%Y %l:%M %p");
+ assertEquals(converter.convertToClient(format), "%o/%e/%y %l:%M %p");
}
@Test
Please sign in to comment.
Something went wrong with that request. Please try again.