Java Date Time Java Java API
java.time.OffsetDateTime
public int getMonthValue()
Returns the month-of-year field as int.
package com.logicbig.example.offsetdatetime;import java.time.LocalDateTime;import java.time.OffsetDateTime;import java.time.ZoneOffset;public class GetMonthValueExample { public static void main (String... args) { OffsetDateTime d = OffsetDateTime.of(LocalDateTime.of(2010, 10, 3, 11, 43), ZoneOffset.ofHours(-5)); int monthValue = d.getMonthValue(); System.out.println(monthValue); }}
10