This program demonstrates how to get various information about the current month using the Month class of the java.time package.
The program first creates a LocalDate object representing the date "June 8, 2014". It then calls the getMonth() method on this object to obtain a Month object representing the month of June.
The program then obtains several pieces of information about this month using the following methods of the Month class:
Finally, the program prints out these pieces of information about the current month using System.out.println().
import java.time.*; class Get_Information_CurrentMonth { public static void main(String[] args) { LocalDate ldt = LocalDate.of(2014, Month.JUNE, 8); Month m = ldt.getMonth(); int cm = m.getValue(); int dm = m.minLength(); int mdm = m.maxLength(); Month firstMonthOfQuarter = m.firstMonthOfQuarter(); System.out.println("Current Month of Number : " + cm); System.out.println("Number of Days in Month : " + dm); System.out.println("Maximum Number of Days in Month : " + mdm); System.out.println("First Month of the Quarter : " + firstMonthOfQuarter); } }
Current Month of Number : 6 Number of Days in Month : 30 Maximum Number of Days in Month : 30 First Month of the Quarter : APRIL
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions