I actually wnat to find difference between the two dates but get unparceable date error at the curent date :
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 shows:
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)
I have searched this on google but unable to resolve this. Can anybody help please ?