Java SimpleDateFormat.format抛出java.lang.IllegalArgumentException

时间:2015-12-31 07:04:35

标签: java android oracle simpledateformat illegalargumentexception

我需要从Date对象获取“Day of day”。我试图将Date对象中的Day编号解析为new SimpleDateFormat("u").format(date)

根据SimpleDateFormat u : Day number of week (1 = Monday, ..., 7 = Sunday)

的Oracle文档

这是例外情况

enter image description here

2 个答案:

答案 0 :(得分:0)

试试这个以获取约会的日期......

Calendar c = Calendar.getInstance();
c.setTime(yourDate);//Replace your date with the date which u have
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);

答案 1 :(得分:0)

使用此

Calendar c = Calendar.getInstance(); //create an instance of Calendar class
int Day = c.get(Calendar.DAY_OF_WEEK); //get current day of the week from the same instance