Java Month Day previousMonthFirstDay()

Here you can find the source of previousMonthFirstDay()

Description

previous Month First Day

License

Open Source License

Declaration

public static String previousMonthFirstDay() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static final String DATE_PATTERN = "yyyy-MM-dd";

    public static String previousMonthFirstDay() {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
        Date curDate = new Date(System.currentTimeMillis());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(curDate);/*from   ww w. j  av a  2  s.  co m*/
        calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        return sdf.format(calendar.getTime());
    }
}

Related

  1. isLastDayOfMonth(Calendar cal)
  2. lastDayOfLastMonth()
  3. lastdayofmonth()
  4. lastDayOfMonth(String batdate)
  5. lastDayOfMonth(String src)