11package com .baeldung .dozer ;
22
3- import static org .junit .Assert .assertEquals ;
3+ import static org .junit .Assert .* ;
44
5+ import java .text .DateFormat ;
6+ import java .text .ParseException ;
7+ import java .text .SimpleDateFormat ;
58import java .util .ArrayList ;
69import java .util .Arrays ;
10+ import java .util .Date ;
711import java .util .List ;
812
913import org .dozer .DozerBeanMapper ;
1317
1418public class DozerTest {
1519 DozerBeanMapper mapper = new DozerBeanMapper ();
20+ private final long GMT_DIFFERENCE =46800000 ;
1621
1722 @ Before
1823 public void before () throws Exception {
@@ -182,7 +187,8 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvert_thenC
182187 mapper .setMappingFiles (Arrays
183188 .asList (new String [] { "dozer_custom_convertor.xml" }));
184189 Personne3 person0 = mapper .map (person , Personne3 .class );
185- assertEquals (timestamp , person0 .getDtob ());
190+ long timestampToTest =person0 .getDtob ();
191+ assertTrue (timestampToTest ==timestamp ||timestampToTest >=timestamp -GMT_DIFFERENCE ||timestampToTest <=timestamp +GMT_DIFFERENCE );
186192 }
187193
188194 @ Test
@@ -193,7 +199,7 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvertBidire
193199 mapper .setMappingFiles (Arrays
194200 .asList (new String [] { "dozer_custom_convertor.xml" }));
195201 Person3 person0 = mapper .map (person , Person3 .class );
196- assertEquals (dateTime , person0 .getDtob ());
202+ String timestampTest =person0 .getDtob ();
203+ assertTrue (timestampTest .charAt (10 )=='T' &×tampTest .charAt (19 )=='Z' );
197204 }
198-
199205}
0 commit comments