package com.taocares.naoms.client.model.common.custom.control;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import javafx.beans.NamedArg;
import javafx.beans.property.LongProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.SpinnerValueFactory;
import javafx.util.StringConverter;
public class LocalDateTimeSpinnerValueFactory extends SpinnerValueFactory{
/**
* Creates a new instance of the LocalDateSpinnerValueFactory, using the
* value returned by calling {@code LocalDate#now()} as the initial value,
* and using a stepping amount of one day.
*/
public LocalDateTimeSpinnerValueFactory() {
this(LocalDateTime.now());
}
/**
* Creates a new instance of the LocalDateSpinnerValueFactory, using the
* provided initial value, and a stepping amount of one day.
*
* @param initialValue The value of the Spinner when first instantiated.
*/
public LocalDateTimeSpinnerValueFactory(@NamedArg("initialValue") LocalDateTime initialValue) {
this(LocalDateTime.MIN, LocalDateTime.MAX, initialValue);
}
/**
* Creates a new instance of the LocalDateSpinnerValueFactory, using the
* provided initial value, and a stepping amount of one day.
*
* @param min The minimum allowed double value for the Spinner.
* @param max The maximum allowed double value for the Spinner.
* @param initialValue The value of the Spinner when first instantiated.
*/
public LocalDateTimeSpinnerValueFactory(@NamedArg("min") LocalDateTime min,
@NamedArg("min") LocalDateTime max,
@NamedArg("initialValue") LocalDateTime initialValue) {
this(min, max, initialValue, 1, ChronoUnit.DAYS,"yyyy-MM-dd HH:mm:ss");
}
/**
* Creates a new instance of the LocalDateSpinnerValueFactory, using the
* provided min, max, and initial values, as well as the amount to step
* by and {@link java.time.temporal.TemporalUnit}.
*
* <p>To better understand, here are a few examples:
*
* <ul>
* <li><strong>To step by one day from today: </strong> {@code new LocalDateSpinnerValueFactory(LocalDate.MIN, LocalDate.MAX, LocalDate.now(), 1, ChronoUnit.DAYS)}</li>
* <li><strong>To step by one month from today: </strong> {@code new LocalDateSpinnerValueFactory(LocalDate.MIN, LocalDate.MAX, LocalDate.now(), 1, ChronoUnit.MONTHS)}</li>
* <li><strong>To step by one year from today: </strong> {@code new LocalDateSpinnerValueFactory(LocalDate.MIN, LocalDate.MAX, LocalDate.now(), 1, ChronoUnit.YEARS)}</li>
* </ul>
*
* @param min The minimum allowed double value for the Spinner.
* @param max The maximum allowed double value for the Spinner.
* @param initialValue The value of the Spinner when first instantiated.
* @param amountToStepBy The amount to increment or decrement by, per step.
* @param temporalUnit The size of each step (e.g. day, week, month, year, etc)
*/
public LocalDateTimeSpinnerValueFactory(@NamedArg("min") LocalDateTime min,
@NamedArg("min") LocalDateTime max,
@NamedArg("initialValue") LocalDateTime initialValue,
@NamedArg("amountToStepBy") long amountToStepBy,
@Na