LoginSignup
1
0

More than 5 years have passed since last update.

JavaでClockとLocalDateTimeからOffsetDateTimeを生成する

Last updated at Posted at 2017-05-31

タイトルそのままだが、手もとにLocalDateTimeとClockのオブジェクトがあったときに、どうやってOffsetDateTimeに変換するか。

一発でできそうな気もするけど、調べた感じどうにもならそうだったので、ZonedDateTimeを経由した。

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0