实际上,我想找出两个日期之间的差异,但在当前日期得到不可分割的日期错误:
String act_dateString;
Calendar cal = Calendar.getInstance();
act_dateString = cal.getTime().toLocaleString();
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy/MM/dd");
Date date_old = null;
try {
date_old = formatter1.parse(act_dateString);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Logcat 显示:
10-21 00:03:34.904: W/System.err(770): java.text.ParseException: Unparseable date: Oct 21, 2013 12:03:34 AM
10-21 00:03:34.904: W/System.err(770): at java.text.DateFormat.parse(DateFormat.java:645)
10-21 00:03:34.914: W/System.err(770): at com.example.datesdifference.MainActivity.showDifference(MainActivity.java:60)
10-21 00:03:34.914: W/System.err(770): at com.example.datesdifference.MainActivity.onCreate(MainActivity.java:25)
10-21 00:03:34.914: W/System.err(770): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-21 00:03:34.914: W/System.err(770): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-21 00:03:34.914: W/System.err(770): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-21 00:03:34.914: W/System.err(770): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-21 00:03:34.914: W/System.err(770): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-21 00:03:34.914: W/System.err(770): at android.os.Handler.dispatchMessage(Handler.java:99)
10-21 00:03:34.914: W/System.err(770): at android.os.Looper.loop(Looper.java:123)
10-21 00:03:34.914: W/System.err(770): at android.app.ActivityThread.main(ActivityThread.java:4627)
我在谷歌上搜索过这个但无法解决这个问题。有人可以帮忙吗?