代码如下:
String d = "2005-4-28";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try{
Date date = format.parse(d);
SimpleDateFormat ff = new SimpleDateFormat("MMM dd, yyyy");
StringBuffer x = ff.format(date,new StringBuffer(),new FieldPosition(0));
System.out.println(x.toString());
}catch(ParseException e){
System.out.print("e:"+e.toString());
}
输出结果:四月 28, 2005
但我想要的结果是April 28, 2005.
输出的月份变成了中文,但我想要英文,造成这样的结果是不是当前操作系统是中文版呢?应如何解决呢?
String d = "2005-4-28";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try{
Date date = format.parse(d);
SimpleDateFormat ff = new SimpleDateFormat("MMM dd, yyyy");
StringBuffer x = ff.format(date,new StringBuffer(),new FieldPosition(0));
System.out.println(x.toString());
}catch(ParseException e){
System.out.print("e:"+e.toString());
}
输出结果:四月 28, 2005
但我想要的结果是April 28, 2005.
输出的月份变成了中文,但我想要英文,造成这样的结果是不是当前操作系统是中文版呢?应如何解决呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货