Q:

converting UTC date string to local date string inspecific format

I have a UTC date in string
String utcDate = "2014-03-05 07:09:07.0";

I want to convert it to local date string of format DD-MMM-YYYY hh:mm a
eg: 5-Mar-2014 12:39 PM from UTC date 2014-03-05 07:09:07.0
How this can be achieved using simple java or joda API

A:

Very easy to achieve with default functionality. I hope the local data is for display only.
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
parser.setTimeZone(TimeZone.getTimeZone("UTC"));
Date parsed = parser.parse(utcDate);

SimpleDateFormat formatter = new SimpleDateFormat("d-MMM-yyyy hh:mm a");
System.out.println(formatter.format(parsed));

