Showing posts with label next month. Show all posts
Showing posts with label next month. Show all posts

Tuesday, November 26, 2013

First day of next month with java Time


public static Date getNextMonth() {
    Date current = new Date();
    Calendar c = Calendar.getInstance();
    c.setTime(current);
    c.add(Calendar.MONTH, 1);
    c.set(Calendar.DATE, 1);

    c.set(Calendar.HOUR, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    return c.getTime();
}

Date nextMonth = getNextMonth();
System.out.println(nextMonth);

And output as if you check it withing november month.

Sun Dec 01 00:00:00 ALMT 2013