从长到长格式转换 [英] Convert from Long to date format
本文介绍了从长到长格式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以Long格式将此值转换为String或Date格式:1343805819061
>可以将其转换为日期格式?
谢谢。
解决方案
可以使用下面的代码行来做到这一点。这里的timeInMilliSecond是很长的值。
String dateString = new SimpleDateFormat(MM / dd / yyyy)format(new Date TimeinMilliSeccond));
或者您也可以使用以下代码。
String longV =1343805819061;
long millisecond = Long.parseLong(longV);
//或者你已经有很长的日期值,使用这个而不是毫秒变量。
String dateString = DateFormat.format(MM / dd / yyyy,new Date(millisecond))。toString();
参考: - DateFormat 和 SimpleDateFormat
PS根据需要更改日期格式。
I want to convert Long value to String or Date in this format dd/mm/YYYY.
I have this value in Long format: 1343805819061.
It is possible to convert it to Date format?
Thanks.
解决方案
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));
Or you can use below code too also.
String longV = "1343805819061";
long millisecond = Long.parseLong(longV);
// or you already have long value of date, use this instead of milliseconds variable.
String dateString = DateFormat.format("MM/dd/yyyy", new Date(millisecond)).toString();
Reference:- DateFormat and SimpleDateFormat
P.S. Change date format according to your need.
这篇关于从长到长格式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文