public static Date fromJavaUtilDate ( java . util . Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; cal . set ( Calendar . HOUR_OF_DAY , 0 ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; // Calender.MONTH starts from 0 while G C date starts from 1 return new Date ( cal . get ( Calendar . YEAR ) , cal . get ( Calendar . MONTH ) + 1 , cal . get ( Calendar . DAY_OF_MONTH ) ) ; }
Convert a Java Util Date to a Google Date .