如何使用time构造全新的固定格式Date呢?
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class hehe {
public static void main(String args[]) throws ParseException {
Date d = new Date();
long longtime = d.getTime();
System.out.println(Long.parseLong("1251876468000"));
// 你获得的是上面的long型数据吧
String time = d.toLocaleString();
// 你可以简单的得到本地化时间,本来就是String类型的就不用转换了
System.out.println(time);
// 也可以自己用SimpleDateFormat这个函数把它变成自己想要的格式,注意需要import java.text.SimpleDateFormat;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(Long.parseLong("1251876468000")));
Date d1=sdf.parse("2009-10-10 10:10:10");
System.out.println(d1);
}
}