Reputation: 21
i want to convert filetime to date in format(DD/MM/YYYY).
here is my code.
Path path = Paths.get(FilePath);
BasicFileAttributes attr;
attr = Files.readAttributes(path, BasicFileAttributes.class);
FileTime date=attr.creationTime();
DateFormat df=new SimpleDateFormat("DD/MM/YYYY");
Fdate=df.format(date.toMillis());
i tried this code month and year is working fine and it's in the format but some value is printing in the day(DD). Thank you.
Upvotes: 0
Views: 3394
Reputation: 69460
You have to use lower d and lower y:
DateFormat df=new SimpleDateFormat("dd/MM/yyyy");
Because:
D Day in year
d Day in month
y Year
Y Week year
For more informations see the javadoc of SimpleDateFormat
Upvotes: 3