public class TestDate { public static void main(String[] args) { Calendar c = new GregorianCalendar(2008, 7, 8, 20, 8, 8);// 构建一个特定时间 Date d = c.getTime();// Date date = calendar.getTime();转换 System.out.println(d); Date d2 = new Date(); Calendar c2 = Calendar.getInstance();// new GregorianCalendar对象 c2.setTime(d2);// Date转换为Calendar System.out.println(d2); System.out.println(d2.getTime()); // 获得从1970的毫秒值 //格式显示时间 SimpleDateFormat bartDateFormat = new SimpleDateFormat( "EEEE-MMMM-dd-yyyy"); Date d3 = new Date(); System.out.println(bartDateFormat.format(d3)); //Strin转换为Date SimpleDateFormat bartDateFormat2 = new SimpleDateFormat("MM-dd-yyyy"); String dateStringToParse = "8-29-2009"; Date d4=null; try { d4 = bartDateFormat2.parse(dateStringToParse); } catch (ParseException e) { e.printStackTrace(); } System.out.println(d4); } }