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/

  • 相关阅读:
    数据结构2
    EF Fluent API
    VS2017+mysql5.7 连接数据库生成实体
    JavaScript中的枚举
    EasyUI datagird 排序 按数字类型的问题
    php 将秒数转换为时间(年、天、小时、分、秒)
    mySQL把秒转换成日期
    Android 界面间传参数
    android 登陆界面
    Android 在已有的项目上创建新的项目
  • 原文地址:https://www.cnblogs.com/softidea/p/5905573.html
Copyright © 2011-2022 走看看