get datetime with AM or PM in java -


i have date in string format(yyyy-mm-dd hh:mm:ss). same date am/pm alongwith datetime.

e.g:

input string --> 2013-03-12 13:23:30,

ouput-->2013-03-12 01:23:30 am/pm.

do have util class get.

use string format yyyy-mm-dd hh:mm:ss a

a marker am/pm marker: http://docs.oracle.com/javase/6/docs/api/java/text/simpledateformat.html

date date = new date(); simpledateformat sdf = new simpledateformat("yyyy-mm-dd h:mm:ss a"); string formattedtime = sdf.format(date); system.out.println(formattedtime); 

or

public static string convertdate(date date) {     simpledateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss a",             locale.english);     return df.format(date); } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -