package javaapplication1;
import java.io.*;
import java.text.*;
import java.util.Date;
public class JavaApplication1
{
public static void main(String[] args)
{
try
{
File file = new File("d:\\data.txt");
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
System.out.println(sdf.format(file.lastModified()));
sdf = new SimpleDateFormat("HH");
String hh = sdf.format(file.lastModified());
sdf = new SimpleDateFormat("mm");
String mm = sdf.format(file.lastModified());
sdf = new SimpleDateFormat("ss");
String ss = sdf.format(file.lastModified());
String newdate = "02/15/2014 " + hh + ":" + mm + ":" + ss;
sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = sdf.parse(newdate);
file.setLastModified(date.getTime());
System.out.println(sdf.format(file.lastModified()));
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}
/*
run:
06/20/2015 23:06:33
02/15/2014 23:06:33
*/