导入Java.text.simple date format;
import java.util.Date;
将long字符串转换为格式时间并输出
公共类长串存储{
publicstaticvoidmain (stringargsp [ ] ) {
字符串时间=' 1256006105375 ';
数据=new date (long.parse long ) time );
simpledateformatformatter=newsimpledateformat (yyyy-mm-ddhh : mm : ss );
time=formatter.format (日期;
系统. out.println (time;
}
}
//将字符串转换为时间
公共类字符串todate {
publicstaticvoidmain (stringargsp () throws Exception{ )。
stringtime=' 2010-11-2011336010336010 ';
日期日期=null;
simpledateformatformatter=newsimpledateformat (yyyy-mm-ddhh : mm : ss );
date=formatter.parse (时间;
系统. out.println (date;
}
//获取当前系统时间并返回yyyy-MM-dd HH:mm:ss字符串
公共类字符串模式