Calendar.DATE : Calendar « java.util « Java by API






Calendar.DATE

   
/*
 * Output: 
Date: Apr 25 2006
Time: 4:36:28
Updated time: 10:29:22

 */

import java.util.Calendar;

public class MainClass {
  public static void main(String args[]) {
    String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
        "Sep", "Oct", "Nov", "Dec" };

    Calendar calendar = Calendar.getInstance();

    System.out.print("Date: ");
    System.out.print(months[calendar.get(Calendar.MONTH)]);
    System.out.print(" " + calendar.get(Calendar.DATE) + " ");
    System.out.println(calendar.get(Calendar.YEAR));

    System.out.print("Time: ");
    System.out.print(calendar.get(Calendar.HOUR) + ":");
    System.out.print(calendar.get(Calendar.MINUTE) + ":");
    System.out.println(calendar.get(Calendar.SECOND));

    calendar.set(Calendar.HOUR, 10);
    calendar.set(Calendar.MINUTE, 29);
    calendar.set(Calendar.SECOND, 22);

    System.out.print("Updated time: ");
    System.out.print(calendar.get(Calendar.HOUR) + ":");
    System.out.print(calendar.get(Calendar.MINUTE) + ":");
    System.out.println(calendar.get(Calendar.SECOND));
  }
}
           
         
    
    
  








Related examples in the same category

1.Calendar.AM_PM
2.Calendar.DAY_OF_WEEK_IN_MONTH
3.Calendar: DAY_OF_WEEK
4.Calendar.DAY_OF_YEAR
5.Calendar.DST_OFFSET
6.Calendar.ERA
7.Calendar.HOUR
8.Calendar.HOUR_OF_DAY
9.Calendar.MILLISECOND
10.Calendar.MINUTE
11.Calendar.MONDAY
12.Calendar: TUESDAY
13.Calendar.SECOND
14.Calendar.SUNDAY
15.Calendar.WEEK_OF_MONTH
16.Calendar.WEEK_OF_YEAR
17.Calendar.YEAR
18.Calendar.ZONE_OFFSET
19.Calendar: add(int field, int amount)
20.Calendar: after(Object when)
21.Calendar: before(Object when)
22.Calendar: int get(int field)
23.Calendar: getActualMaximum(int field)
24.Calendar: getDisplayNames(int field, int style, Locale locale)
25.Calendar: getFirstDayOfWeek()
26.Calendar: getInstance()
27.Calendar: getTime()
28.Calendar: set(int field, int value)
29.Calendar: set(int year, int month, int date)
30.Calendar: setTime(Date date)
31.Calendar: setTimeInMillis(long millis)