1、时间戳的定义

时间戳(timestamp),通常是一个数字序列,唯一地标识某一刻的时间,指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的毫秒数。

数字时间戳技术是数字签名技术一种变种的应用。在电子商务交易文件中,时间是十分重要的信息。在书面合同中,文件签署的日期和签名一样均是十分重要的防止文件被伪造和篡改的关键性内容。数字时间戳服务(DTS:digital time stamp service)是网上电子商务安全服务项目之一,能提供电子文件的日期和时间信息的安全保护。

时间戳(time-stamp)是一个经加密后形成的凭证文档,它包括三个部分:   

(1)需加时间戳的文件的摘要(digest);   

(2)DTS收到文件的日期和时间;   

(3)DTS的数字签名。   

一般来说,时间戳产生的过程为:用户首先将需要加时间戳的文件用Hash编码加密形成摘要,然后将该摘要发送到DTS,DTS在加入了收到文件摘要的日期和时间信息后再对该文件加密(数字签名),然后送回用户。   

书面签署文件的时间是由签署人自己写上的,而数字时间戳则不然,它是由认证单位DTS来加的,以DTS收到文件的时间为依据。

有时后台返回给我们的是时间戳,我们就需要转换一下才能展示。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAN4AAACSCAIAAACln+P3AAAgAElEQVR4nO2daXQT173A/b3NOW1yTtNSmp6mJ005CS8977VJT1/okkDTNnlpICErCQnYGMwWDGZfzRLCYocYg1kMNphgFhsMxth4t2UbvCDLm6TRPtpHGkmjZRbNct+H6w6DZBzbkCDs+R19sK/uzB3hH/fOnfvX/ScBGZmEJOlhX4CMzNDIasokKAmhZrsiPDlJOTlJOWsa0tUWgYV+nNu01PrsY6r3XtX1dJEP9wplvn8SQk2IIIDujsjncy1EgOM4kLPLdb4A53mg7qUyUlC/j3vYFyjzvTJSNVGFbfcTB3Y/cSB3ar7+hgkAAASgvoTkTs2H5YUzikkvyZJsW3ZH9tN5uVPze4sHeJaHh1dWVs6dO9fv9w/ThCCApurg7vUOhhFwD5uRjDrtUUEAdRXEK8+pVZ1yxzmxGHWvGTAT5WlVdIDGdf6Sj68StiAdZMrTqpy33QCAg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IDAMGj2fjg3khkzspoPBoFlsYvnO1/+o2LST9qmPGPcvJH13fM7+DIjQVZTJkGR1ZRJUGQ1ZRIUWU2ZBEVWUyZB+X+jmy6o2faDnAAAAABJRU5ErkJggg==" alt="" />

在easy-ui中

<div>
<table class="easyui-datagrid" id="userList" title="会员列表"
data-options="singleSelect:false,collapsible:true,pagination:true,url:'/rest/user/list',method:'get',pageSize:5,toolbar:toolbar,pageList:[2,5,10]">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'id',width:60">ID</th>
<th data-options="field:'userName',width:200">用户名</th>
<th data-options="field:'name',width:100">姓名</th>
<th data-options="field:'age',width:100">年龄</th>
<th data-options="field:'sex',width:80,align:'right',formatter:formatSet">性别</th>
<th data-options="field:'birthday',width:80,align:'right',formatter:formatBirthday">出生日期</th>
<th data-options="field:'created',width:130,align:'center',formatter:formatDate">创建日期</th>
<th data-options="field:'updated',width:130,align:'center',formatter:formatDate">更新日期</th>
</tr>
</thead>
</table>
</div>
formatter:后面是我们自定义的函数名,不是内置的
<script type="text/javascript">
function formatDate(val, row) {
var now = new Date(val);
return now.format("yyyy-MM-dd hh:mm:ss");
}
function formatBirthday(val, row) {
var now = new Date(val);
return now.format("yyyy-MM-dd");
}
function formatSet(val, row) {
if (val == 1) {
return "男";
} else if (val == 2) {
return "女";
} else {
return "未知";
}
}
function getSelectionsIds() {
var userList = $("#userList");
var sels = userList.datagrid("getSelections");
var ids = [];
for (var i in sels) {
ids.push(sels[i].id);
}
ids = ids.join(",");
return ids;
}
var toolbar = [{
text: '新增',
iconCls: 'icon-add',
handler: function () {
$('#userAdd').window('open');
}
}, {
text: '编辑',
iconCls: 'icon-edit',
handler: function () {
$.messager.alert('提示', '该功能由学员自己实现!');
}
}, {
text: '删除',
iconCls: 'icon-cancel',
handler: function () {
var ids = getSelectionsIds();
if (ids.length == 0) {
$.messager.alert('提示', '未选中用户!');
return;
}
$.messager.confirm('确认', '确定删除ID为 ' + ids + ' 的会员吗?', function (r) {
if (r) {
$.post("/user/delete", {'ids': ids}, function (data) {
if (data.status == 200) {
$.messager.alert('提示', '删除会员成功!', undefined, function () {
$("#userList").datagrid("reload");
});
}
});
}
});
}
}, '-', {
text: '导出',
iconCls: 'icon-remove',
handler: function () {
var optins = $("#userList").datagrid("getPager").data("pagination").options;
var page = optins.pageNumber;
var rows = optins.pageSize;
$("<form>").attr({
"action": "/user/export/excel",
"method": "POST"
}).append("<input type='text' name='page' value='" + page + "'/>")
.append("<input type='text' name='rows' value='" + rows + "'/>").submit();
}
}];
</script>
function formatDate(val, row) {
var now = new Date(val);
return now.format("yyyy-MM-dd hh:mm:ss");
}

