Hello again,

This time, I want to create a simple function where you choose a date with JSpinner, and next to it, I want a textfield where you can enter the time.
I've already created a JSpinner with both date and time, but it kind of looks bad, but that's my opinion. Also, whenever I run my app, it gives me my local time, and date, which is very nice, but kind of "bad".

I want to register some movies, and I want to select a date for it, and insert the time by myself. It's kinda "hard" to scroll it with the JSpinner.

I tried this out, and I did it. But the thing is, I've got some other classes which requires the date in this format:
"YYYY-mm-dd HH-mm-ss" - I can do this with my spinner

But when I try:

dateSpinner.getValue().toString() + " " + timeField.getText(); 

Where
timeField.getText() = 20:00:00

My output becomes:
2012-05-04 00:00:00 CET 20:00:00.

This isn't the format that I want. I've tried using SimpleDateFormat, but the thing is that I can't get my JSpinner output to be "YYYY-mm-DD".

How can I do this? How can I get my JSpinner Output to be "YYYY-mm-DD"?

Right now, this is how I've created my dateSpinner.

datoSpinner = new JSpinner(new SpinnerDateModel());
        datoSpinner.setEditor(new DateEditor(datoSpinner, "yyyy-MM-dd HH:mm:ss"));

Also, one more question. How can I set a limit to my JSpinner? I don't want my Jspinner to go under today, this times limit.
For example, if I open my JSpinner, and it's 2012-05-04 22:44:13,
I don't want it to go lower than 2012-05-04 22:44:13.

Thanks!

jDateChooser which comes with jCalendar is the best component for date: Following is the way to get date from date picker:

//dat is name given to datepicker component
int day=dat.getJCalendar().getDayChooser().getDay();
int month=dat.getJCalendar().getMonthChooser().getMonth();
int year=dat.getJCalendar().getYearChooser().getYear();
String dateNow=year+"/"+month+"/"+day;
System.out.println(dateNow);

//***************************************************
//For setting date of date picker:
dat.setDateFormatString("dd-MM-yyyy");
Calendar currentDate = Calendar.getInstance();
dat.setDate(currentDate.getTime());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.