All pastes #708540 Raw Edit

Miscellany

public text v1 · immutable
#708540 ·published 2007-09-23 22:28 UTC
rendered paste body
import java.io.*;
import java.util.*;

public class SimpleMyTime
{
	//Initiate the BufferedReader to get user input
	public static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws IOException
	{
		Calendar cal = new GregorianCalendar();
		System.out.println("Please enter your birthdate in mm//dd//yyyy format:");
		String dateS = stdin.readLine();
		int length = dateS.length();
		String[] date = new String(dateS).split("\\/");
		String month=date[0];
		String day=date[1];
		String year=date[2];
		if (length > 10 | length < 10)
		{
			System.out.println("You did not enter the date in mm//dd//yyyy format!");
			return;
		}
		else
		{
			System.out.println("Wait...");
		}
		int useryear = Integer.parseInt(year);
		int usermonth = Integer.parseInt(month);
		int userday = Integer.parseInt(day);
		int currentyear = cal.get(Calendar.YEAR);
		/*int currentmonth = cal.get(Calendar.MONTH);
		int currentday = cal.get(Calendar.DAY_OF_MONTH);*/
		System.out.println("You are " + (currentyear - useryear) + " years old");
		Date userdate = new GregorianCalendar(useryear, usermonth, userday,00,00,00).getTime();
		Date today = new Date();
		Date dt = null;
		//long newtoday = dt.parse(today);
		//long newuserdate = dt.parse(Tuserdate);
		long diff = today - userdate;
		System.out.println("The 21st century (up to " + today + ") is "
		+ (diff / (1000 * 60 * 60 * 24)) + " days old.");
	
		

	}
	
}