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
Jump to Post
I 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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.