从长转换为日期格式转换为、日期、格式

由网友(来我怀里i)分享简介:我要以这种格式长值转换为字符串或日期DD / MM / YYYY。I want to convert Long value to String or Date in this format dd/mm/YYYY.我在长格式该值:1343805819061 I have this value in Long for...

我要以这种格式长值转换为字符串或日期DD / MM / YYYY。

I want to convert Long value to String or Date in this format dd/mm/YYYY.

我在长格式该值:1343805819061

I have this value in Long format: 1343805819061.

有可能将其转换为日期格式?

It is possible to convert it to Date format?

感谢。

推荐答案

您可以使用下面的code线做到这一点。这里timeInMilliSecond是长期的价值。

You can use below line of code to do this. Here timeInMilliSecond is long value.

 String dateString = new SimpleDateFormat("MM/dd/yyyy").format(new Date(TimeinMilliSeccond));

或者你也可以使用以下code过也。

Or you can use below code too also.

 String longV = "1343805819061";
 long millisecond = Long.parseLong(longV);
 String dateString= DateFormat.format("MM/dd/yyyy", new Date(millisecond)).toString();

参考: - 日期格式和SimpleDateFormat

P.S。根据您的需要更改日期格式

P.S. Change date format according to your need

阅读全文

相关推荐

最新文章