Here you can find the source of getMonthStartTime(int year, int month)
public static String getMonthStartTime(int year, int month)
//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; } }