Day to 12 A.M.





5
Date Submitted Wed. Oct. 11th, 2006 7:15 AM
Revision 1 of 1
Beginner toriwells
Tags com | Date | Java
Comments 0 comments
This function returns a Date object being set at 12 A.M. It is useful for comparing dates where you don't know if they'll come set at the beginning of the day or not.


    public static Date dayTo12AM( Date date ) {
        Calendar c = new GregorianCalendar();
        c.setTime( date );
        c.set( Calendar.HOUR_OF_DAY, 0 );
        c.set( Calendar.MINUTE, 0 );
        c.set( Calendar.SECOND, 0 );
        c.set( Calendar.MILLISECOND, 0 );
        return c.getTime();
    }


 

Ramon Maria Gallart

Comments

There are currently no comments for this snippet.

Voting