How to get name of the first day of a month?

To get the first date of the current month, use java.util.Calendar. First get an instance of it and set the field Calendar.DAY_OF_MONTH to the first date of the month. Since the first day of any month is 1, inplace of cal.getActualMinimum(Calendar.DAY_OF_MONTH), 1 can be used here.

private Date getFirstDateOfCurrentMonth() {
  Calendar cal = Calendar.getInstance();
  cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
  return cal.getTime();
}

Leave a Comment