2016-11-16 140 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);