我有表與數據的日期。如何通過本地化獲取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