Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}