Java Month Get getMonthStartTime(int year, int month)

Here you can find the source of getMonthStartTime(int year, int month)

Description

get Month Start Time

License

Apache License

Declaration

public static String getMonthStartTime(int year, int month) 

Method Source Code


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

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

public class Main {
    public static final String simple = "yyyy-MM-dd HH:mm:ss";

    public static String getMonthStartTime(int year, int month) {
        Calendar now = Calendar.getInstance(Locale.CHINA);
        if (year > 2014) {
            now.set(Calendar.YEAR, year);
        }//www.  ja va2  s . c o  m
        now.set(Calendar.MONTH, month - 1);
        now.set(Calendar.DAY_OF_MONTH, 1);
        now.set(Calendar.HOUR_OF_DAY, 0);
        now.set(Calendar.MINUTE, 0);
        now.set(Calendar.SECOND, 0);
        Date date = now.getTime();
        DateFormat format = new SimpleDateFormat(simple);
        String abcd = format.format(date);
        return abcd;
    }
}

Related

  1. getMonthPath(Date date)
  2. getMonthRange(String strBeginDate, String strEndDate, String pattern)
  3. getMonths()
  4. getMonths(DateFormatSymbols symbols)
  5. getMonthSpace(Date date)
  6. getMonthString(Date date)
  7. getMonthString(int month)
  8. getMonthStringFromNumber(String monthNumber)
  9. getMonthStrings()