All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.norbitltd.spoiwo.utils.JavaTimeApiConversions.scala Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.norbitltd.spoiwo.utils

import java.util.Date
import java.time.{ZoneId, LocalDate => JLocalDate, LocalDateTime => JLocalDateTime}
import org.joda.time.{DateTime, LocalDate}

object JavaTimeApiConversions {

  implicit class RichJavaLocalDate(ld: JLocalDate) {
    def toDate: Date =
      new LocalDate(
        ld.getYear,
        ld.getMonthValue,
        ld.getDayOfMonth
      ).toDate
  }

  implicit class RichLocalDateTime(ldt: JLocalDateTime) {
    def toDate: Date =
      new DateTime(
        ldt.atZone(ZoneId.systemDefault()).toInstant.toEpochMilli
      ).toDate
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy