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; }
@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; } }
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); } }
@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); } }
@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()); } }
public void postCheck(HashMap<String, String>[] maps) { final PostCheckWidget pcw = this; if (Util.getProgramMode() == ProgramMode.STUBBED) { } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // String[] params = { "" + payerWidget.getStoredValue(), // JsonUtil.jsonify(tbCheckNo.getText()), // JsonUtil.jsonify(maps) }; String[] params = { "", JsonUtil.jsonify(tbCheckNo.getText()), JsonUtil.jsonify(maps) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.ClaimLog.post_check", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { pcw.removeFromParent(); callback.jsonifiedData("update"); } else { } } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
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; }