Esempio n. 1
0
 public String getStoredValue() {
   String storedValue = null;
   try {
     JsonUtil.debug(
         "CustomDatePicker.getStoredValue: " + getValue() != null
             ? dateFormat.format(getValue())
             : null);
     storedValue = dateFormat.format(getValue());
   } catch (Exception e) {
     JsonUtil.debug("CustomDatePicker.getStoredValue:" + e.getMessage());
   }
   return storedValue;
 }
Esempio n. 2
0
 @Override
 public Date parse(DateBox dateBox, String text, boolean reportError) {
   // Try default parser
   DateBox.Format f = new DateBox.DefaultFormat();
   Date p = importSqlDate(text); // f.parse(dateBox, text, false);
   if (p == null) {
     JsonUtil.debug("CustomDatePicker.parse: " + importSqlDate(text));
     return f.parse(dateBox, text, false); // importSqlDate(text);
   } else {
     JsonUtil.debug("CustomDatePicker.parse: " + p);
     return p;
   }
 }
Esempio n. 3
0
 public void setValue(String s, boolean fireEvent) {
   if (s == null || s.equalsIgnoreCase("") /*|| s.equalsIgnoreCase("0000-00-00")*/) {
     setValue(new Date(), fireEvent);
   } else {
     Date dt = importSqlDate(s);
     JsonUtil.debug("CustomDatePicker.setValue: " + dt);
     setValue(dt, fireEvent);
   }
 }
Esempio n. 4
0
 @Override
 public String format(DateBox dateBox, Date date) {
   try {
     return dateFormat.format(date);
   } catch (Exception ex) {
     JsonUtil.debug("CustomDatePicker.format: " + ex.toString());
     return new DateBox.DefaultFormat().format(dateBox, date);
   }
 }
Esempio n. 5
0
 @Override
 public void reset(DateBox dateBox, boolean abandon) {
   // Just do whatever the superclass would do
   try {
     DateBox.Format f = new DateBox.DefaultFormat();
     f.reset(dateBox, abandon);
   } catch (Exception ex) {
     JsonUtil.debug("CustomDatePicker.reset: " + ex.toString());
   }
 }
Esempio n. 6
0
 public Date importSqlDate(String date) {
   if (date == null) {
     return null; // new Date();
   } else if (date.equalsIgnoreCase("")
       || date.equalsIgnoreCase("0000-00-00")
       || date.equalsIgnoreCase("0000-00-00 00:00:00")) {
     return null; // new Date();
   } else if (date.indexOf("-") != -1) {
     Calendar calendar = new GregorianCalendar();
     calendar.set(Calendar.YEAR, Integer.parseInt(date.substring(0, 4)));
     calendar.set(Calendar.MONTH, Integer.parseInt(date.substring(5, 7)) - 1);
     calendar.set(Calendar.DATE, Integer.parseInt(date.substring(8, 10)));
     /*
     calendar.set(Calendar.HOUR, 0);
     calendar.set(Calendar.MINUTE, 0);
     calendar.set(Calendar.SECOND, 0);
     calendar.set(Calendar.MILLISECOND, 0);
     */
     JsonUtil.debug("CustomDatePicker.importSqlDate: " + new Date(calendar.getTime().getTime()));
     return new Date(calendar.getTime().getTime());
   } else return null;
 }