zoukankan      html  css  js  c++  java
  • 关于Unix时间戳转北京时间的问题

    工具在这里:http://tool.chinaz.com/Tools/unixtime.aspx?qq-pf-to=pcqq.group

    今天踩了坑,无论参数是多少,年份总是1970。才发现原来参数必须是long不能是int

        /*
         * 输入参数long类型的time,返回格式为yyyy-MM-dd HH:mm:ss的时间
         */
        public static String switchIntToDate(long time) {
            String pattern = "yyyy-MM-dd HH:mm:ss";
            String result = null;  
            Date date = new Date(time*1000);  
            SimpleDateFormat sd = new SimpleDateFormat(pattern);  
            result = sd.format(date);  
            return result;  
        }
    
        /*
         * 测试
         */
        public static void main(String[] args) {
            System.out.println(getCurrentYearAndMonth(0));
            System.out.println(switchIntToDate(1509678698));
        }
  • 相关阅读:
    ssh 命令
    mtr 命令
    ping 命令
    curl 命令
    echo 命令
    cp 命令
    sftp服务器配置
    tomcat性能优化
    消息队列
    深度学习
  • 原文地址:https://www.cnblogs.com/XJJD/p/7777263.html
Copyright © 2011-2022 走看看