Question

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);
Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top