Skip to content

Instantly share code, notes, and snippets.

@mach-kernel
Created February 13, 2019 18:41
Show Gist options
  • Save mach-kernel/6585dd48ae98de3f9facc86a1491d5dc to your computer and use it in GitHub Desktop.
Save mach-kernel/6585dd48ae98de3f9facc86a1491d5dc to your computer and use it in GitHub Desktop.
Does your project use 99999 different timestamp types? Join my masochism!
import org.joda.time.{ LocalDateTime => JodaLocalDateTime }
import java.time.{ LocalDateTime => JavaLocalDateTime }
object JodaConversionImplicits {
implicit class JodaLocalDateTimeExtensions(val timestamp: JodaLocalDateTime) {
def toJavaLocalDateTime: JavaLocalDateTime = new JavaLocalDateTime(
timestamp.getYear,
timestamp.getMonthOfYear,
timestamp.getDayOfMonth,
timestamp.getHourOfDay,
timestamp.getMinuteOfHour,
timestamp.getSecondOfMinute,
// 10^-3 -> 10^-9, it's not a magic number, promise!
timestamp.getMillisOfSecond * 1000000
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment