-1
我想比较两个基于时间的因此我只是将时间转换为日期。java.text.ParseException:无法解析的日期:“9:30 AM”(在偏移量5)
我有分析时是这样的:
SimpleDateFormat h_mm_a = new SimpleDateFormat("h:mm a");
Date d1 = h_mm_a.parse(txtTimeFrom.getText().toString());
Date d2 = h_mm_a.parse(txtTimeTo.getText().toString());
if(d1.compareTo(d2)<0){
....................
}
else{
Toast.makeText(ExecutiveRouteTracking.this,"Invalid Time",Toast.LENGTH_SHORT).show();
}
它会抛出像
java.text.ParseException: Unparseable date: “9:30 AM” (at offset 5)
例外,任何一个可以帮助我解决问题比较两个时间?
都不行由于当乔达限制到Java 8? – Akshay
@Akshay
– Tom糟糕...它被添加到jdk 8..DateTimeFormatter类 – Akshay