Reputation: 1514
I'm using Kotlinx.dateTime. And I need to get the current date and the current date - 12 months.
Here is my code for current date:
val currentDate: LocalDateTime = Clock.System.now()
.toLocalDateTime(TimeZone.currentSystemDefault())
But I can't understand how to retrieve current date - 12 months. Because as far as I can see kotlin.time.Duration does not contain Duration.Months, only NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS. So I can't write something like this:
val lastYear: LocalDateTime = Clock.System.now().minus(12.months).toLocalDateTime(
TimeZone.currentSystemDefault()
Please help me.
Upvotes: 1
Views: 588