Android examples for java.util:Month
get First Date Of Month by different format
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String fm = "yyyy/MM/dd/"; public static String fm2 = "MM/dd/"; public static String getFirstDateOfMonth(int i) { SimpleDateFormat sdf = null; if (i == 1) { sdf = new SimpleDateFormat(fm); } else if (i == 2) { sdf = new SimpleDateFormat(fm2); }/*w w w .jav a 2s . c om*/ Date dt = new Date(); if (dt == null) return null; Calendar cal = Calendar.getInstance(); cal.setTime(dt); int days = cal.getActualMinimum(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, days); String result = sdf.format(cal.getTime()); return result; } }