java数据转换问题:下面方法是将时间转换成秒,怎么能把这个时间在转换成原来的时间格式00:00:00.0啊?

Python010

java数据转换问题:下面方法是将时间转换成秒,怎么能把这个时间在转换成原来的时间格式00:00:00.0啊?,第1张

SimpleDateFormat dateformat=new SimpleDateFormat("HH:mm:ss. E ")

String a2=dateformat2.format(new Date())

即可 想要什么格式就什么格式 很简单的 SimpleDateFormat还可以加年月日 等等

如:SimpleDateFormat dateformat2=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ")

Date类有一个getTime()可以换回秒数,例如:

public class DateToSecond

{

public static void main(String[] args)

{

Date date = new Date(System.currentTimeMillis())

System.out.println(date.getTime())

}

}