toLocaleString()
Deprecated. As of JDK version 1.1, replaced by DateFormat.format(Date date).
toString()
Converts this Date object to a String of the form: dow mon dd hh:mm:ss zzz yyyy where: dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
Deprecated. As of JDK version 1.1, replaced by DateFormat.format(Date date).
toString()
Converts this Date object to a String of the form: dow mon dd hh:mm:ss zzz yyyy where: dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
用下面的程序来代替
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINA);
df.format(new Date());
而toString()则是相当于将日期格式设置为美国的长日期格式相当于
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.USA);
为一个使用本地时区表示的字符串。toLocalString()方法也将日期转换为
一个使用本地时区表示的字符串,但字符串的格式稍有不同。