Results 1 to 4 of 4

Thread: File Modified

  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default File Modified

    How can I convert the return type of file.lastmodified() to simple date format ? I can't understand what of date it returns

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,648
    Blog Entries
    7
    Rep Power
    21

    Default Re: File Modified

    Quote Originally Posted by allaudin View Post
    How can I convert the return type of file.lastmodified() to simple date format ? I can't understand what of date it returns
    The GregorianCalendar extends the Calendar class and the latter has the setTimeInMillis( ... ) method; millis is what you get for the last modiied date ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,074
    Rep Power
    6

    Default Re: File Modified

    Quote Originally Posted by allaudin View Post
    How can I convert the return type of file.lastmodified() to simple date format ? I can't understand what of date it returns
    The current timestamp, an even simpler way to represent a date than an actual Date object, nice and cross-platform too. You don't need to use a Calendar by the way, the millisecond constructor is one of the few Date constructors that is actually NOT deprecated.

    Date (Java Platform SE 7 )

    So this would suffice:

    Java Code:
    Date lastModified = new Date(file.getLastModified());
    The Javadoc is your friend.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

Similar Threads

  1. How to create an array that can be modified
    By i8java in forum New To Java
    Replies: 5
    Last Post: 12-19-2010, 07:19 PM
  2. Modified Pixels
    By monkey04 in forum Java 2D
    Replies: 1
    Last Post: 03-12-2009, 08:15 AM
  3. JSP Last Modified Date
    By thagentleman in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-18-2008, 04:52 AM
  4. Replies: 0
    Last Post: 04-04-2008, 02:45 PM
  5. Checking of file was modified on the server
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •