Java 格式化长时间戳

Java 格式化长时间戳,java,timestamp,Java,Timestamp,我使用此代码获取时间戳,将其转换为long,然后将其放入数据库中 Timestamp timeStamp = new Timestamp(date.getTime()); long lonTime = timeStamp.getTime(); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Entity post = new Entity("post"); post.setProperty("

我使用此代码获取时间戳,将其转换为long,然后将其放入数据库中

Timestamp timeStamp = new Timestamp(date.getTime());
long lonTime = timeStamp.getTime();
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity post = new Entity("post");
post.setProperty("time", lonTime);
datastore.put(post);
我存储的时间看起来像time=1372369544272。
现在,当我得到它时,我如何格式化它以获得日期和时间?

要从时间戳中获取
日期和
时间,您需要传递
时间戳中的长值,就像-
时间戳t=新时间戳(1372369544272L)
一样


查看
时间戳
了解更多详细信息。

Timestamp t=新时间戳(长时间);你检查过这个了吗?首先,您应该知道时间戳是从日期开始扩展的。所以您可以这样做:通过TimeStamp t=newtimestamp(long)获取时间戳;与按日期获取日期相同d=新日期(长);当您想要获得像“ddMMM”这样的格式时,使用SimpleDataFormat,使用日历来计算日期