public class TestTime {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年M月d日");
try {
Date d = sdf.parse("2013年1月6日");
sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(d));
System.out.println(d.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
}
这样就可以:
public static void main(String[] args) {
Date date = new Date();
Long time = date.getTime();
System.out.println(time);
Date d = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(d));
}