Created
February 13, 2019 18:41
-
-
Save mach-kernel/6585dd48ae98de3f9facc86a1491d5dc to your computer and use it in GitHub Desktop.
Does your project use 99999 different timestamp types? Join my masochism!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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