|
22 | 22 | */ |
23 | 23 | public class DateToLocalDateConverterTest { |
24 | 24 |
|
| 25 | + @Test |
| 26 | + public void shouldReturn10thNovember2010WhenConvertViaInstant() { |
| 27 | + // given |
| 28 | + Calendar calendar = Calendar.getInstance(); |
| 29 | + calendar.set(2010, 10, 10); |
| 30 | + Date dateToConvert = calendar.getTime(); |
| 31 | + |
| 32 | + // when |
| 33 | + LocalDate localDate = DateToLocalDateConverter.convertToLocalDateViaInstant(dateToConvert); |
| 34 | + |
| 35 | + // then |
| 36 | + assertEquals(2010, localDate.get(ChronoField.YEAR)); |
| 37 | + assertEquals(11, localDate.get(ChronoField.MONTH_OF_YEAR)); |
| 38 | + assertEquals(10, localDate.get(ChronoField.DAY_OF_MONTH)); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void shouldReturn10thNovember2010WhenConvertViaMiliseconds() { |
| 43 | + // given |
| 44 | + Calendar calendar = Calendar.getInstance(); |
| 45 | + calendar.set(2010, 10, 10); |
| 46 | + Date dateToConvert = calendar.getTime(); |
| 47 | + |
| 48 | + // when |
| 49 | + LocalDate localDate = DateToLocalDateConverter.convertToLocalDateViaMilisecond(dateToConvert); |
| 50 | + |
| 51 | + // then |
| 52 | + assertEquals(2010, localDate.get(ChronoField.YEAR)); |
| 53 | + assertEquals(11, localDate.get(ChronoField.MONTH_OF_YEAR)); |
| 54 | + assertEquals(10, localDate.get(ChronoField.DAY_OF_MONTH)); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void shouldReturn10thNovember2010WhenConvertViaSqlDate() { |
| 59 | + // given |
| 60 | + Calendar calendar = Calendar.getInstance(); |
| 61 | + calendar.set(2010, 10, 10); |
| 62 | + Date dateToConvert = calendar.getTime(); |
| 63 | + |
| 64 | + // when |
| 65 | + LocalDate localDate = DateToLocalDateConverter.convertToLocalDateViaSqlDate(dateToConvert); |
| 66 | + |
| 67 | + // then |
| 68 | + assertEquals(2010, localDate.get(ChronoField.YEAR)); |
| 69 | + assertEquals(11, localDate.get(ChronoField.MONTH_OF_YEAR)); |
| 70 | + assertEquals(10, localDate.get(ChronoField.DAY_OF_MONTH)); |
| 71 | + } |
| 72 | + |
25 | 73 | @Test |
26 | 74 | public void shouldReturn10thNovember2010WhenConvertToLocalDate() { |
27 | 75 | // given |
|
0 commit comments