import java.util.Calendar;
import java.io.*;
public class umur
{
public static void main(String[] args)
{ BufferedReader dataIn = new BufferedReader(
new InputStreamReader(System.in));
Calendar cal = Calendar.getInstance();
int hari = cal.get(Calendar.DATE);
int bulan = cal.get(Calendar.MONTH)+1;
int tahun = cal.get(Calendar.YEAR);
int tgl=0,bln=0,thn=0,a=0,b=0,c=0;
try {
System.out.print(“Masukkan tanggal lahir anda: “);
tgl = Integer.parseInt(dataIn.readLine());
} catch (Exception e) {}
try {
System.out.print(“Masukkan bulan lahir anda: “);
bln = Integer.parseInt(dataIn.readLine());
} catch (Exception e) {}
try {
System.out.print(“Masukkan tahun lahir anda: “);
thn = Integer.parseInt(dataIn.readLine());
} catch (Exception e) {}
System.out.println(“Tanggal lahir anda adalah : ” + tgl +”-“+ bln +”-“+ thn);
System.out.println(“Tanggal hari ini adalah : ” + hari + “-” + bulan + “-” + tahun );
System.out.println(“Anda telah berumur : ” );
a = tahun – thn;
System.out.println(“\t\t\t” + a + ” Tahun” );
b = bulan – bln – 1;
System.out.println(“\t\t\t” + b + ” Bulan” );
c = 30 + hari – tgl;
System.out.println(“\t\t\t” + c + ” Hari” );
}
}
saya belum masukkin tentang tahun kabisat, jadi harap ngeshare lagi bagi yang sudah.