java怎么获取19位时间戳

Python023

java怎么获取19位时间戳,第1张

public Long getToday(){

DateTime now = new DateTime()

return new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0, 0, 0).getMillis()

}

public Long getTomorrow(){

DateTime now = new DateTime()

return new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0, 0, 0).plusDays(1).getMillis()

}

时间戳通常是”yyyyMMddHHmmss“的,举例:

Date date = new Date()

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss")

String str = sdf.format(date)

输出结果:20150704173752。

备注:时间戳中的时间显示格式可以根据实际情况设置即可。

在线时间戳转换工具

在java中获取时间戳方式:

下面方法中,在调用Date构造函数而不传递参数的情况下,新创建的对象自动获得当前日期和时间。如果想传入特定日期,需将表示日期的字符串传递给Date构造函数。