【发布时间】:2013-09-07 03:48:39
【问题描述】:
当我在 String 中有一个 Date 数组时,我想从 Java Date 对象中获取星期几。
SimpleDateFormat sourceDateformat = new SimpleDateFormat("yyyy-MM-dd");
public String[] temp_date;
public Int[] day = new Int[5];
Date[] d1= new Date[5];
Calendar[] cal= new Calendar[5]
try {
d1[i]= sourceDateformat.parse(temp_date[i].toString());
cal[i].setTime(d1[i]); // its not compiling this line..showing error on this line
day[i]= cal[i].get(Calendar.DAY_OF_WEEK);
}
catch (ParseException e) {
e.printStackTrace();
}
有人知道答案吗?
【问题讨论】:
-
错误是什么?您确定您使用的是 Calendar 对象所期望的正确日期对象 (java.util.Date)
标签: java android date calendar