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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.