I was given code that uses the dateTimeFormat function. The original developer used the mask "MM-HH-YY-dd-NN". This code runs on his machine. And it works on our test server. But this does not work on my local machine. I can make it work only when changing the mask to "MM-HH-yy-dd-NN";
Please note that the difference here is upper case "YY" and lower case "yy"
Looking at the documentation at https://wikidocs.adobe.com/wiki/display/coldfusionen/DateTimeFormat , it seems that yy lowercase is an officially supported way of doing things.
Does anyone know why YY will be supported in some situations and not in others? I suspect that this may be some kind of localization code somewhere, but I do not find differences in my CF administration and on the test server. Is there something I can do on my machine to do YY work?
My machine is a Windows 7 virtual machine running on a Mac, and the server is a Windows 2008 server.
My JVM is 1.6.0_29 and the server is running 1.7.0
Are these differences sufficient to explain the problem?
Here is a simple test code:
<cfscript> testTime=now(); lowermask= "MM-HH-yy-dd-NN"; uppermask= "MM-HH-YY-dd-NN"; result = { lower=dateTimeFormat(testTime, lowermask) ,upper=dateTimeFormat(testTime, uppermask) }; writedump(result); </cfscript>
It seems the problem is with the base version of Java. The error I am getting is:
java.lang.IllegalArgumentException: Illegal pattern character 'Y' at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:768) at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:575) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:500) at coldfusion.util.DateUtils.getCFDateTimeFormat(DateUtils.java:673) at coldfusion.util.DateUtils.formatDateTime(DateUtils.java:942) at coldfusion.runtime.CFPage.LSDateTimeFormat(CFPage.java:1750) at coldfusion.runtime.CFPage.LSDateTimeFormat(CFPage.java:1742) at coldfusion.runtime.CFPage.DateTimeFormat(CFPage.java:1722) at cftemp2ecfm333879290.runPage(C:\inetpub\wwwroot\temp.cfm:7) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:444) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:64) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:449) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:112) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:204) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
source share