kotlin import com.soywiz.klock.* fun main() { val today = DateTime.now() val nextWeek = today + 1.week val nextMonth = today + 1.month val previousDay = today - 1.day println("Today: $today") println("Next week: $nextWeek") println("Next month: $nextMonth") println("Previous day: $previousDay") } kotlin import com.soywiz.klock.* fun main() { val now = DateTime.now() val formattedDate = now.format("YYYY-MM-dd") val formattedTime = now.format("hh:mm a") println("Formatted date: $formattedDate") println("Formatted time: $formattedTime") } kotlin import com.soywiz.klock.* fun main() { val now = DateTime.now() val newYorkTime = now.toTimezone(TimezoneOffset("-05:00")) val newYorkFormatted = newYorkTime.format("hh:mm a", locale = "en-US") val londonTime = now.toTimeZone("Europe/London") val londonFormatted = londonTime.format("hh:mm a", locale = "en-GB") println("New York time: $newYorkFormatted") println("London time: $londonFormatted") } kotlin import com.soywiz.klock.* fun main() { val today = DateTime.now() val tomorrow = today + 1.day val isTomorrow = tomorrow > today val isSameDay = tomorrow.isInSameDay(today) println("Is tomorrow? $isTomorrow") println("Is same day? $isSameDay") }


上一篇:
下一篇:
切换中文