zoukankan      html  css  js  c++  java
  • Joda-Time

    根据Millis计算minutes:

    demo:

    import org.joda.time.Interval;
    import org.joda.time.LocalDateTime;
    
    /**
     * Created by tang.cheng on 2017/5/19.
     */
    public class Test {
    
        public static void main(String[] args) {
            long startTime = LocalDateTime.now().toDate().getTime();
            int millis = 1234567890;
            System.out.println("plus millis:" + millis);
            long endTime = LocalDateTime.now().plusMillis(millis).toDate().getTime();
            System.out.println("startTime:" + startTime + " 
    endTime:" + endTime);
    
            long totalTime = endTime - startTime;
            System.out.println("TotalMillis: " + totalTime);
            long l = totalTime / 60 / 1000;
            System.out.println("Total minutes:" + l + (millis == totalTime ? "没有精度损失" : "有精度损失"));
    
            Interval interval = new Interval(startTime, endTime);
            long standardMinutes = interval.toDuration().getStandardMinutes();
            System.out.println("Total minutes:" + standardMinutes);
        }
    }

    http://1985wanggang.blog.163.com/blog/static/7763833201371341545546/

    http://www.yihaomen.com/article/java/405.htm

    withMillis

    public DateTime withMillis(long newMillis)
    Returns a copy of this datetime with different millis.

    The returned object will be either be a new instance or this. Only the millis will change, the chronology and time zone are kept.

    Parameters:
    newMillis - the new millis, from 1970-01-01T00:00:00Z
    Returns:
    a copy of this datetime with different millis

    http://www.joda.org/joda-time/

  • 相关阅读:
    Java 字节码解释说明
    JVM垃圾回收:G1回收器
    JVM 参数
    HotSpot 虚拟机对象探秘
    JDK 内置图形界面工具
    Java 内存模型
    在网络设备上调试 Android 程序
    .NET MVC异步调用中的Session问题
    在MVC的ApiController中实现统一校验
    使用 AndroidX86 在虚拟机中作为调试设备
  • 原文地址:https://www.cnblogs.com/softidea/p/5905573.html
Copyright © 2011-2022 走看看