This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes formatting challenge using JSpinner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "formatting challenge using JSpinner" Watch "formatting challenge using JSpinner" New topic

formatting challenge using JSpinner

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi Guys,

I have a formatting challenge that I'm trying to rectify. I'm working with a JTable and a JSpinner class. I got the working code sample from I decided I wanted to use it, but it needs some formatting issues worked out. Basically I'm trying to ensure that a Date field in JTable always displays via format "MM/dd/yyyy". I'm working with two classes which you can see below. I tried setting up a couple more methods that perform some formatting for me, but it meant changing the Date type to a String type, and well, it just messed things up. As you look at the lines of code that have been commented out, you can probably see what I was trying to do.

As it stands now, when the JTable first loads the data, it is formatted in the cell using some ugly default Date format. I want it to display always in the format "MM/dd/yyyy". When I click on the date cell the JSpinner certainly does display in the proper format dictated in the constructor of DateCellEditor. Then after editing and the cell loses focus, that ugly default date format shows up again. Could someone please show me what it is I need to do to retain the format I want for this date cell? I'm a bit lost on this one.


Darryl Burke

Joined: May 03, 2008
Posts: 5091

Concepts: Editors and Renderers

luck, db
There are no new questions, but there may be new answers.
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Thanks for the link to the tutorial. That helped.

Consider Paul's rocket mass heater.
subject: formatting challenge using JSpinner
jQuery in Action, 3rd edition