1.Calendar 轉化 String java
//獲取當前時間的具體狀況,如年,月,日,week,date,分,秒等 ide
Calendar calendat = Calendar.getInstance();orm
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");get
String dateStr = sdf.format(calendar.getTime());it
2.String 轉化Calendarform
String str="2010-5-27";class
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");date
Date date =sdf.parse(str);im
Calendar calendar = Calendar.getInstance();di
calendar.setTime(date);
3.Date 轉化String
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
String dateStr=sdf.format(new Date());
4.String 轉化Date
String str="2010-5-27";
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Date birthday = sdf.parse(str);
5.Date 轉化Calendar
Calendar calendar = Calendar.getInstance();
calendar.setTime(new java.util.Date());
6.Calendar轉化Date
Calendar calendar = Calendar.getInstance();
java.util.Date date =calendar.getTime();