DatePicker: pattern messed with LocalDateTime and showTime="true"
See original GitHub issue1) Environment
- PrimeFaces version: trunk
- Application server + version: jetty 9.20
- Affected browsers: all
2) Expected behavior
The user-provided pattern is not modified.
3) Actual behavior
HH:mm is added to the pattern, causing conversion errors.
4) Steps to reproduce
…
5) Sample XHTML
<h:form>
<div>
<p:outputLabel for="date1" value="Date1" style="display: inline-block; width: 120px;"/>
<p:datePicker id="date1" value="#{testViewCdi.date1}" showTime="true"/>
<p:message for="date1"/>
</div>
<div>
<p:outputLabel for="date2" value="Date2" style="display: inline-block; width: 120px;"/>
<p:datePicker id="date2" value="#{testViewCdi.date2}" showTime="true" pattern="dd/MM/yy HH:mm"/>
<p:message for="date2"/>
</div>
<div>
<p:outputLabel for="date3" value="Date3" style="display: inline-block; width: 120px;"/>
<p:datePicker id="date3" value="#{testViewCdi.date3}"/>
<p:message for="date3"/>
</div>
<div>
<p:outputLabel for="date4" value="Date4" style="display: inline-block; width: 120px;"/>
<p:datePicker id="date4" value="#{testViewCdi.date4}" pattern="dd/MM/yy"/>
<p:message for="date4"/>
</div>
<p:commandButton id="sub" value="submit" update="@form"/>
</h:form>
6) Sample bean
@Named
@ViewScoped
public class TestViewCdi implements java.io.Serializable {
private java.time.LocalDateTime date1 = java.time.LocalDateTime.now();
private java.time.LocalDateTime date2 = java.time.LocalDateTime.now();
private java.time.LocalDateTime date3 = java.time.LocalDateTime.now();
private java.time.LocalDateTime date4 = java.time.LocalDateTime.now();
// getters and setters
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Problem with passing LocalDateTime data using Kendo api ...
I'm using a kendo date picker in a jsp binded form (using spring + ... STRING) private Cause cause; @DateTimeFormat(pattern="MM.dd.yyyy ...
Read more >Unable to input 12 hour format LocalDateTime in calendar o ...
I'm having some issues with calendar on capturing LocalDateTime in twelve hour format like this: <p:calendar id="popupCalendar" ...
Read more >Datetime advance format in datepicker - OutSystems
Hi. I want to enable time in date picker control.but show time option is not available there.i saw the outsystems documentation.advanced format one...
Read more >DatePicker (JavaFX 8) - Oracle Help Center
public class DatePicker extends ComboBoxBase<LocalDate> ... setConverter(new StringConverter<LocalDate>() { String pattern = "yyyy-MM-dd"; DateTimeFormatter ...
Read more ><input type="datetime-local"> - HTML - MDN Web Docs
The format of the date and time value used by this input type is ... and dates outside June can't be scrolled to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
IMHO the easiest and best solution is the server-side only:
PR: #5313