Skip to content

Commit

Permalink
[#276] Fix the default ISO 8601 date format to include the timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebort committed Oct 21, 2010
1 parent 63b1def commit 32105a1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/src/play/data/binding/Unbinder.java
Expand Up @@ -51,7 +51,7 @@ private static void unBind(Map<String, Object> result, Object src, Class<?> srcC
}
}
} else if (Date.class.isAssignableFrom(src.getClass())) {
result.put(name, src != null ? new SimpleDateFormat(DateBinder.ISO).format((Date)src) : null);
result.put(name, new SimpleDateFormat(DateBinder.ISO8601).format((Date)src));
} else {
Field[] fields = src.getClass().getDeclaredFields();
for (Field field : fields) {
Expand Down
4 changes: 2 additions & 2 deletions framework/src/play/data/binding/types/DateBinder.java
Expand Up @@ -13,7 +13,7 @@
*/
public class DateBinder implements TypeBinder<Date> {

public static final String ISO = "'ISO8086'yyyy-MM-dd'T'HH:mm:ss";
public static final String ISO8601 = "'ISO8601:'yyyy-MM-dd'T'HH:mm:ssZ";

public Date bind(String name, Annotation[] annotations, String value, Class actualClass) throws Exception {

Expand All @@ -31,7 +31,7 @@ public Date bind(String name, Annotation[] annotations, String value, Class actu
}

try {
SimpleDateFormat sdf = new SimpleDateFormat(ISO);
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601);
sdf.setLenient(false);
return sdf.parse(value);
} catch(Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion framework/src/play/test/Fixtures.java
Expand Up @@ -224,7 +224,7 @@ static void serialize(Map<?, ?> values, String prefix, Map<String, String[]> ser
if (value instanceof Map<?, ?>) {
serialize((Map<?, ?>) value, prefix + "." + key, serialized);
} else if (value instanceof Date) {
serialized.put(prefix + "." + key.toString(), new String[]{new SimpleDateFormat(DateBinder.ISO).format(((Date) value))});
serialized.put(prefix + "." + key.toString(), new String[]{new SimpleDateFormat(DateBinder.ISO8601).format(((Date) value))});
} else if (value instanceof List<?>) {
List<?> l = (List<?>) value;
String[] r = new String[l.size()];
Expand Down
2 changes: 1 addition & 1 deletion samples-and-tests/just-test-cases/test/vendor-data.yml
Expand Up @@ -22,7 +22,7 @@ vendor.VenueVendor(venue2):
# Bloc
Bloc(b):
name: Yop
created: 2001-11-23 15:03:17 -5
created: 2001-11-23T15:03:17-05
criterias:
? key1
: value1
Expand Down

0 comments on commit 32105a1

Please sign in to comment.