Results 1 to 2 of 2

Thread: jDatePicker ???

  1. #1
    Join Date
    Oct 2009
    Rep Power

    Default jDatePicker ??? m i supposed to use jdatepicker component to store in sql table? how to retrieve it from the form?

    what is myDate variable here for?? m assuming datePicker to be datepicker = new net.sourceforge.jdatepicker.JDatePicker(); i hope this is it??
    Java Code:
    java.sql.Date sqlDate = myDate;
    java.util.Date date = convertSqlDateToUtilDate(sqlDate);
    java.util.Date date = datePicker.getSelectedDate();
    java.sql.Date sqlDate = convertUtilDateToSqlDate(date);
    private java.util.Date convertSqlDateToUtilDate(java.sql.Date sqlDate) {
      java.util.Date date = null;
      if (sqlDate != null) {
        date = new java.util.Date(sqlDate.getTime());
      return date;
    private java.sql.Date convertUtilDateToSqlDate(java.util.Date date) {
      java.sql.Date sqlDate = null;
      if (date != null) {
        sqlDate = new java.sql.Date(date.getTime());
      return sqlDate;
    plz help!!!

  2. #2
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Pittsburgh, PA
    Rep Power


    The code in your note shows
    how to convert between two date formats.
    There is no way to know what datePicker is.

    If you want to use net.sourceforge.jdatepicker.JDatePicker(),
    download it and take a look at the code.
    It looks like getCalendarClone() fetches from the JDatePicker
    its currently picked date as a Calendar object.
    To get a Date object use getCalendarClone().getDate();
    Once you have the Date, you can use the code noted in your post
    to format it for sql.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts