Hien Nguyen
09/21/2021, 7:58 AMio.ktor.util.date.GMTDate
how to get timestamp of next month with GMTDate ๐ ?Aleksei Tirman [JB]
09/21/2021, 9:11 AMHien Nguyen
09/21/2021, 9:14 AMConsider a GregorianCalendar originally set to August 31, 1999. Calling add(Calendar.MONTH, 13) sets the calendar to September 30, 2000.
๐Aleksei Tirman [JB]
09/21/2021, 10:05 AMval date = GMTDate(0, 0, 0, 31, io.ktor.util.date.Month.AUGUST, 1999)
val instant = Instant.fromEpochMilliseconds(date.timestamp)
val result = instant.plus(13, DateTimeUnit.MONTH, TimeZone.of("GMT"))
val local = result.toLocalDateTime(TimeZone.of("GMT"))
val newDate = GMTDate(seconds = local.second, minutes = local.minute, hours = local.hour, dayOfMonth = local.dayOfMonth, month = io.ktor.util.date.Month.from(local.monthNumber - 1), year = local.year)
println(newDate.toJvmDate())
Please file a feature request if you want to see this functionality in Ktor.Hien Nguyen
09/21/2021, 10:11 AMhfhbd
09/21/2021, 10:30 AMHien Nguyen
09/21/2021, 10:31 AM