Below is how I set up my JFormattedTExtField.
The database (derby) will take the format no prob.

The db will then change the form to yyyy-MM-dd

If I follow that format from begining to end the JFormatted Field
will be fine.

However, when a date is queried from the database and put back to

the field nothing shows becaue the formats are now different.

so it goes in fine the way I set it up.but I need it to output it
in a format I am comforable with MM/dd/yyyy.

is there a way to do this?

CLASS 
public class FormattedDateField  extends JFormattedTextField implements ActionListener, Serializable{: 
 -->public FormattedDateField(Wed May 11 06:00:04 CDT 2011) var: ((Date date))<-- 
 : : caller 
--> : DefaultFormatterFactory() : var: xxxx : xxxxxxx <-- 

 --> in  public FormattedDateField() var: xxxxxxxxx : xxxxxxxx<-- 

CLASS 
public class FormattedDateField  extends JFormattedTextField implements ActionListener, Serializable{: 
 --> in  public FormattedDateField() var: xxxxxxxxx : xxxxxxxx<-- 
 : ##-##-####: MASKFORMAT: 

CLASS 
public class FormattedDateField  extends JFormattedTextField implements ActionListener, Serializable{: 
 --> in  public FormattedDateField() var: xxxxxxxxx : xxxxxxxx<-- 
 : MM-dd-yyyy: SIMPLEDATEFORMATMASK: 

 --> in public static synchronized ResourceBundle getResources() var: xxxxxxxxx : xxxxxxxx<-- 

 --> in public JFormattedTextField fieldSetup(INSTR_DOB) var: (String fieldName)<-- 

 -->public FormattedDateField(Wed May 11 06:00:04 CDT 2011) var: ((Date date))<-- 

CLASS 
public class FormattedDateField  extends JFormattedTextField implements ActionListener, Serializable{: 
 -->public FormattedDateField(Wed May 11 06:00:04 CDT 2011) var: ((Date date))<-- 
 : ##-##-####: MASKFORMAT: 

CLASS 
public class FormattedDateField  extends JFormattedTextField implements ActionListener, Serializable{: 
 -->public FormattedDateField(Wed May 11 06:00:04 CDT 2011) var: ((Date date))<-- 
 : MM-dd-yyyy: SIMPLEDATEFORMATMASK:

Recommended Answers

All 2 Replies

how you formated input/output Sql query from/to Db, because you can do that with Sql syntax quite confortly,

you have to ensure that (not basic stuff, or yes???):

- SQL syntax is same for java.util.Date (output and input)
- java.util.Date get same value from SimpleDateFormat as received
- JFormattedTextField get same format as received from SimpleDateFormat
- sometimes depends of DataType on DbSide (not mentioned if is there DATETIME, DATE or TIMESTAMPT)

EDIT :

I'm raally&totally hate Date&Time in PL or DB, but maybe not died my last brain cell, post here what you are trying to ...

I think you are right. Keep it simple. I don't know the scope of
data I will need later for calanders,forms,lists etc.
I will use 2011-05-04 because I see 2011-05-04 07:00:57 CDT every where and I may need
some of that info later. java.util.Date and calander is hard enough to learn
without changing formats. Someone should re-write it.

I installed Joda to learn some calanders but no progress yet.
thanks for your reply.

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.