Forums de discussion

Can't use dateFormat and FastDateFormatFactoryUtil not found

Sam Wan, modifié il y a 14 années.

Can't use dateFormat and FastDateFormatFactoryUtil not found

Liferay Master Publications: 660 Date d'inscription: 03/03/09 Publications récentes
Dear everyone,

I don't know why I would have the following error:


07:46:56,577 ERROR [[jsp]:711] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 


An error occurred at line: 214 in the generated java file
Only a type can be imported. com.liferay.portal.kernel.util.FastDateFormatFactoryUtil resolves to a package


An error occurred at line: 215 in the generated java file
The import com.liferay.portal.model.PortletPreferences collides with another import statement

An error occurred at line: 52 in the jsp file: /html/portlet/ext/servicepackage/init.jsp
Format cannot be resolved to a type
49: <%@ page import="com.liferay.portal.util.LayoutView" %>
50: 
51: <%
52: Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale, timeZone);
53: Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale, timeZone);
54: 



What have I missing in my project setup?

Very appreciate for any suggestion and example.

Thanks
Sam
thumbnail
Gnaniyar Zubair, modifié il y a 14 années.

RE: Can't use dateFormat and FastDateFormatFactoryUtil not found

Liferay Master Publications: 722 Date d'inscription: 19/12/07 Publications récentes
Hi Sam,


you can use jsp tag for date format like this:



<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

<fmt:formatDate value="<%= article.getCreateDate() %>" type="date" pattern="dd-MMM-yy" />




- Gnaniyar Zubair
Sam Wan, modifié il y a 14 années.

RE: Can't use dateFormat and FastDateFormatFactoryUtil not found

Liferay Master Publications: 660 Date d'inscription: 03/03/09 Publications récentes
Gnaniyar Zubair:
Hi Sam,


you can use jsp tag for date format like this:



<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

<fmt:formatDate value="<%= article.getCreateDate() %>" type="date" pattern="dd-MMM-yy" />




- Gnaniyar Zubair


Thanks Gnaniyar.
Never known I can format a date in this way. emoticon

It just appeared unusual that when I can use Format in another project, but can't use it in this project.
thumbnail
Jakub Liska, modifié il y a 13 années.

RE: Can't use dateFormat and FastDateFormatFactoryUtil not found

Regular Member Publications: 187 Date d'inscription: 25/03/10 Publications récentes
Hi guys,

I have the same issue, after I import FastDateFormatFactoryUtil / DateFormatFactoryUtil, then I'm getting compilation errors due to unresolved variable (non-related) that otherwise exist when DateFormatFactoryUtil is not imported ...
Arun Kumar, modifié il y a 14 années.

RE: Can't use dateFormat and FastDateFormatFactoryUtil not found

New Member Publications: 15 Date d'inscription: 01/02/10 Publications récentes
Sam Wan:
Dear everyone,

I don't know why I would have the following error:


07:46:56,577 ERROR [[jsp]:711] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 


An error occurred at line: 214 in the generated java file
Only a type can be imported. com.liferay.portal.kernel.util.FastDateFormatFactoryUtil resolves to a package


An error occurred at line: 215 in the generated java file
The import com.liferay.portal.model.PortletPreferences collides with another import statement

An error occurred at line: 52 in the jsp file: /html/portlet/ext/servicepackage/init.jsp
Format cannot be resolved to a type
49: &lt;%@ page import="com.liferay.portal.util.LayoutView" %&gt;
50: 
51: &lt;%
52: Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale, timeZone);
53: Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale, timeZone);
54: 



What have I missing in my project setup?

Very appreciate for any suggestion and example.

Thanks
Sam


It happens most of the time for me as well, i donno why !!!!.
In that case , we would rather import with packagename.* or use the whole class name with package while accessing it.