GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — java.time.OffsetDateTime Class in Java - GeeksforGeeks java.time.OffsetDateTime Class in JavaLast Updated : 9 Sep, 2026 The
Example: Program uses
Output Date and Time: 2026-09-08T04:20:55.125272274Z Year: 2026 Month: SEPTEMBER Day: TUESDAY Hour: 4 Minute: 20 Second: 55 Explanation: The program creates an OffsetDateTime object using the system clock and then uses methods such as getYear(), getMonth(), getDayOfWeek(), getHour(), getMinute(), and getSecond() to retrieve the corresponding values. Syntax
Methods to Get Date and Time Fields from OffsetDateTimeThe OffsetDateTime class provides individual getter methods for accessing different parts of a date-time. The following examples demonstrate retrieving date-related and time-related fields from the current date-time. 1. Get Year, Month and Day of WeekThe getYear(), getMonth(), and getDayOfWeek() methods retrieve the year, month, and day of the week from an OffsetDateTime object. The now() method first obtains the current date and time from the system clock.
Output 2026-09-08T04:04:53.152921914Z Year : 2026 | Month : SEPTEMBER | Day : TUESDAY Explanation: The program creates an OffsetDateTime object using now(). It then uses getYear(), getMonth(), and getDayOfWeek() to retrieve the year, month, and day of the week. The actual output depends on the system date and time. 2. Get Hour, Minute, Second and NanosecondThe getHour(), getMinute(), getSecond(), and getNano() methods retrieve individual time fields from an OffsetDateTime object. These methods provide the time components separately.
Output 2026-09-08T04:06:05.835923202Z Hour : 4 | Minute : 6 | Second : 5 | NanoSecond : 835923202 Explanation: The program obtains the current OffsetDateTime and retrieves its hour, minute, second, and nanosecond values. The exact values vary according to the system clock. Commonly Used Methods of OffsetDateTime
Comment Explore | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |