Skip to main content

JXDatePicker.setFormats + DatePickerBinding + JXTable

No replies
yael800
Offline
Joined: 2006-09-27

Hi,
I have a problem with that topic.

String[] dateStr = new String[] { "dd/MM/yyyy" };
mtJXDatePicker.setFormats();

Then the user can see this (MM/dd/yyyy) format in JXDatePicker, untill now it's good for me.
I have JSpinner for time select.
I want to get: MM/dd/yyyy HH:mm (from JXDatePicker and JSpinner together)
The problem is to enable user to update date column from jxtable (column Date class type) with the DatePickerBinding :

The dateBinding know to read only date type.
If I print this, I get the result us I wanted but it is in String type:
System.out.println(df.format(dateDestination.getDate()) +" "+ spinner.getTime())

so I need to convert it to Date type:
Date newDate;
try {
newDate = df.parse(df.format(dateDestination.getDate()) +" "+ spinner.getTime());
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

sometimes I get error:
java.lang.NullPointerException
at java.util.Calendar.setTime(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)

And if it's succeed, in the corresponding cell the date and time result look like this for 11/02/2006 12:00:
Thu Nov 02 00:00:00 GMT + 02:00 2006

Only after the next running, I get in JXTable what I wanted: 11/02/2006 12:00:00.0
MySql is dateTime type, so it is arrange oneself from the database.
I'm hope that someone culd help me with that.
Thanking you in anticipation :)
Yael