昆仑山:眼中无形心中有穴之穴人合一

夫君子之行,静以修身,俭以养德;非澹泊无以明志,非宁静无以致远。夫学须静也,才须学也;非学无以广才,非志无以成学。怠慢则不能励精,险躁则不能冶性。年与时驰,意与岁去,遂成枯落,多不接世。悲守穷庐,将复何及!

 

java:时区

import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;

public class Driver {
    public static void main(String[] args) {

        //获取系统剩余的内存空间
        long begin1 = Runtime.getRuntime().freeMemory();
        //获取系统的当前时间
        long start01 = System.currentTimeMillis();


        /**
         * ZonedDateTime=LocalDateTime+Zoneld
         * ·ZonedDateTime:带时区的日期和时间
         * ·ZoneId:新的时区对象(取代旧的java.util.TimeZone)
         * ·Instant:时刻对象(epoch seconds)
         */

        ZonedDateTime zonedDateTime=ZonedDateTime.now();//当前时区的日期和时间
        System.out.println(zonedDateTime);
        ZonedDateTime zonedDateTime1=ZonedDateTime.now(ZoneId.of("America/New_York"));
        System.out.println(zonedDateTime1);


//        关联到当前默认时区:
        LocalDateTime localDateTime=LocalDateTime.of(2019,05,06,10,37,57);
        ZonedDateTime zonedDateTime2=localDateTime.atZone(ZoneId.systemDefault());
        System.out.println(zonedDateTime2);


        //转换到纽约时区:
        ZonedDateTime zonedDateTime3=zonedDateTime2.withZoneSameInstant(ZoneId.of("America/New_York"));

        System.out.println(zonedDateTime3);

        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:43  Indian_Mysore  阅读(131)  评论(0编辑  收藏  举报

导航