Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Mask (MM/dd/yyy) in JTable cell  RSS feed

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends
How can I add a Date Mask (MM/dd/yyyy) in a JTable cell.
Thanks
Sri
 
Chris Stehno
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will want to create a custom table cell renderer that displays the date object as a formatted string (using SimpleDateFormat).
Or... you could convert the date to its formatted string representation before adding to the table data, but this should only be done if you will not need that data again (only for show).
Hope this helps.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you need the mask for editing the table, you might have to implement your own cell editor extending JFormattedField.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!