You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to convert the following Java 8 Desugar DateTime.
val currentDate = LocalDateTime.now().atOffset(ZoneOffset.UTC)
val currentDateInMilli = currentDate.toInstant().toEpochMilli()
val oldestDateInMilli = currentDate.minusYears(currentDate.year - 2009L).toInstant().toEpochMilli()
val previousMonthInMilli = currentDate.minusMonths(1).toInstant().toEpochMilli()
I ended up with this
val now = Clock.System.now()
val currentDate = now.toLocalDateTime(TimeZone.UTC)
val currentDateInMilli = currentDate.toInstant(TimeZone.UTC).toEpochMilliseconds()
val oldestDateInMilli = now.minus(currentDate.year - 2009L, DateTimeUnit.YEAR, TimeZone.UTC).toEpochMilliseconds()
val previousMonthInMilli = now.minus(1, DateTimeUnit.MONTH, TimeZone.UTC).toEpochMilliseconds()
What I noticed is the repeated setting of TimeZone, would it be good if there will be a default value on it by reusing the TimeZone used on its origin?
The text was updated successfully, but these errors were encountered:
I am trying to convert the following Java 8 Desugar DateTime.
I ended up with this
What I noticed is the repeated setting of TimeZone, would it be good if there will be a default value on it by reusing the TimeZone used on its origin?
The text was updated successfully, but these errors were encountered: