Java Month Day getMonthFirstDay(String date)

Here you can find the source of getMonthFirstDay(String date)

Description

get Month First Day

License

Apache License

Declaration

public static Date getMonthFirstDay(String date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getMonthFirstDay(String date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
        Date d = null;/*from   w ww  .ja v a  2s .  co  m*/
        try {
            d = format.parse(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Calendar cal = Calendar.getInstance();
        if (d != null) {
            cal.setTime(d);
        }
        cal.add(Calendar.DAY_OF_MONTH, 0);
        return cal.getTime();
    }
}

Related

  1. getMonthEndDay(String time)
  2. getMonthEndDay(String yyyy, String mm)
  3. getMonthFirstDay()
  4. getMonthFirstDay()
  5. getMonthFirstDay(Date date)
  6. getMonthFirstDay(T date)
  7. getMonthFristWeekSunday(String month)
  8. getMonthLastDay()
  9. getMonthLastDay()