上面的Date对象是js的内置对象,但是Date对象没有format方法!!!

以后可能会遇到这种问题,我们需要用到js内置对象的某些方法,但是我们发现这些内置对象没有这些方法!,咋办呢?我们自己来扩展!

Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
};
if(/(y+)/.test(format)){
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(format)){
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
};

时间戳处理

2、时间戳转化为Date(or String)

public class Test {
public static void main(String[] args) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Long time = new Long(460742400000L); String toString = format.format(time); Date toDate = format.parse(toString); System.out.println("Format To String:" + toString); System.out.println("Format To Date:" + toDate);
}
}

运行结果:

Format To String:1984-08-08 00:00:00
Format To Date:Wed Aug 08 00:00:00 CST 1984

3、Date(or String)转化为时间戳

public class Test {
public static void main(String[] args) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); String time="2016-11-06 11:45:55"; Date date = format.parse(time); System.out.print("Format To timestamp:" + date.getTime());
}
}

运行结果:

Format To times:1478403955000

4、注意

定义SimpleDateFormat时new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );里面字符串头尾不能有空格

java时间戳转date(转)的更多相关文章

  1. java 时间戳与date转换

    1.时间戳转换为date long sjc=1442633777; SimpleDateFormat t = new SimpleDateFormat("yyyyMMddHHmmss&quo ...

  2. 【Java】时间戳与Date相互转换

    时间戳转Date public static void main(String[] args) { // 10位的秒级别的时间戳 long time1 = 1527767665; String res ...

  3. java 时间戳和PHP时间戳 的转换

    java 时间戳和PHP时间戳 的转换 PHPJava  总结一下java 时间戳和PHP时间戳 的转换问题: 由于精度不同,导致长度不一致,直接转换错误. JAVA时间戳长度是13位,如:12948 ...

  4. Java时间戳与日期格式字符串的互转

    上代码: import java.text.SimpleDateFormat; import java.util.Date; public class DateUtil { /** * 时间戳转换成日 ...

  5. Java~时间戳小知识

    大叔对java时间戳使用的总结 Java里的Date对象有方法setTime,主要是将一个时间戳转成一个日期对象,而这个时间戳的标准是unix标准,即当前时间与1970/1/1相差的毫秒数,记得是毫秒 ...

  6. java 时间戳和PHP时间戳 的转换[10位和13位]

    2013-08-02 14:06 9826人阅读 评论(2) 收藏 举报 版权声明:本文为博主原创文章,未经博主允许不得转载. 总结一下java 时间戳和PHP时间戳 的转换问题:  由于精度不同,导 ...

  7. PHP java时间戳转php时间戳

    /** * java时间戳转php时间戳 * @param int $javaUt java的时间戳 * @return int * @Date 2019/8/26 */ public static ...

  8. Java时间戳获取

    Java时间戳获取方式: 1:New Date().getTime(); 2: System.currentTimeMillis();区别: New Date().getTime()的底层其实是Sys ...

  9. 3.Java基础之Date对象

    毕向东老师Java基础学习笔记——Date对象 今天学习Java中的Date对象后,感觉这个对象对我们主要有以下几点用处. 1.获取时间和日期并按照自己定义的格式显示. 2.网站设计时显示时间.  知 ...

随机推荐

  1. 安卓学习笔记---Activity

    由于学期实训的要求,我开始学习安卓了.从本月一号开始,学了五天了.时间短,刚学到的东西容易忘,我记一下笔记. 首先是对Activity的理解.activity首先是一个java类,我们创建一个新的ac ...

  2. fastjson 常用api

    一.json字符串的数据解析      1.json字符串 ---> JSONObject或者JSONArray[好处就是当你没有bean的model类时,可以直接获取相关数据]         ...

  3. c#是否参入中间变量交换变量的几种方法

    大家很熟悉知道,交换变量经常的使用的一种方法是使用第三个变量,也符合正常人的思维逻辑,但是还有其他的一些方法来实现,但是有点“偏门”,记住就好了.下面就列举这几种方法. 第一种方法,会用到参数的方法再 ...

  4. context:component-scan 分析

    <context:component-scan> Web.xml中 <servlet> <servlet-name>springMVC</servlet-na ...

  5. mobile cpu上禁用alpha test的相关总结

       因为,每家芯片的特性不同,根据向framebuffer写法的不同,分为tile-based的mobile cpu,如ImgTec PowerVR,ARM Mali,一部分老版本Qualcomm  ...

  6. 超实用PHP函数总结整理

    超实用PHP函数总结整理 2014-12-06    分类:WEB开发.编程开发.首页精华暂无人评论     来源:月光光博客 分享到:更多8 1.PHP加密解密 PHP加密和解密函数可以用来加密一些 ...

  7. 推荐25款php中非常有用的类库

    推荐25款php中非常有用的类库 投稿:hebedich 字体:[增加 减小] 类型:转载 时间:2014-09-29   作为一个PHP开发者,现在是一个令人激动的时刻.每天有许许多多有用的库分发出 ...

  8. php--某个字符在字符串中的位置比较

    <?php $haystack = 'helloe'; $needle = 'e'; $pos = stripos($haystack, $needle); echo "\n" ...

  9. poj1979

    #include<stdio.h>int map[4][4]={'.','.','.','.',      '#','.','.','.',      '.','#','.','.',   ...

  10. json数据交换

    1.1   为什么要进行json数据交互 json数据格式在接口调用中.html页面中较常用,json格式比较简单,解析还比较方便. 比如:webservice接口,传输json数据. 1.2   s ...