tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Lauman <jlau...@nwcascades.com>
Subject Custom Taglib /JSTL 1.1.2/JBoss4.0.1 Problem - Unparseable date
Date Thu, 30 Dec 2004 00:10:42 GMT
This is show stopper for us.  Does anyone know how to fix this problem?  It apparently only
affects JBoss v4.0.x.

It seems to affect any call to java.util.Date in a jsp page.  The exception is coming from
a custom tag library that I use for scheduling when date/time sensitive persistant content
should be displayed.  This code works fine in v3.0.7, v3.2.7 but not in v4.0.1.  I tried several
different combinations in the 'properties-service.xml' file, all of which generated mbean
errors.

I don't have a clue as to what should be used here.  Is the a way to disable the default date
parser?

Any help would be appreciated.

Thanks,

Jack

<--- ERROR --->
org.jboss.util.NestedRuntimeException: Unparseable date: "Mon Dec 27 16:49:16 PST 2004"; -
nested throwable: (java.text.ParseException: Unparseable date: "Mon Dec 27 16:49:16 PST 2004")
    org.jboss.util.propertyeditor.DateEditor.getValue(DateEditor.java:42)
    org.apache.taglibs.standard.lang.jstl.Coercions.coerceToObject(Unknown Source)
    org.apache.taglibs.standard.lang.jstl.Coercions.coerce(Unknown Source)
    org.apache.taglibs.standard.lang.jstl.ELEvaluator.convertStaticValueToExpectedType(Unknown
Source)
    org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(Unknown Source)
    org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(Unknown Source)
    org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Unknown Source)
    org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Unknown Source)
    org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(Unknown Source)
    com.nwc.tags.DateSelectTag.doEndTag(DateSelectTag.java:120)
<--- END ERROR --->


<--- CODE SNIP --->
public int doEndTag() throws JspException {
/*
* Evaluate the EL expression, if any
*/
Integer days = (Integer) ExpressionEvaluatorManager.evaluate("days", daysEL, Integer.class,
this, pageContext);

<<< THIS IS THE LINE THAT THROWS THE EXCEPTION >>>
java.util.Date attribSelect = (java.util.Date) ExpressionEvaluatorManager.evaluate("select",
selectEL, java.util.Date.class, this, pageContext);

String name = (String) ExpressionEvaluatorManager.evaluate("name", nameEL, String.class, this,
pageContext);
String expires = (String) ExpressionEvaluatorManager.evaluate("expires", expiresEL, String.class,
this, pageContext);

Calendar now = Calendar.getInstance();
   now.set(Calendar.HOUR_OF_DAY, 0);
   now.set(Calendar.MINUTE, 0);
   now.set(Calendar.SECOND, 0);
   now.set(Calendar.MILLISECOND, 0);

SimpleDateFormat displayFormat = new SimpleDateFormat("MMM dd (EE)");
SimpleDateFormat valueFormat = new SimpleDateFormat("MMMddyyyy");

HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
  try {
      JspWriter out = pageContext.getOut();
      out.write("<SELECT NAME=\"" + name + "\">");

      java.util.Date today = valueFormat.parse(valueFormat.format(now.getTime()));
      java.util.Date select = null;

           if (attribSelect == null) {
               Calendar invalid = Calendar.getInstance();
               invalid.set(Calendar.HOUR_OF_DAY, 0);
               invalid.set(Calendar.MINUTE, 0);
               invalid.set(Calendar.SECOND, 0);
               invalid.set(Calendar.MILLISECOND, 0);
               invalid.set(Calendar.DAY_OF_YEAR, invalid.get(Calendar.DAY_OF_YEAR) + days.intValue()
+ 1);
               select = valueFormat.parse(valueFormat.format(invalid.getTime()));
           } else {
               select = valueFormat.parse(valueFormat.format(attribSelect));
           }

           if (select.before(today)) {
               if (expires.equals("yes")) {
                   out.write("<OPTION SELECTED CLASS=\"red\" VALUE=\"" + valueFormat.format(select)
+ "\">Expired");
               } else {
                   out.write("<OPTION SELECTED VALUE=\"" + valueFormat.format(select) +
"\">" + displayFormat.format(select) + "");
               }
           }
<--- END CODE SNIP --->




---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message