Skip to content

Commit

Permalink
Add test for #60
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 13, 2015
1 parent f901771 commit 75e8ef7
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.datatype.joda;

import java.io.IOException;
import java.text.SimpleDateFormat;

import org.joda.time.*;

Expand Down Expand Up @@ -227,6 +228,23 @@ public void testInstantSer() throws IOException {
assertEquals(quote("1970-01-01T00:00:00.000Z"), m.writeValueAsString(instant));
}

// [datatype-joda#60]
public void testInstantConversion() throws Exception
{
final ObjectMapper mapper = jodaMapper();

// Configure Date Formatting
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));

// Create an instant and serialize and additonally serialize the instant as DateTime to demonstrate the difference
org.joda.time.Instant now = new DateTime(1431498572205L).toInstant();

String instantString = mapper.writeValueAsString(now);

assertEquals("\"2015-05-13T06:29:32.205Z\"", instantString);
}

public void testMonthDaySer() throws Exception
{
MonthDay monthDay = new MonthDay(7, 23);
Expand Down

0 comments on commit 75e8ef7

Please sign in to comment.