-1

例如:我能够得到时间戳

String date="123456765343";
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(Long.parseLong(date)*1000);
    Date d = cal.getTime(); // now this reprents the unix timestamp

我想让日期看起来像这样:

2013 年 3 月 14 日下午 6:31:34

4

2 回答 2

4

您将不得不使用SimpleDateFormat(并且您不需要Calendar):

Date d = new Date(Long.parseLong(date) * 1000);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss a");
System.out.println(sdf.format(d));
于 2013-03-14T16:37:54.600 回答
1

您可以使用SimpleDateFormat来格式化您的日期。

于 2013-03-14T16:35:47.030 回答