zoukankan      html  css  js  c++  java
  • java的日期时间处理(待更新)

    1.  /*
           * 将时间转换为时间戳
           */   
        public static String dateToStamp(String s) throws ParseException{
            String res;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = simpleDateFormat.parse(s);//注意s的格式
            long ts = date.getTime();
            res = String.valueOf(ts);
            return res;
        }

    2. /*
         * 将时间戳转换为时间
         */
        public static String stampToDate(String s){
            String res;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            long lt = new Long(s);
            Date date = new Date(lt);
            res = simpleDateFormat.format(date);
            return res;
        }

    天助自助者
  • 相关阅读:
    Eclipse 的单步调试
    CALayer快速入门
    UITableView快速入门
    iOS程序启动原理
    iOS触摸事件
    UITableViewCell重用和性能优化
    Autolayout
    iOS适配
    NSTimer
    UIScrollView
  • 原文地址:https://www.cnblogs.com/ZeGod/p/9953254.html
Copyright © 2011-2022 走看看