Skip to content

Commit ba93182

Browse files
committed
Merge branch '2.13'
2 parents bbdbb2f + d79bbfb commit ba93182

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.fasterxml.jackson.datatype.jsr310.failing;
2+
3+
import java.time.Duration;
4+
5+
import org.junit.Test;
6+
7+
import com.fasterxml.jackson.annotation.JsonFormat;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
import com.fasterxml.jackson.databind.*;
10+
11+
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
12+
13+
import static org.junit.Assert.assertEquals;
14+
15+
public class DurationSer224Test extends ModuleTestBase
16+
{
17+
// [datetime#224]
18+
static class MyDto224 {
19+
@JsonFormat(pattern = "MINUTES"
20+
// Work-around from issue:
21+
// , without = JsonFormat.Feature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS
22+
)
23+
@JsonProperty("mins")
24+
private final Duration duration;
25+
26+
public MyDto224(Duration d) { duration = d; }
27+
28+
public Duration getDuration() { return duration; }
29+
}
30+
31+
private final ObjectMapper MAPPER = newMapper();
32+
33+
// [datetime#224]
34+
@Test
35+
public void testDurationFormatOverride() throws Exception
36+
{
37+
final String json = MAPPER.writeValueAsString(new MyDto224(Duration.ofHours(2)));
38+
assertEquals(a2q("{'mins':120}"), json);
39+
}
40+
}

0 commit comments

Comments
 (0)