Calendar 转化 String
Calendar calendat = Calendar.getInstance();SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");String dateStr = sdf.format(calendar.getTime());
String 转化Calendar
String str="2016-6-25";SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");Date date =sdf.parse(str);Calendar calendar = Calendar.getInstance();calendar.setTime(date);
Date 转化String
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");String dateStr=sdf.format(new Date());
String 转化Date
String str="2016-6-25";SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");Date date= sdf.parse(str);
Date 转化Calendar
Calendar calendar = Calendar.getInstance();calendar.setTime(new java.util.Date());
Calendar转化Date
Calendar calendar = Calendar.getInstance();java.util.Date date =calendar.getTime();
String 转成 Timestamp
Timestamp ts = Timestamp.valueOf("2016-6-25 15:11:00");
Date 转 TimeStamp
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String time = df.format(new Date());Timestamp ts = Timestamp.valueOf(time);