zoukankan      html  css  js  c++  java
  • Timestamp_时间戳

    时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。

    package timestamp;

    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    import freemarker.template.SimpleDate;

    public class Test_timestamp {

      /**
      * @param args
      */
      public static void main(String[] args) {
        // TODO Auto-generated method stub
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = sdf.format(new Date().getTime()).toString();
        System.out.println(str+"-------------1");

        Timestamp ts = new Timestamp(System.currentTimeMillis());
        //String->Timestamp
        System.out.println(ts.valueOf(str)+"-------------2");

        //Timestamp->String
        System.out.println(sdf.format(ts).toString()+"-------------3");

        //Timestamp->Date
        Date date = new Date() ;
        date = ts;
        System.out.println(date+"-------------4");

        //Date->Timestamp
        //父类 子类
        Timestamp ts1 = new Timestamp(new Date().getTime());
        System.out.println(ts1);
      }

    }

       

  • 相关阅读:
    在Windows Phone应用中使用Google Map替代Bing Map
    《从入门到精通:Windows Phone 7应用开发》
    判断最小割的唯一性
    ASP.NET页面生命周期
    SQL排序
    window.open
    VS2008中英文转换
    asp.net下载文件的常用方法
    TSQL Convert转换时间类型
    TreeView
  • 原文地址:https://www.cnblogs.com/0914lx/p/6984837.html
Copyright © 2011-2022 走看看