Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

OffsetDateTime to milliseconds

I would just convert the OffsetDateTime to an Instant and then use toEpochMilli:

long millis = book.getInteractionDuration().getStartTimeStamp().toInstant().toEpochMilli();

Unlike toEpochSecond(), this approach won't lose any more precision than is inherent in wanting milliseconds rather than nanoseconds.


Try this:

long millis = offsetDateTime.toInstant().toEpochMilli();

Tags:

Datetime

Java

Java 8

Related

SwiftUI: Generic parameter 'Subject' could not be inferred Emulator: Unexpected feature list: MultiDisplay VulkanNullOptionalStrings YUV420888toNV21 YUVCache React app is looking for static files in different location when using proxy What is app-ads.txt and how do I implement it in AdMob? What are reasons for the deprecation of Hyperledger Composer? How to merge multiple json files into one file in python No module named ipykernel_launcher How to solve Source path does not exist: resources/android/xml/network_security_config.xml starting container process caused "exec: > \"exec\": executable file not found in $PATH": unknown F# How to write a function that takes int list or string list How do you make a Button conditionally hidden or disabled? Find index position in nested lists for match

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy