Friday, February 26, 2010

Dating with Date and Flirting with Calendar

import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
import java.util.*;
import java.util.Collections;
import java.text.SimpleDateFormat;
import java.text.ParseException;

public class DatingWithDate {

private static final SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
protected final static long MILLSECS_PER_DAY = 24L * 60L * 60L * 1000L;

public static void main (String[] args) throws IOException, ParseException {
Calendar now = Calendar.getInstance();
printCalendar (now);
now.add(Calendar.DAY_OF_YEAR,1);
printCalendar (now);
System.exit(0);

}
private static void printCalendar(Calendar calendar)
{
String date = df.format(calendar.getTime());
System.out.println(date);
}

}

No comments:

Post a Comment