Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
// Calculate the moment when someone has lived for 10^9 seconds.
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.Month
fun main(args: Array<String>) {
// Should print 2043-01-01T01:46:40
println(Gigasecond(LocalDate.of(2011, Month.APRIL, 25)).date)
// Should print 2009-02-19T01:46:40
println(Gigasecond(LocalDate.of(1977, Month.JUNE, 13)).date)
}
data class Gigasecond(val dobWithTime: LocalDateTime) {
constructor(dateOfBirth: LocalDate) : this(dateOfBirth.atStartOfDay())
private val GIGASECOND = Math.pow(10.0, 9.0).toLong()
val date: LocalDateTime = dobWithTime.plusSeconds(GIGASECOND)
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more