I have this code to convert a string to a date. but the resulting date is always in another format.
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm");
try {
String dateString = "18/01/2013 11:59";
dateTest = format.parse(dateString);
System.out.println(dateTest); //output: Tue Jan 18 11:59:00 GMT 2013
}
How can I make it so that dateTest is in the same format as the original?
This
will do the job. You can use the
format()method of yourSimpleDateFormatto format the output the same way your input should be.