Friday, August 10, 2012

To get coming Start of the day in java

public Date getComingStartoftheDay()
    {
        java.util.GregorianCalendar today = (GregorianCalendar) Calendar.getInstance();
        today.set(Calendar.HOUR_OF_DAY, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);

        Timestamp ts = new Timestamp(today.getTime().getTime()+86400000);
        Date date = new Date(ts.getTime());
        System.out.println(date);
        return date;
    }

No comments:

Post a Comment