Java examples for java.util:Date Format
Uses todays date to create a new calendar that holds only the date information, not time.
//package com.java2s; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static void main(String[] argv) throws Exception { System.out.println(createNewDate()); }//from w ww . j a v a 2 s .c o m /** * Uses todays date to create a new calendar that holds only the date * information, not time. * @return Today's date with no time component. */ public static Calendar createNewDate() { Calendar cal = Calendar.getInstance(); if (cal instanceof GregorianCalendar) { return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); } else { return cal; } } }