Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza-vd committed Aug 10, 2023
1 parent 92b6dfb commit a84599d
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -95,4 +97,25 @@ public void differenceTest() {
Assert.assertEquals(2, DateUtil.dayDifference(new LocalDate("2019-10-01"), new LocalDate("2019-10-03")));
Assert.assertEquals(1, DateUtil.weekDifference(new LocalDate("2019-09-26"), new LocalDate("2019-10-03")));
}

@Test
public void testSetDefaultDateFormatShouldSSetTheDefaultDateFormatOfDateUtil() {
DateUtil.setDefaultDateFormat("yyyy/MM/dd");
Assert.assertEquals("yyyy/MM/dd", DateUtil.DEFAULT_DATE_FORMAT);
}


@Test
public void testFormatFromISOString() {
String localDateTime = LocalDateTime.parse("22-09-23").toString(ISODateTimeFormat.dateTime());
String date = DateUtil.formatFromISOString(localDateTime, "dd/MM/YY");
Assert.assertEquals("23/09/22", date);
}

@Test
public void testGetTimeFromMillis() {
LocalDate date = DateUtil.getDateFromMillis(1691654548L);
Assert.assertEquals("1970-01-20", date.toString());
}
}

0 comments on commit a84599d

Please sign in to comment.