Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

java.io.File.lastModified returns 0

LEGEND ,
Sep 03, 2020 Sep 03, 2020

Hello, all,

 

I'm working on some legacy code, and the original developer was manually setting a "last modified" date on documents he worked on.  I learned that there is a programmatic way of doing this, and I'm trying, but the value returned is 0.

 

<!--- I got this from Pete Freitag's blog. --->
<cfset thisFile = CreateObject("java","java.io.File") />
<cfset thisFile.init("" & cgi.script_name & "") />
<cfset lastMod = thisFile.lastModified() />
<cfset lastMod = DateFormat(DateAdd('s',lastMod,"January 1 1970 00:00:00"),"mmmm dd, yyyy") />

 

Last mod is reporting as January 1, 1970, which means that it's 0.  Please advise.

 

V/r,

 

^ _ ^

TOPICS
Advanced techniques , Asynchronous , Builder , cfchart , Cffiddle , Connector , Database access , Documentation , Event gateways , Flash integration , Getting started , Monitoring , Reporting , Security , Server administration
730
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 03, 2020 Sep 03, 2020

Well, I think I know why it didn't work.  But I found another way of doing it, that I will be using.

<cfset thisFilePath = getCurrentTemplatePath() />
<cfset lastMod = DateFormat(GetFileInfo(thisFilePath).lastmodified,'mmmm dd, yyyy') />

I was hoping to do this in application.cfc, just the once.  The above method has to be put on each page, but I'm okay with that.

 

V/r,

 

^ _ ^

Translate
LEGEND ,
Sep 03, 2020 Sep 03, 2020
LATEST

Well, I think I know why it didn't work.  But I found another way of doing it, that I will be using.

<cfset thisFilePath = getCurrentTemplatePath() />
<cfset lastMod = DateFormat(GetFileInfo(thisFilePath).lastmodified,'mmmm dd, yyyy') />

I was hoping to do this in application.cfc, just the once.  The above method has to be put on each page, but I'm okay with that.

 

V/r,

 

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources