将字符串设置为日历类型

时间:2013-02-25 14:48:25

标签: java string calendar

我有像

这样的代码
Customer_Todo_Master customerTodo=new Customer_Todo_Master();
customerTodo.setCALCDATE(String type);

此处setCALCDATE是日历类型。如何将字符串设置为此setCALCDATE()

1 个答案:

答案 0 :(得分:3)

使用SimpleDateFormat类:

String str="your string rep of cal"; 
Calendar cal = Calendar.getInstance();
cal.setTime(new SimpleDateFormat("your date format").parse(str));
customerTodo.setCALCDATE(cal);