0

I am using the Swingx JXDatePicker to enable date selection in a java application with NEtBeans.

I just need the date but anytime the date is selected from the calender button, I get the date and time formatted together in this form : Sat Apr 13 00:00:00 BST 2013

however , I just want to have the date and not the time.

that is in a form like : Sat Apr 13 2013 or any other form without the time included

Is there a way to trim the default format to have just the date.

thank you all.

faisal abdulai
  • 3,739
  • 8
  • 44
  • 66
  • How about [`JCalendar`](https://max-server.myftp.org/trac/jcalendar)? Recently, I used it and it was good. – Eng.Fouad Feb 27 '13 at 10:28
  • You try taking a look at [`JXDateField.setFormats(DateFormat...)`](http://www.jarvana.com/jarvana/view/org/swinglabs/swingx-core/1.6.2/swingx-core-1.6.2-javadoc.jar!/org/jdesktop/swingx/JXDatePicker.html#setFormats%28java.text.DateFormat...%29) – MadProgrammer Feb 27 '13 at 10:37
  • I will look at both suggestions and get back later – faisal abdulai Feb 27 '13 at 11:46
  • hmm, showing only the formatted date is default - maybe a problem with your Locale, which is it? – kleopatra Feb 28 '13 at 12:45

1 Answers1

-1

You can try this:

DateFormat df = DateFormat.getDateInstance();
String fromdate = df.format(txt_fromdate.getDate());
tima
  • 1,498
  • 4
  • 20
  • 28
  • 1
    Welcome to Stack Overflow! You answer could use a little formatting, and more text for OP to understand and not only copy paste. I'd suggest you take the [tour](/tour), and read [how to answer](/help/how-to-answer). Then you'll be able to come back and edit your answer – Ulysse BN Aug 01 '17 at 17:03