Working with date and time

http://www.wilsonmar.com/datepgms.htm

Interesting link

Some java source code for working with a calendar

>> Monday, September 13, 2004 4:54:20 PM - Comments by satya

Calendar cal = Calendar.getInstance();
Date today = cal.getTime();
//2 days ago's date
Date 2daysAgo = cal.add(Calendar.DATE, -2).getTime();
//2 years ago
cal.add(Calendar.YEAR, -2);

Example of Date formats

  • SHORT is completely numeric, such as 12.13.52 or 3:30pm
  • MEDIUM is longer, such as Jan 12, 1952
  • LONG is longer, such as January 12, 1952 or 3:30:32pm
  • FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.