1、时间戳定义
时间戳是创建、修改和访问文件属性的时间。
数字时间戳技术是数字签名技术变种的应用。 在电子商务文档中,时间是非常重要的信息。 在书面合同中,文件签署的日期和签名一样,是防止文件伪造和篡改的非常重要的内容。 数字时间戳服务(dts )是互联网上电子商务安全服务之一,用于安全地保护电子文件的日期和时间信息。
编辑本段的构成要素
时间戳(time-stamp )是一种加密的证书文档,由三个部分组成:
)1)需要时间戳的文件摘要) digest;
)2) DTS接收文件的日期和时间
)3) DTS的数字签名。
通常,时间戳用散列码加密用户需要首先进行时间戳的文件以创建摘要,将该摘要发送至DTS,DTS在添加接收到文件摘要的日期和时间信息后对该文件进行加密
书面文件的签名时间是签名者自己写的,但数字时间戳不是。 这是由认证机构DTS添加的,基于DTS接收到文档的时间。
2、时间戳被转换为date (或字符串)
//将时间戳转换为Sting或Date
simpledateformatformat=newsimpledateformat (yyyy-mm-ddhh 3360 mm : ss );
长时间=newlong (44555555;
stringd=format.format(time;
datedate=format.parse(d );
system.out.println (format tostring (date ) :’d );
system.out.println (format todate : ) date;
执行结果:
格式模拟(date ) :1970-01-06 11:45:55
format todate : tue Jan 0611:45336055 CST 1970
3、date (或字符串)被转换为时间戳
//Date或String转换为时间戳
simpledateformatformat=newsimpledateformat (yyyy-mm-ddhh 3360 mm : ss );
stringtime=' 1970-01-0611336045336055 ';
datedate=format.parse(time;
system.out.print (' formattotimes : ' date.gettime ) );
执行结果:
格式为to times :44555000
4、注意
在定义简单数据格式时,使用newsimpledateformat (yyyy-mm-ddhh : mm : ss ); 字符串的末尾不能有空格。 如果有空间的话,在转换时对应的时间空间中也必须加入空间。 例如,以下内容:
//Date或String转换为时间戳
simpledateformatformat=newsimpledateformat (yyyy-mm-ddhh 3360 mm : ss );
stringtime=' 1970-01-0611336045336055 ';
datedate=format.parse(time;
system.out.print (' formattotimes : ' date.gettime ) );
执行结果(错误) :
exceptioninthread ' main ' Java.text.parse exception 3360 unparseabledate : ' 1970-01-0611336045336055 '
更正:
//Date或String转换为时间戳
simpledateformatformat=newsimpledateformat (yyyy-mm-ddhh 3360 mm : ss );
stringtime=' 1970-01-0611336045336055 '; //注:修改后,在这里的前后也加入了空格
datedate=format.parse(time;
system.out.print (' formattotimes : ' date.gettime ) );
执行结果:
格式为to times :44555000