Local datetime
Update the code to create a date time object for May 15, 2024 at 2:30 PM in the UTC+2 timezone.
Java
var datetime = ZonedDateTime.of(
2024, 05, 15, 14, 30, 00, 0,
/*select:ZoneId.of("+02:00")*/
);
-
❏ "+02:30"
-
❏ "-02:00"
-
❏ ZoneId.of("02:00")
-
✓ ZoneId.of("+02:00")
Hint
Remember that:
- The timezone can be specified using ZoneId.of
- You need to specify the timezone offset in the format +hh:mm
or -hh:mm
Solution
The correct answer is:
Java
var datetime = ZonedDateTime.of(
2024, 05, 15, 14, 30, 00, 0,
ZoneId.of("+02:00")
);
The following code creates a DateTime object representing 2:30 PM on May 15, 2024 in the UTC+2 timezone:
Java
import java.time.ZonedDateTime;
import java.time.ZoneId;
var datetime = ZonedDateTime.of(
2024, 05, 15, 14, 30, 00, 0,
ZoneId.of("+02:00")
);
Lesson Summary
In this lesson, you enforced your understanding of working with dates and times in Neo4j using the Java driver.
In the next lesson, you will learn about spatial data types.