Generate OffsetDateTime from Clock and LocalDateTime in Java

The title is as it is, but how to convert it to OffsetDateTime when there are LocalDateTime and Clock objects at hand.

I feel like I can do it in one shot, but it seemed like I couldn't do anything about it, so I went through ZonedDateTime.

ZonedDateTime zonedDateTime = LocalDateTime.now().atZone(clock.getZone());
OffsetDateTime offsetDateTime = zonedDateTime.toOffsetDateTime();

Recommended Posts

Generate OffsetDateTime from Clock and LocalDateTime in Java
Capture and save from selenium installation in Java
JSON in Java and Jackson Part 1 Return JSON from the server
Implement Java Interface in JRuby class and call it from Java
Correct the character code in Java and read from the URL
Get attributes and values from an XML file in Java
Generate AWS Signature V4 in Java and request an API
Generate Stream from an array of primitive types in Java
Generate CloudStack API URL in Java
StringBuffer and StringBuilder Class in Java
Understanding equals and hashCode in Java
Hello world in Java and Gradle
Sort List in descending order in Java and generate a new List non-destructively
Study Deep Learning from scratch in Java.
Java starting from beginner, variables and types
JSON in Java and Jackson Part ③ Embed JSON in HTML and use it from JavaScript
Difference between final and Immutable in Java
Call Java method from JavaScript executed in Java
OCR in Java (character recognition from images)
Reverse Key from Value in Java Map
[Java] for Each and sorted in Lambda
Using JavaScript from Java in Rhino 2021 version
Gradle automatically generates version number from git and uses it in Java
Get history from Zabbix server in Java
Arrylist and linked list difference in java
Learn Flyweight patterns and ConcurrentHashMap in Java
Java Direction in C ++ Design and Evolution
Java to C and C to Java in Android Studio
Reading and writing gzip files in Java
Difference between int and Integer in Java
Discrimination of Enums in Java 7 and above
[Deep Learning from scratch] in Java 1. For the time being, differentiation and partial differentiation
GetInstance () from a @Singleton class in Groovy from Java
Regarding the transient modifier and serialization in Java
Create barcodes and QR codes in Java PDF
Detect similar videos in Java and OpenCV rev.2
Java method call from RPG (method call in own class)
Parallel and parallel processing in various languages (Java edition)
Generate normal distribution / lognormal distribution random numbers in Java
Difference between next () and nextLine () in Java Scanner
Differences in writing Java, C # and Javascript classes
How to get Class from Element in Java
Text extraction in Java from PDF with pdfbox-2.0.8
Get unixtime (seconds) from ZonedDateTime in Scala / Java
Add, read, and delete Excel comments in Java
Check static and public behavior in Java methods
[Java] Understand in 10 minutes! Associative array and HashMap
Basics of threads and Callable in Java [Beginner]
[Deep Learning from scratch] in Java 3. Neural network
Distinguish between positive and negative numbers in Java
Java adds and removes watermarks in word documents
Detect similar videos in Java and OpenCV rev.1
Represents "next day" and "previous day" in Java / Android
Questions in java exception handling throw and try-catch
Encrypt / decrypt with AES256 in PHP and Java
[Java] Get KFunction from Method / Constructor in Java [Kotlin]
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
Java and JavaScript
XXE and Java