public class MathDemo {
public static void main(String[] args) throws ParseException {
System.out.println("pi:"+Math.PI);
System.out.println("E:"+Math.E);
System.out.println("abs"+Math.abs(-10));
System.out.println("ceil"+Math.ceil(12.35));
System.out.println("floor"+Math.floor(12.56));
System.out.println("max"+Math.max(12,36));
System.out.println("Max:"+Math.max(Math.max(12,86),Math.max(25,98)));
System.out.println("pow"+Math.pow(3,4));
long ge =3;
System.out.println(Math.pow(ge,100));
System.out.println(System.currentTimeMillis());
long start=System.currentTimeMillis();
for (int i=0;i<10000000;i++)
{
System.out.println("hello"+i);
}
long endt=System.currentTimeMillis();
double diff=endt-start;
System.out.println(diff/1000);
long tinestamp=System.currentTimeMillis();
Date date1=new Date(tinestamp);
System.out.println();
long time =0;
Date date=new Date(9999999);
System.out.println(date.toLocaleString());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
Date date =new Date();
String strDate=simpleDateFormat.format(date);
System.out.println(strDate);
String strDate2="2015/08/09";
SimpleDateFormat simpleDateFormat1=new SimpleDateFormat("yyyy/MM/dd");
Date date2=simpleDateFormat1.parse(strDate2);
System.out.println(date2.toLocaleString());
你已经来到世界上多少天
package array;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class LiveDate {
public static void main(String[] args) throws ParseException {
System.out.println("请输入出生日期:");
Scanner scanner =new Scanner(System.in);
String strBirthDate=scanner.next();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy/mm/dd");
Date date=simpleDateFormat.parse(strBirthDate);
long birth_time =date.getTime();
Date date1=new Date();
long now_time=date1.getTime();
long diff = now_time - birth_time;
long days = diff/1000/60/60/24;
System.out.println( "你已经来到世界上"+ days+"天");