java:日历
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Driver {
public static void main(String[] args) {
//获取系统剩余的内存空间
long begin1 = Runtime.getRuntime().freeMemory();
//获取系统的当前时间
long start01 = System.currentTimeMillis();
//当前时间:
Calendar calendar=Calendar.getInstance();
System.out.println(calendar.get(Calendar.YEAR));
System.out.println(calendar.get(Calendar.MONTH));
System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
System.out.println(calendar.get(Calendar.MINUTE));
System.out.println(calendar.get(Calendar.SECOND));
System.out.println(calendar.get(Calendar.MILLISECOND));
//或者
System.out.println(calendar.get(14));
System.out.println("\t\t");
//获取系统剩余的内存空间
long end2 = Runtime.getRuntime().freeMemory();
//获取系统的当前时间 单位是毫秒
long finish02 = System.currentTimeMillis();
System.out.println("本程序占用内存:" + (begin1 - end2));
System.out.println("本程序占用时间:" + (finish02 - start01));
}
}
posted on 2019-05-06 13:01 Indian_Mysore 阅读(110) 评论(0) 编辑 收藏 举报