I am trying to get information on when was the last date a file was modified in java. I have the date in long format. I dont know why the long object is showing the year to be 1970.Below is my code
File mypath=new File(my_global_folder+"/"+mydata.getItemAtPosition(position));
long time=mypath.lastModified();
//When i try to convert long to Date the year part reads 1970
Date mydate= new Date(time);
Can anyone help me modify the code to give the right lat modified date
KINYUA_1
0
Newbie Poster
Recommended Answers
Jump to PostI can't see anything wrong with that code. I pasted it into a little stand-alone test and it works perfectly...
JFileChooser fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(null); File f = fileChooser.getSelectedFile(); long time = f.lastModified(); System.out.println(new Date(time));
All 2 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
KINYUA_1
commented:
Am debugging on android, when i toast the date in string format, it shows 1970 as the year
+0
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
KINYUA_1
commented:
Thankslet me try that code
+0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.