zoukankan      html  css  js  c++  java
  • (转)JAVA打印零点时间

    public static void main(String[] args) throws ParseException
        {
            Date date = new Date(0);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            format.setTimeZone(TimeZone.getTimeZone("GMT"));
            System.out.println(format.format(date));
    
            long current = System.currentTimeMillis();// 当前时间毫秒数
            long zero = current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();// 今天零点零分零秒的毫秒数
            long twelve = zero + 24 * 60 * 60 * 1000 - 1;// 今天23点59分59秒的毫秒数
            long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000;// 昨天的这一时间的毫秒数
            System.out.println(format.format(new Date(current)));// 当前时间
            System.out.println(format.format(new Date(yesterday)));// 昨天这一时间点
            System.out.println(format.format(new Date(zero)));// 今天零点零分零秒
            System.out.println(format.format(new Date(twelve)));// 今天23点59分59秒
        }
  • 相关阅读:
    计算机通信网
    程序员面试——数学和概率
    位移枚举
    OC中的宏定义
    配置Xcode的Device Orientation、AppIcon、LaunchImage
    Xcode中的Project和Target
    NSObject
    CG
    UICollectionViewLayout
    UICollectionView
  • 原文地址:https://www.cnblogs.com/zhengchunhao/p/5702473.html
Copyright © 2011-2022 走看看