Advertisement

Udemy WW Udemy WW

Thursday, 3 September 2020

Java code to find first day of the month

 

 Calendar cal = Calendar.getInstance();  

 cal.set(Calendar.DAY_OF_MONTH, 1);

 System.out.println("First day of the current month:-"+c.getTime());



Java -8 (using java.time)


LocalDate currentDate = LocalDate.now();

System.out.println("First day of the current month:-" + currentDate.withDayOfMonth(1));

No comments:

Post a Comment

Advertisement

Udemy WW