I have string form of date:
2011-03-27T09:39:01.607
and I want to format it to March 27, 2011
I am using
DateFormat[] formats = new DateFormat[] {
DateFormat.getDateInstance(), DateFormat.getDateTimeInstance(),
DateFormat.getTimeInstance(), };
String actDate= formats[0].format(uploadeddate.substring(0,9));
but its not working.
How do I convert to March 27, 2011
?
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy hh:mm a"); String date = formatter. format(Date. parse("Your date string")); Hope it will help you.
DateFormat. format("yyyy-MM-dd hh:mm:ss a", new java.
try this
SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
java.util.Date date = null;
try
{
date = form.parse("2011-03-27T09:39:01.607");
}
catch (ParseException e)
{
e.printStackTrace();
}
SimpleDateFormat postFormater = new SimpleDateFormat("MMMMM dd, yyyy");
String newDateStr = postFormater.format(date);
now newDateStr = March 27, 2011;
String dateimput = "2011-03-27T09:39:01.607"
SimpleDateFormat formatrecived = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
SimpleDateFormat formarwanted = new SimpleDateFormat("MMMM dd, yyyy");
Date recived = formatrecived.parse(dateimput);
Date output = formatwanted.format(recived);
Note: dateimput you need to format to yyyy-MM-dd hh:mm:ss
using replace and substring
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