I have a Date in
String format -'15-03-2011 15:27:53' .
When i parse this, using the Dateformat, am getting the output as 'Tue Mar 15 15:27:53 IST 2011'
But,I want the date in the same format 'dd/MM/YYYY hh:mm:ss' ('15-03-2011 15:27:53')
IS there any way, I can do this..
Here is my code :
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
long now = System.currentTimeMillis();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(now);
System.out.println("now: "+ formatter.format(calendar.getTime()));
Date date = (Date)formatter.parse(formatter.format(calendar.getTime()));
System.out.println("Date:" + date);
Output:
now : 15-03-2011 15:27:53
Date:Tue Mar 15 15:27:53 IST 2011