-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f71fbf2
commit a8776a6
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...c/test/java/com/fasterxml/jackson/datatype/jsr310/failing/OffsetDateTimeDeser279Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.fasterxml.jackson.datatype.jsr310.failing; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.ZoneId; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class OffsetDateTimeDeser279Test extends ModuleTestBase | ||
{ | ||
// For [modules-java8#279] | ||
static class Wrapper279 { | ||
OffsetDateTime date; | ||
|
||
public Wrapper279(OffsetDateTime d) { date = d; } | ||
protected Wrapper279() { } | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") | ||
public OffsetDateTime getDate() { | ||
return date; | ||
} | ||
public void setDate(OffsetDateTime date) { | ||
this.date = date; | ||
} | ||
} | ||
|
||
private ObjectMapper MAPPER = newMapper(); | ||
|
||
// For [modules-java8#279] | ||
@Test | ||
public void testWrapperWithPattern279() throws Exception | ||
{ | ||
final OffsetDateTime date = OffsetDateTime.now(ZoneId.of("UTC")) | ||
.truncatedTo(ChronoUnit.SECONDS); | ||
final Wrapper279 input = new Wrapper279(date); | ||
final String json = MAPPER.writeValueAsString(input); | ||
|
||
Wrapper279 result = MAPPER.readValue(json, Wrapper279.class); | ||
assertEquals(input.date, result.date); | ||
} | ||
} |