Topic: Using the Calendar class is calculated from the date of his birth today, how many days, then your date of birth using the format of the output SimpleDateFormat class setting display.

package po;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class time {

     * @param args
     * @throws ParseException 
    public static void main(String[] args) throws ParseException {
        Calendar ca=Calendar.getInstance();
        long e=System.currentTimeMillis();//获得当前时间毫秒值
        System.out.println (E); 
        Scanner Re = new new Scanner (; 
        System.out.println ( "Please enter the year of birth" ); 
        String BIR = re.nextLine (); 
           SimpleDateFormat SDF = new new SimpleDateFormat ( " yyyy, MM month dd " ); 
            a date DA = sdf.parse (BIR); // time date turn into type 
          String = sdf.format the GeSHi (DA); // formatting time 
        ca.setTime (DA); // setting his birthday date 
        Long BIR1 ca.getTimeInMillis = (); // get birthday milliseconds 
        System.out.println (geshi);

        System.out.println (BIR1); 
        System.out.println ((E -bir1) / 1000/60/60/24); // do all the time difference between the rotation output 

        // da.getTime ();
         // String = agf.format nowtim (DA); 





Guess you like