Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java Example – Getting File Modification Time

Java Example - Getting File Modification Time

Java Examples Java Examples

The following example demonstrates how to use the File class's file.lastModified() method to get a file's last modified time

Main.java File

import

java

.

io

.

File

;

import

java

.

util

.

Date

;

public

class

Main

{

public

static

void

main

(

String

[

]

args

)

{

File

file

=

new

File

(

"

Main.java

"

)

;

Long

lastModified

=

file

.

lastModified

(

)

;

Date

date

=

new

Date

(

lastModified

)

;

System

.

out

.

println

(

date

)

;

}

}

The output of the above code is:



Thu Apr 09 09:40:19 CST 2015

Java Examples Java Examples