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/

  • 相关阅读:
    OpenFlow Switch学习笔记(一)——基础概念
    Open vSwitch 给虚拟机网卡限流(QoS)
    MySQL字符集或字符序
    timestamp和datetime
    MySQL Audit日志审计
    sysbench0.4.12测试query_cache_size和query_cache_type
    MySQL 异地 双机房同步之otter
    keep running
    Linux Bonding
    自动化测试-2.seleniumIDE
  • 原文地址:https://www.cnblogs.com/softidea/p/5905573.html
Copyright © 2011-2022 走看看