• Post Reply Bookmark Topic Watch Topic
  • New Topic

usage of substring in jstl variable  RSS feed

 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
i'm attempting to get a substring (last 4 chars of the string date) and call it var="year", can't get it to work so far. Here is what I have:



Could anybody please help me with this one?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd better use formatDate instead :
<jsp:useBean id="today" class="java.util.Date"/>
--> <fmt:formatDate pattern="yyyy" value="${today}"/>

don't forget to declare the prefix:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!