java - JDatePicker date formatting -


i got jdatepicker working, in application, want date formatted yyyy_mm_dd
date's format default wed jul 08 15:17:01 adt 2015
guide there's class formats date follows.

package net.codejava.swing;  import java.text.parseexception; import java.text.simpledateformat; import java.util.calendar;  import javax.swing.jformattedtextfield.abstractformatter;  public class datelabelformatter extends abstractformatter {      private string datepattern = "yyyy-mm-dd";     private simpledateformat dateformatter = new simpledateformat(datepattern);      @override     public object stringtovalue(string text) throws parseexception {         return dateformatter.parseobject(text);     }      @override     public string valuetostring(object value) throws parseexception {         if (value != null) {             calendar cal = (calendar) value;             return dateformatter.format(cal.gettime());         }          return "";     }  } 

so added class package , swing application has proper constructor

jdatepickerimpl datepicker = new jdatepickerimpl(datepanel, new datelabelformatter()); 

so everytime call datepicker.getmodel().getvalue().tostring() formatting original.
see datelabelformatter calls valuetostring, method doesn't seem available in application class.
need extend application class?
calling wrong methods information?
they're in default package [not good?] causing problems ?
complete noob appreciated :)

http://www.codejava.net/java-se/swing/how-to-use-jdatepicker-to-display-calendar-component

here might resource can help

i believe might need call

datepicker.getjformattedtextfield().gettext() 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -