Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: help me with readFileAttributes() method, Time question

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default help me with readFileAttributes() method, Time question

    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    import java.nio.file.attribute.BasicFileAttributes;
     
     
    public class Main {
     
    	/**
    	 * @param args
    	 * @throws IOException 
    	 */
    	public static void main(String[] args) throws IOException {
    		Path p1 = Paths.get("C:\\Users\\User\\Desktop\\Desk");
     
    		BasicFileAttributes att = Files.readAttributes(p1, BasicFileAttributes.class);
     
    		System.out.println("Size: " + att.lastModifiedTime());
     
    	}
     
    }

    time is retured as GMT format.
    what should i do to return it to GMT+4 etc?

    and lastAccessTime() is also not showing correct time. I modified a file then chcked it lastModifiedtime(). it shows the current time(GMT) but when i System.out the lastAccesstime() it shows the wrong time..
    Last edited by fredsilvester93; August 2nd, 2012 at 02:21 AM.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: help me with readFileAttributes() method, Time question

    Quote Originally Posted by fredsilvester93 View Post
    ...

    time is retured as GMT format.
    what should i do to return it to GMT+4 etc?
    peek in at the calendar class and check out the add method


    Quote Originally Posted by fredsilvester93 View Post
    ...
    and lastAccessTime() is also not showing correct time.
    What time does it show? What time did you expect to see?

Similar Threads

  1. Question on a method?
    By cam25 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: June 17th, 2012, 02:53 PM
  2. [SOLVED] Question about using the toString method.
    By iDizzle in forum Object Oriented Programming
    Replies: 12
    Last Post: April 9th, 2012, 09:24 AM
  3. Prime Factorization Method: Won't reproduce all Factors every time
    By Staticity in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 30th, 2011, 05:16 AM
  4. execute a method over a maximum period of time
    By PedroCosta in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 24th, 2011, 02:06 PM
  5. java threading execution time question
    By centenial in forum Threads
    Replies: 4
    Last Post: September 8th, 2010, 11:32 PM