I have been developing Android application where I use this code:
Date d=new Date(new Date().getTime()+28800000); String s=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(d);
I need to get date after 8 hours from current moment, and I want that this date has 24-hours format, but I don't know how I can make it by SimpleDateFormat. I also need that date has DD/MM/YYYY HH:MM:SS
format.
The pattern dd/MM/yyyy hh:mm:ss aa is used for the 12 hour format and the pattern MM-dd-yyyy HH:mm:ss is used for the 24 hour format.
SimpleDateFormat(“hh:mm:ss a”) in Java.
for 12-hours format:
SimpleDateFormat simpleDateFormatArrivals = new SimpleDateFormat("hh:mm", Locale.UK);
for 24-hours format:
SimpleDateFormat simpleDateFormatArrivals = new SimpleDateFormat("HH:mm", Locale.UK);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With