This project is fork of DatePicker component for Vaadin Flow. On top of basic functionality of DatePicker, it has ability to format date by pattern. Formatting is done by JavaScript library date-fns v2.0.0-beta.2. More information about supported formatting paterns can be found here: https://date-fns.org/v2.0.0-beta.2/docs/format
Formatting pattern can be set using method setPattern(String formattingPattern)
. For example:
EnhancedDatePicker datePicker;
datePicker.setPattern("dd-MMM-yyyy");
or by using constructor: new EnhancedDatePicker(LocalDate.now(), "dd-MMM-yyyy");
Patterns used for parsing user's input can be set using method setParsers(String ... parserPatterns)
. For example:
EnhancedDatePicker datePicker;
datePicker.setParsers("dd-MM-yy", "dd/MM/yy", "dd/MM/yyyy");
or by using constructor: new EnhancedDatePicker(LocalDate.now(), "dd-MMM-yyyy", "dd-MM-yy", "dd/MM/yy", "dd/MM/yyyy");
This component can be used in combination with <vaadin-date-picker>
.
In HTML/JS template you can add <vaadin-date-picker id="datePickerId"></vaadin-date-picker>
and in Java side, you can bind it to EnhancedDatePicker
like this:
@Id("datePickerId")
private EnhancedDatePicker datePicker;
NOTE: Localization in this component is also done by DateFns and some locales for some patterns are not stable:
for example Russian and French for pattern MMM
(it adds '.' in the end of month and then it can not parse it back)
This component is part of Vaadin Component Factory
Run from the command line:
mvn -pl enhanced-date-picker-demo -Pwar install jetty:run
Then navigate to http://localhost:8080/enhanced-date-picker
For running integration tests demos execute one of the following lines depending on the desired mode
mvn -pl enhanced-date-picker-integration-tests clean jetty:run
mvn -pl enhanced-date-picker-integration-tests clean jetty:run -Dvaadin.bowerMode
Then navigate to http://localhost:9998/
for see integration tests demos.
For running all integration tests execute
mvn clean install verify
Run from the command line:
mvn clean install -DskipTests
To use the component in an application using maven,
add the following dependency to your pom.xml
:
<dependency>
<groupId>com.vaadin.componentfactory</groupId>
<artifactId>enhanced-date-picker</artifactId>
<version>${component.version}</version>
</dependency>
Documentation for flow can be found in Flow documentation.
- Use the coding conventions from Flow coding conventions
- Submit a pull request with detailed title and description
- Wait for response from one of Vaadin Flow team members
Apache Licence 2