void addDate()
{
Calendar data = new GregorianCalendar(1982, 0, 1);
data.add(Calendar.DAY_OF_MONTH, 25);
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
System.out.println(df.format(data.getTime()));
}
String getToday(){
// (1) get today's date
Date today = Calendar.getInstance().getTime();
// (2) create our "formatter"
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd hh:mm");
// (3) create a new String in the format we want
String now = formatter.format(today);
// (4) this prints "Folder Name = 2009-09-06-08.23.23"
System.out.println(now);
return now;
}
void getToday2(){
String td = new SimpleDateFormat("dd/MM/yyyy").format(new GregorianCalendar().getTime());
System.out.println(td);
}
public static Calendar parseTimestamp(String timestamp)
throws Exception {
/*
** we specify Locale.US since months are in english
*/
SimpleDateFormat sdf = new SimpleDateFormat
("dd-MMM-yyyy HH:mm:ss", Locale.US);
Date d = sdf.parse(timestamp);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
return cal;
}