Pretty simple:
Date date = new Date(file.lastModified())
This works because the long value returned by File.lastModified() is the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970), as stated in Javadoc . The same can be said of java.util.Date . Thus, they are already in UTC / GMT. When a date is converted to a string, for example via Date.toString() or DateFormat , it is usually expressed in the local time zone, but the long value stores are time-agnostic.
Rob H Mar 10 2018-11-11T00: 00Z
source share