80,351
社区成员
发帖
与我相关
我的任务
分享
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dateformat);
String newdate = FormatDate("2015-02-6");
System.out.println(newdate);
}
public String FormatDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = format.parse(str);
} catch (Exception e) {
e.printStackTrace();
}
date = java.sql.Date.valueOf(str);
String newdate = format.format(date);
return newdate;
}