• Java8 ChronoUnits枚举


    java.time.temporal.ChronoUnit 枚举在 Java8 中添加,以取代旧的API用来代表日,月等整数值

    让我们来看看他们的操作。

    使用所选择的任何编辑器创建下面的java程序在 C:/> JAVA

    Java8Tester.java

    import java.time.LocalDate;import java.time.temporal.ChronoUnit;public class Java8Tester {
       public static void main(String args[]){
          Java8Tester java8tester = new Java8Tester();
          java8tester.testChromoUnits(); 
       }
    
       public void testChromoUnits(){
    	   //Get the current date
           LocalDate today = LocalDate.now();
    	   System.out.println("Current date: " + today);	   
    	   //add 1 week to the current date
           LocalDate nextWeek = today.plus(1, ChronoUnit.WEEKS);
    	   System.out.println("Next week: " + nextWeek);	   
    	   //add 1 month to the current date
           LocalDate nextMonth = today.plus(1, ChronoUnit.MONTHS);
    	   System.out.println("Next month: " + nextMonth);	  
    	   //add 1 year to the current date
           LocalDate nextYear = today.plus(1, ChronoUnit.YEARS);
    	   System.out.println("Next year: " + nextYear);	  
    	   //add 10 years to the current date
           LocalDate nextDecade = today.plus(1, ChronoUnit.DECADES);
    	   System.out.println("Date after ten year: " + nextDecade);	  
       }	}
    点击链接查看详细内容

  • 相关阅读:
    Memcached简介
    TP5 volist
    Getting command line access to PHP and MySQL running MAMP on OSX
    PHP use
    PHP 命名空间(namespace)
    mac 使用 pf 做端口转发
    微信测试帐号如何设置URL和Token,以及相关验证的原理
    ionic开发笔记
    Eclipse下配置Maven
    css引用第三方字体库
  • 原文地址:https://www.cnblogs.com/hane/p/7305326.html
Copyright © 2020-2023  润新知