Complete tests for DateUtils, move internal functions to private

pull/1120/head
sgallese 4 years ago
parent 6e426c9b04
commit 4f87dc349f

@ -214,13 +214,7 @@ abstract class DateUtils {
@JvmStatic
fun getStartOfTodayCalendarWithOffset(): GregorianCalendar = getCalendar(getStartOfTodayWithOffset())
@JvmStatic
fun getTimeZone(): TimeZone {
return fixedTimeZone ?: TimeZone.getDefault()
}
@JvmStatic
fun getTimezone(): TimeZone {
private fun getTimeZone(): TimeZone {
return fixedTimeZone ?: TimeZone.getDefault()
}
@ -236,8 +230,7 @@ abstract class DateUtils {
startDayMinuteOffset = minuteOffset
}
@JvmStatic
fun getLocale(): Locale {
private fun getLocale(): Locale {
return fixedLocale ?: Locale.getDefault()
}

@ -274,6 +274,23 @@ class DateUtilsTest : BaseUnitTest() {
assertThat(truncate(field, t2, firstWeekday), equalTo(expected))
}
@Test
fun testTruncate_timestamp() {
val field = DateUtils.TruncateField.YEAR
val nonTruncatedDate = unixTime(2016, Calendar.MAY, 30)
val expected = Timestamp(unixTime(2016, Calendar.JANUARY, 1))
assertThat(expected, equalTo(truncate(field, Timestamp(nonTruncatedDate), firstWeekday)))
}
@Test
fun testGetUpcomingTimeInMillis() {
setFixedLocalTime(FIXED_LOCAL_TIME)
setFixedTimeZone(TimeZone.getTimeZone("GMT"))
val expected = unixTime(2015, Calendar.JANUARY, 25, 10, 1)
val upcomingTimeMillis = DateUtils.getUpcomingTimeInMillis(10, 1)
assertThat(expected, equalTo(upcomingTimeMillis))
}
@Test
@Throws(Exception::class)
fun testMillisecondsUntilTomorrow() {

Loading…
Cancel
Save