2016-11-16 144 views
0

我試圖從JSpinner的輸入中獲取一個字符串。如何從JSpinner解析爲字符串?

我怎樣才能解析輸入到字符串?

我想:

JSpinner jSpinner = (JSpinner) e.getSource(); 
    dates = (Date) jSpinner.getValue(); 
    DateFormat df = new SimpleDateFormat("HH:mm dd-MM-yyyy"); 
    ta2.setText(df.parse((String)jSpinner.getValue())); 
    // or this, which works but it throws an exception because of date. 
    ta2.setText((String)jSpinner.getValue()); 

回答

0

它在某種程度上簡單,現在它的工作原理。

我說:

String nt = df.format(dates);