我写了下面的代码
Date d = new Date();
CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime());
但是正在询问我的参数,我想要字符串格式的当前日期,
喜欢
28-Dec-2011
这样我就可以控制TextView
了,
解释一下,如果你认为有些事情是必要的,我是Android开发的新手。
发布于 2011-12-28 19:04:36
这与android无关,因为它是基于java的,所以您可以使用
private String getDateTime() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
return dateFormat.format(date);
}
发布于 2011-12-28 19:23:08
public String giveDate() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d, yyyy");
return sdf.format(cal.getTime());
}
发布于 2011-12-28 19:03:52
尝尝这个,
SimpleDateFormat timeStampFormat = new SimpleDateFormat("yyyyMMddHHmmssSS");
Date myDate = new Date();
String filename = timeStampFormat.format(myDate);
https://stackoverflow.com/questions/8654990
复制相似问题