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/

  • 相关阅读:
    Android 操作系统的内存回收机制(转载)
    如何减少代码中的分支语句
    Android中动画学习
    Android中 AsyncTask
    Linux安装后更新系统
    看百度宣传片
    可爱的linux mint 11
    ubuntu 修改root密码
    SHA256加密算法封装[我的代码库]
    使用maven,svn和CruiseControl做持续集成
  • 原文地址:https://www.cnblogs.com/softidea/p/5905573.html
Copyright © 2011-2022 走看看