ParseException: What to do when Unparseable date is reached

Event: I got an error when using f: convertDateTime

--Environment - CentOS Linux release 7.8.2003 (Core) - Eclipse IDE for Enterprise Java Developers.Version: 2020-03 (4.15.0) - openjdk version "11.0.7" 2020-04-14 LTS - JSF 2.3.9

java.text.ParseException: Unparseable date: "sampleBean.timestamp"
    at java.base/java.text.DateFormat.parse(DateFormat.java:395)
    at javax.faces.convert.DateTimeConverter$FormatWrapper.parse(DateTimeConverter.java:489)
    at javax.faces.convert.DateTimeConverter$FormatWrapper.access$100(DateTimeConverter.java:470)
    at javax.faces.convert.DateTimeConverter.getAsObject(DateTimeConverter.java:437)
    at com.sun.faces.facelets.tag.jsf.ConverterTagHandlerDelegateImpl.applyAttachedObject(ConverterTagHandlerDelegateImpl.java:120)
    at javax.faces.view.facelets.FaceletsAttachedObjectHandler.applyAttachedObject(FaceletsAttachedObjectHandler.java:60)
    at com.sun.faces.facelets.tag.jsf.ConverterTagHandlerDelegateImpl.apply(ConverterTagHandlerDelegateImpl.java:53)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:111)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:179)
...abridgement...

Cause: I forgot to enclose the value attribute of h: outputText in # {}

  1. From f: convertDateTime (convertDateTime (JSF 2.2 View Declaration Language: JSP Variant) /convertDateTime.html)))
  2. javax.faces.convert.DateTimeConverter # getAsObject is called (DateTimeConverter | JavaServer Faces API (2.2) /index.html?javax/faces/convert/DateTimeConverter.html)))
  3. javax.faces.convert.DateTimeConverter.FormatWrapper # parse is called ([DateTimeConverter.FormatWrapper (Mojarra Implementation Javadoc (2.3))]" (https://javadoc.io/static/org.glassfish/javax. faces / 2.3.0-m04 / javax/faces/convert/DateTimeConverter.FormatWrapper.html#parse-java.lang.CharSequence-))
  4. java.text.DateFormat # parse gives ParseException
  5. The reason is "When the beginning of the specified character string cannot be parsed." (DateFormat (Java Platform SE 8) api / java / text / DateFormat.html # parse-java.lang.String-))

I'm stupid but I often do it

    <h:outputText value="sampleBean.timestamp">
      <f:convertDateTime pattern="yyyy-MM-dd" timeZone="Japan"/>
    </h:outputText>

Correspondence: EL expression should be properly enclosed in # {}

    <h:outputText value="#{sampleBean.timestamp}">
      <f:convertDateTime pattern="yyyy-MM-dd" timeZone="Japan"/>
    </h:outputText>

Recommended Posts

ParseException: What to do when Unparseable date is reached
What to do when javax.batch.operations.JobStartException occurs
[Joke] What to do when the invalid sample rate is reached when using Mixxx on Ubuntu 20.04
What to do when a javax.el.PropertyNotWritableException occurs
What to do when undefined method ʻuser_signed_in?'
[IOS] What to do when the image is filled with one color
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do when debugging "Source not found"
What do you use when converting to String?
What to do when IllegalStateException occurs in PlayFramework
What to do when you want to delete a migration file that is "NO FILE"
What to do when is invalid because it does not start with a'-'
What to do when The SSL certificate has expired
What to do when JSF tags do not become HTML
What to do if ClassNotFoundException occurs when starting Tomcat
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do when rbenv says that there is no readline or lib history
What to do when "Fail to load the JNI shared library" is displayed in Eclipse
What to do when Address already in use is displayed after executing rails s
Introduction to Ratpack (1) --What is Ratpack?
What to do when it becomes Unable to find CDI BeanManager.
[App groups] What to check when UserDefaults data is inaccessible
What to do when you launch an application with rails
What to do if audio is not available on discordrb
What to do if FacesMessage is set but not displayed
What to do when Cannot apply expression operators to method binding
What to do when Cannot format given Object as a Date in convertDateTime of JSF
[Rails] What to do when the view collapses when a message is displayed with the errors method
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
[Rails] What to do if data is not registered in DB
What to do when the changes in the Servlet are not reflected
What to do when you want to know the source position where the method is defined in binding.pry
What to do if Cloud9 is full in the Rails tutorial
What to do if the Eclipse Maven dependency Jar is wrong
[Rails] What to do when rails s does not respond or does not stop
java.security.InvalidKeyException: What to do when Illegal key size or default parameters
What to do when you become a Problem During Content Assist
What to do if the app is not created with the latest Rails version installed when rails new
What to do when you run into a docker-compose node_modules problem
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What to do if zip dies if there is a pom when making an executable jar with gradle
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if the background image is not applied after deployment
What to do if the prefix c is not bound in JSP
What to do when CentOS cannot be started with VirtualBox on Catalina
What to do when Blocked Host: "host name" appears in Ruby on Rails
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do after updating Dockerfile, docker-compose.yml
What is Docker? I tried to summarize
What to do if you install Ubuntu
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
What to do if you get an "A server is already running." Error when you try to start the rails server