当前位置: 技术问答>java相关
怎么把时间转成这种格式-------- 3/8/2002 12:05:00 AM
来源: 互联网 发布时间:2015-08-06
本文导语: rt! | java.text.SimpleDateFormat SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa"); try { String str = sdf.format(new Date()); }catch(Exception e){} | public String getdate_A() throws E...
rt!
|
java.text.SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
try
{
String str = sdf.format(new Date());
}catch(Exception e){}
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
try
{
String str = sdf.format(new Date());
}catch(Exception e){}
|
public String getdate_A() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
Calendar MyDate = Calendar.getInstance();
MyDate.setTime(new java.util.Date());
String adddate=df.format(MyDate.getTime());
return adddate;
}
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
Calendar MyDate = Calendar.getInstance();
MyDate.setTime(new java.util.Date());
String adddate=df.format(MyDate.getTime());
return adddate;
}