change value of a timestamp format into other timestamp format?

Hi can anyone tell me how can i change a given timestamp format into other timestamp format like

DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Calendar d1 = Calendar.getInstance();
d1.setTime(formatter.parse("2012-03-08 17:32:56"));

to

"dd-MMM-yyyy HH:mm:ss"

format

Answers


format the date with new date format dd-MMM-yyyy HH:mm:ss

   DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Date oldFormatedDate = formatter.parse("2012-03-08 17:32:56");
   System.out.println(new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss").
   format(oldFormatedDate));

Continue with DateFormat#format(Date):

SimpleDateFormatter newFormat = new SimpleDateFormatter("dd-MMM-yyyy HH:mm:ss");
String newFormattedDate = newFormat.format(d1);

Need Your Help

What is the easiest way to display an editable Dictionary?

c# winforms dictionary

I've got a Dictionary<string, string> and would like to have the user to see and edit the content, possibly adding new entries. How should I do that?

Create a Dictionary <string, list<string> or something similar from a json object list in c#

c# json linq list dictionary

Hey how can you turn json obects into a dictionary or something like that?