Java 类javafx.util.converter.LocalDateStringConverter 实例源码

项目:waterrower-workout    文件:DateTimeFormatter.java   
/**
 * Formatter for dates and times.
 *
 * @param locale The locale, must not be null.
 */
public DateTimeFormatter(Locale locale) {
    requireNonNull(locale);
    this.prettyTime = new PrettyTime(locale);
    this.shortTimeFormat = new LocalTimeStringConverter(SHORT, locale); // getTimeInstance(SHORT, locale);
    this.mediumDateFormat = new LocalDateStringConverter(MEDIUM, locale, null); // getDateInstance(MEDIUM, locale);
}
项目:roda-in    文件:InspectionPane.java   
private DatePicker createFormDatePicker(TemplateFieldValue metadataValue) {
  DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Constants.DATE_FORMAT_4);
  LocalDateStringConverter ldsc = new LocalDateStringConverter(formatter, null);

  String currentValue = metadataValue.get("value") != null ? (String) metadataValue.get("value") : "";

  LocalDate date = null;
  try {
    date = ldsc.fromString(currentValue);
  } catch (DateTimeParseException e) {
    // maybe because of {{mixed}}
  }
  DatePicker datePicker = new DatePicker(date);
  datePicker.setMaxWidth(Double.MAX_VALUE);
  datePicker.setConverter(new StringConverter<LocalDate>() {
    private DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(Constants.DATE_FORMAT_4);

    @Override
    public String toString(LocalDate localDate) {
      if (localDate == null)
        return "";
      return dateTimeFormatter.format(localDate);
    }

    @Override
    public LocalDate fromString(String dateString) {
      if (dateString == null || dateString.trim().isEmpty())
        return null;
      return LocalDate.parse(dateString, dateTimeFormatter);
    }
  });
  datePicker.valueProperty()
    .addListener((observable, oldValue, newValue) -> metadataValue.set("value", ldsc.toString(newValue)));
  addListenersToUpdateUI(metadataValue, datePicker.valueProperty());
  return datePicker;
}
项目:myWMS    文件:OrderStatusPane.java   
@SuppressWarnings("unchecked")
public DetailsPane() {
    ProgressIndicatorBar progress = new ProgressIndicatorBar();
    progress.progressProperty().bind(MBindings.get(order, this::getOrderProgress));

    picksView.setItems(pick);
    unitLoadsView.setItems(unitLoads);
    goodsOutView.setItems(goodsOut);

    unitLoadsView.setCellFactory(
            CellWrappers.forList(PluginRegistry.getPlugin(LOSPickingUnitLoad.class, Editor.class).createTOCellFactory()));
    picksView.setCellFactory(
            CellWrappers.forList(PluginRegistry.getPlugin(LOSPickingOrder.class, Editor.class).createTOCellFactory()));
    goodsOutView.setCellFactory(
            CellWrappers.forList(PluginRegistry.getPlugin(LOSGoodsOutRequestPosition.class, Editor.class).createTOCellFactory()));

    TitledPane picksTP = new TitledPane("Picks", picksView);
    TitledPane unitloadsTP = new TitledPane("Unit loads", unitLoadsView);
    TitledPane goodsOutTP = new TitledPane("Goods out positions", goodsOutView);

    Bindings.bindBidirectional(picksTP.expandedProperty(), unitloadsTP.expandedProperty());
    Bindings.bindBidirectional(picksTP.expandedProperty(), goodsOutTP.expandedProperty());

    SimpleFormBuilder form = new SimpleFormBuilder();
    form.row()
    .label("Number")
    .field(MBindings.get(order, LOSCustomerOrder::getNumber))
    .label("Pick Time")
    .field(Bindings.createStringBinding(this::pickTimeFormat, pickTime, timeToGo))
    .label("Last Pick")
    .field(MBindings.get(lastPick, LOSPickingPosition::getPickFromLocationName))
.end();
    form.row()
    .label("External Number")
    .field(MBindings.get(order, LOSCustomerOrder::getExternalNumber))
    .label("Mins/Pick")
    .field(Bindings.createStringBinding(this::pickRateFormat, minsPerPick))
    .label("Destination")
    .field(Bindings.selectString(order, "destination", "name"))
.end();
    form.row()
    .label("Progress")
    .fieldNode(progress)
    .label("To pick")
    .field(Bindings.createStringBinding(this::pickQtyFormat, pickedCount))
    .label("Delivery")
    .boundField(new LocalDateStringConverter(), MBindings.get(order, o -> DateUtils.toLocalDate(o.getDelivery())))
.end();
form.row()
.fieldNode(picksTP).colSpan(2)
.fieldNode(unitloadsTP).colSpan(2)
.fieldNode(goodsOutTP).colSpan(2)
.end();

    setCenter(form);

    orderTO.addListener(this::selectionChanged);
}