long
myDate
=
1270202674000L
;
SimpleDateFormat fm1 = new SimpleDateFormat( " MM " + " 月 " + " dd " + " 日 " );
String date = fm1.format(myDate);
首先,时间格式format是可以将number型的直接换换成时间Date类型
其次, long myDate = 1270202674000 ;总是报错,提示太长了,我将其删掉3位发现可以了,至此才想起来long型的需要在后面加“L”
也许还有朋友需要用字符串转换时间请看下面:
String unixDate = " 1259200976 " ;
SimpleDateFormat fm1 = new SimpleDateFormat( " dd/MM/yyyy HH:mm:ss " );
SimpleDateFormat fm2 = new SimpleDateFormat( " yyyy-MM-dd hh:mm:ss " );
long unixLong = 0 ;
String date = "" ;
unixLong = Long.parseLong(unixDate) * 1000 ;
date = fm1.format(unixLong);
date = fm2.format( new Date(date));
SimpleDateFormat fm1 = new SimpleDateFormat( " MM " + " 月 " + " dd " + " 日 " );
String date = fm1.format(myDate);
首先,时间格式format是可以将number型的直接换换成时间Date类型
其次, long myDate = 1270202674000 ;总是报错,提示太长了,我将其删掉3位发现可以了,至此才想起来long型的需要在后面加“L”
也许还有朋友需要用字符串转换时间请看下面:
String unixDate = " 1259200976 " ;
SimpleDateFormat fm1 = new SimpleDateFormat( " dd/MM/yyyy HH:mm:ss " );
SimpleDateFormat fm2 = new SimpleDateFormat( " yyyy-MM-dd hh:mm:ss " );
long unixLong = 0 ;
String date = "" ;
unixLong = Long.parseLong(unixDate) * 1000 ;
date = fm1.format(unixLong);
date = fm2.format( new Date(date));