Pregunta

I have a date and time value in String type.

String dateTime = "2012-10-27 19:00:00.000";

And I have a JSpinner named spnDateTime with Spinner Model Type as Date.

What I need to do is get the String variable's value and set to the spinner's date and time .

I'm new to JAVA and this is what I tried to do.

spnDateTime.setValue(dateTime);
¿Fue útil?

Solución

You can use a SimpleDateFrmat to parse the String to a Date value

Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS").parse(daetTime);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top