Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date firstDateOfNextMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, 1); Date newDate = calendar.getTime(); return firstDateOfMonth(newDate); } public static Date firstDateOfMonth(Date date) { try { return (new SimpleDateFormat("yyyyMMdd")).parse((new SimpleDateFormat("yyyyMM")).format(date) + "01"); } catch (ParseException e) { return null; } } }