用户输入时间和当前时间比较空指针
case R.id.find:
simpleDate=new SimpleDateFormat("yyyy--MM--dd");
date_back=new Date();
String backStr= simpleDate.format(date_back);
back_tiem.setText(backStr);
String name= out_time.getText().toString();
Date date_out=null;
try{
if (date_out==null){
date_out=simpleDate.parse(name);
//date_out为什么 为 null
}
}catch (ParseException e){
e.printStackTrace();
}
if (date_out.getTime()>date_back.getTime())
{
finish();
}
break;
正在回答
if (date_out==null) 为什么要加判断?直接让 date_out=simpleDate.parse(name);不就行了 判断的意义何在~
- 参与学习 人
- 提交作业 5461 份
- 解答问题 7235 个
此次推出的专题为Android攻城狮培养计划的第一部分语法与界面基础篇,将带大家从0开始学习Android开发。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星