Henry E.

asked • 10/12/20

Can somebody please fix the output of date in this code

package filestatistics2;

import java.io.File;

import java.util.*;

import java.text.*;

public class FileStatistics2

{

private static Object f;

public static void main(String[] args)

{

final Formatter sup;

try

{

sup = new Formatter("FileStatistics.java");

File f = new File("C:\\Users\\saint\\Desktop\\FileStatistics.java");

String fileName = f.getName();

long fileSize = f.length();

System.out.println("Filename:" + "FileStatistics.Java");

System.out.println("FileStatistics.java's size is: " + fileSize + " bytes");

System.out.println("The file's folder location is: " + f.getPath());

long lastModified = 0;

Date d = new Date(lastModified);

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");

System.out.println("Modified: " + sdf.format(d));

System.out.println("File created ^-^!");

}

catch (Exception e) {

System.out.println("error occured! @^@'");

System.out.println("File Not created ;^;!");

}

}

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.