Create new date without time component


import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
  public static void main(String[] argv) {
    DateFormat IN_TIMESTAMP_FORMAT = new SimpleDateFormat("d/M/yy H:mm:ss.SSS");
    
    System.out.println(IN_TIMESTAMP_FORMAT.format(DateUtil.newDate()));
  }
}

class DateUtil {
  public static Date newDate() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date newDate = cal.getTime();
    return newDate;
  }

}

Output:


5/9/12 0:00:00.000
Home 
  Java Book 
    Runnable examples  

Date Calendar Timestamp:
  1. Create a Date for a Particular Date
  2. Create Date from specific time span
  3. Create new date without time component
  4. Create new java.sql.Timestamp
  5. Create Date with day, month and year
  6. Create Calendar for a specific date
  7. Compute days between 2 dates
  8. Calculate the age
  9. Time Distance in hours and minutes