我有表与数据的日期。如何通过本地化获取java中的数据?
这是我calcaulted日期
DateFormat dateFormat = getFormat();
date = dateFormat.parse((String) value).getTime();
if(date != null) {
cell.setValue(dateFormat.format(date));
tableViewer.update(element, null);
}
public static DateFormat getFormat() {
String systemLocale = System.getProperty("user.language"); //$NON-NLS-1$
Locale locale = new Locale(systemLocale);
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
return dateFormat;
}
的日期是存在于屏幕格式月日(该月的名称),一年
for example Apr 26,2014.
现在我想要得到的单元格的值并得到格式'yyyy-mm-dd' 该日期的值是2014年4月26日。 我如何得到2014-04-26的结果?我也认为,在UI的价值可能会改变根据用户的本地化
我试图
DateFormat dateFormat = getFormat();
Date parse = dateFormat.parse((String) key);
但随后get方法已过时,也没得到了getYear正确的结果
我不是专家的日期也许我错过了什么
,可以储存在电池中的java.util.Date对象和[设置自定义渲染器绘制(http://docs.oracle.com/javase/tutorial/uiswing/components /table.html#renderer)以需要的(用户)格式。这样你就不必将字符串解析回日期。 – SebastianH
我需要它在不同的格式,然后在用户界面。 – user1365697
我需要它在一般,而不是表 – user1365697