日期:2014-05-20 浏览次数:20715 次
public static void main(String[] args) throws ParseException{
String str1 = "20111031143545410655";
String str2 = "2011-10-27-09.19.55.428866";
String str3 = "100833";
DateFormat df1 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
Date date1 = df1.parse(str1);
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS");
Date date2 = df2.parse(str2);
DateFormat df3 = new SimpleDateFormat("HHmmss");
Date date3 = df3.parse(str3);
df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s1 = df1.format(date1);
df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s2 = df2.format(date2);
df3 = new SimpleDateFormat("HH:mm:ss");
String s3 = df3.format(date3);
System.out.println("时间1:"+s1);
System.out.println("时间2:"+s2);
System.out.println("时间3:"+s3);
}
String str,str2;
str="100833";
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("HHmmss");
Date date=simpleDateFormat.parse(str);
SimpleDateFormat simpleDateFormat2=new SimpleDateFormat("HH:mm:ss");
str2=simpleDateFormat2.format(date);
System.out.println(str2);