I am trying to convert a string "8/2/2018 04:25 AM"
into a date object
but it seems to be converting it wrong making it output a completely wrong date
and time
when I do a date.toString()
. Note - I do not care about the date.toString()
format, I just need it to be the same date and time
Here is my code,
String timestampString = dateText.getText().toString() + " " + timeText.getText().toString();
try {
Date timestamp2 = new SimpleDateFormat("dd/MM/yyyy hh:mm a").parse(timestampString);
Log.d("TIME", timestamp2.toString());
} catch (ParseException e) {Log.d("TAG", e)}
Here is the output:
D/TIME: Wed Feb 07 23:25:00 EST 2018
if anyone could lead me in the right direction, it is greatly appreciated.