Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String firstDayOfMonth() { Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_MONTH, 1); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); } }