I am trying to get the time of today's date at 11:59 in milliseconds using a timestamp. This is what I have tried. Now this code is working fine in one device but not in the other. It gives the error
E/test: printstacktrace
java.text.ParseException: Unparseable date: "29/04/2017 11:59:59 PM" (at offset 20)
at java.text.DateFormat.parse(DateFormat.java:579)
at curieo.android.zenmaster.mainfragments.HomeFragment$8.onDataChange(HomeFragment.java:723)
at com.google.android.gms.internal.zzbmz.zza(Unknown Source)
at com.google.android.gms.internal.zzbnz.zzYj(Unknown Source)
at com.google.android.gms.internal.zzboc$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
.
String currentDate = questiondateFormat.format(new Date(timeStampLong));
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a");
Date d = null;
try {
d = sdf.parse(currentDate + " " + "11:59:59 PM");
} catch (ParseException e) {
e.printStackTrace();
}
Calendar c = Calendar.getInstance();
c.setTime(d);
long time = c.getTimeInMillis();
long difference = time - timeStampLong;
countDownTimer.start(difference);