Permalink
Browse files

Merge pull request #15 from loudej/issue-228

Issue 228
  • Loading branch information...
2 parents a552797 + ff44325 commit 42a8cfdc94b176b972ddb3c80497ff048c022001 @jcookems jcookems committed Feb 24, 2012
@@ -33,6 +33,10 @@ public String format(Date date) {
return getFormat().format(date);
}
+ public String shortFormat(Date date) {
+ return getShortFormat().format(date);
+ }
+
public Date parse(String date) throws ParseException {
if (date == null)
return null;
@@ -179,7 +179,7 @@ private InputStream generateEntry(PropertiesWriter propertiesWriter) {
writer.writeEndElement(); // title
writer.writeStartElement("updated");
- writer.writeCharacters(iso8601DateConverter.format(dateFactory.getDate()));
+ writer.writeCharacters(iso8601DateConverter.shortFormat(dateFactory.getDate()));
writer.writeEndElement(); // updated
writer.writeStartElement("author");
@@ -25,7 +25,7 @@ public String serialize(String edmType, Object value) {
String serializedValue;
if (value instanceof Date) {
- serializedValue = iso8601DateConverter.format((Date) value);
+ serializedValue = iso8601DateConverter.shortFormat((Date) value);
}
else {
serializedValue = value.toString();
@@ -20,8 +20,6 @@
import org.junit.Test;
-import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter;
-
public class ISO8601DateConverterTests {
@Test
public void shortFormatWorks() throws Exception {
@@ -48,4 +46,19 @@ public void longFormatWorks() throws Exception {
// Assert
assertNotNull(result);
}
+
+ @Test
+ public void shortFormatRoundTrips() throws Exception {
+ // Arrange
+ ISO8601DateConverter converter = new ISO8601DateConverter();
+ String value = "2012-01-12T00:35:58Z";
+
+ // Act
+ Date result = converter.parse(value);
+ String value2 = converter.shortFormat(result);
+
+ // Assert
+ assertNotNull(result);
+ assertEquals(value, value2);
+ }
}

0 comments on commit 42a8cfd

Please sign in to comment.