How does the Date object update without recompiling the program in Java?











up vote
3
down vote

favorite












Example:



System.out.println(new Date());


Now obviously this is part of a larger program, but you can see what this does. Now, I run the compiler once, and then run the program. Then, without compiling the program again, I run it and the date updates. This might seem stupid but how does the date update without updating the bytecode?



From my understanding through what I have read the Java compiler takes my source code and compiles it to bytecode, which is saved in a class file. The JIT converts this code to machine code and it runs. However, wouldn't the state of the Date object stay the same? It obviously doesn't. I am just confused on how it changes.










share|improve this question




















  • 3




    What do you think a compilation is?
    – Fureeish
    Nov 11 at 0:33






  • 3




    new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
    – khelwood
    Nov 11 at 0:35








  • 2




    ^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
    – Caleb Suhy
    Nov 11 at 0:37






  • 2




    As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
    – jhenrique
    Nov 11 at 2:58








  • 2




    You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
    – Ole V.V.
    Nov 11 at 6:42

















up vote
3
down vote

favorite












Example:



System.out.println(new Date());


Now obviously this is part of a larger program, but you can see what this does. Now, I run the compiler once, and then run the program. Then, without compiling the program again, I run it and the date updates. This might seem stupid but how does the date update without updating the bytecode?



From my understanding through what I have read the Java compiler takes my source code and compiles it to bytecode, which is saved in a class file. The JIT converts this code to machine code and it runs. However, wouldn't the state of the Date object stay the same? It obviously doesn't. I am just confused on how it changes.










share|improve this question




















  • 3




    What do you think a compilation is?
    – Fureeish
    Nov 11 at 0:33






  • 3




    new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
    – khelwood
    Nov 11 at 0:35








  • 2




    ^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
    – Caleb Suhy
    Nov 11 at 0:37






  • 2




    As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
    – jhenrique
    Nov 11 at 2:58








  • 2




    You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
    – Ole V.V.
    Nov 11 at 6:42















up vote
3
down vote

favorite









up vote
3
down vote

favorite











Example:



System.out.println(new Date());


Now obviously this is part of a larger program, but you can see what this does. Now, I run the compiler once, and then run the program. Then, without compiling the program again, I run it and the date updates. This might seem stupid but how does the date update without updating the bytecode?



From my understanding through what I have read the Java compiler takes my source code and compiles it to bytecode, which is saved in a class file. The JIT converts this code to machine code and it runs. However, wouldn't the state of the Date object stay the same? It obviously doesn't. I am just confused on how it changes.










share|improve this question















Example:



System.out.println(new Date());


Now obviously this is part of a larger program, but you can see what this does. Now, I run the compiler once, and then run the program. Then, without compiling the program again, I run it and the date updates. This might seem stupid but how does the date update without updating the bytecode?



From my understanding through what I have read the Java compiler takes my source code and compiles it to bytecode, which is saved in a class file. The JIT converts this code to machine code and it runs. However, wouldn't the state of the Date object stay the same? It obviously doesn't. I am just confused on how it changes.







java date instantiation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 15:44









Mureinik

176k21127195




176k21127195










asked Nov 11 at 0:31









Caleb Suhy

297




297








  • 3




    What do you think a compilation is?
    – Fureeish
    Nov 11 at 0:33






  • 3




    new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
    – khelwood
    Nov 11 at 0:35








  • 2




    ^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
    – Caleb Suhy
    Nov 11 at 0:37






  • 2




    As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
    – jhenrique
    Nov 11 at 2:58








  • 2




    You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
    – Ole V.V.
    Nov 11 at 6:42
















  • 3




    What do you think a compilation is?
    – Fureeish
    Nov 11 at 0:33






  • 3




    new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
    – khelwood
    Nov 11 at 0:35








  • 2




    ^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
    – Caleb Suhy
    Nov 11 at 0:37






  • 2




    As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
    – jhenrique
    Nov 11 at 2:58








  • 2




    You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
    – Ole V.V.
    Nov 11 at 6:42










3




3




What do you think a compilation is?
– Fureeish
Nov 11 at 0:33




What do you think a compilation is?
– Fureeish
Nov 11 at 0:33




3




3




new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
– khelwood
Nov 11 at 0:35






new Date is evaluated when the code is run, not when it is compiled. Compiling doesn't work out the date and store it in your bytecode. It stores the instructions that include looking up the current date.
– khelwood
Nov 11 at 0:35






2




2




^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
– Caleb Suhy
Nov 11 at 0:37




^^ Ah I see. I guess I just had the wrong idea about when it is evaluated. Thanks!
– Caleb Suhy
Nov 11 at 0:37




2




2




As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
– jhenrique
Nov 11 at 2:58






As you are learning, if you would like to check the bytecode generated from your example try this in your cmd, after you compiled your class: C:Test>javap -c C:TestYourCompiledClass.class C:TestYourBytecode.bc
– jhenrique
Nov 11 at 2:58






2




2




You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
– Ole V.V.
Nov 11 at 6:42






You shouldn’t use the Date class. After years of bad experiences with it, its replacement came out when you were 10: java.time, the modern Java date and time API. Try for example System.out.println(LocalDate.now(ZoneId.systemDefault()));. The answer will be the same, though: a new LocalDate object will be generated every time you run your program.
– Ole V.V.
Nov 11 at 6:42














2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










Compile-time versus Run-time



The Answer by Mureinik is correct. Objects defined in your code are constructed at run-time, not compile-time.



Compilation is like having an engineer review an architect’s plans for a building, and then writing out more detailed specifications. No building is yet built. We are now thoroughly ready to build, but have not actually built anything until “run-time” when the construction crew arrives on site.



In this metaphor, your source code is the architect’s drawings. The engineer’s more detailed specifications is the bytecode emitted by the Java compiler. The JVM running your app’s bytecode is the construction crew going to work on site.



Another way to think if it:




  • Classes are determined at compile-time.

  • Objects (instances) are determined at run-time.


java.time



Also, you should never use the Date class. That class and the other legacy date-time classes from the earliest versions of Java are terrible, riddled with poor design choices. They were supplanted years ago by the modern java.time classes.



The java.time classes use factory methods for instantiating rather than constructors and new.



Instant.now()  // Capture current moment in UTC. 
OffsetDateTime.now( ZoneOffset.UTC ) // Capture current moment in UTC.
ZonedDateTime.now( ZoneId.of( "Africa/Casablanca" ) ) // Capture current moment as seen though the wall-clock time used by the people of a particular region (a time zone).
LocalDate.of( 2018 , Month.JANUARY , 23 ) // A date-only value, without time-of-day and without time zone.





share|improve this answer



















  • 1




    No constant available for Africa/Casablanca ?
    – Koray Tugay
    Nov 11 at 15:05






  • 1




    @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
    – Basil Bourque
    Nov 11 at 15:20








  • 1




    @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
    – Basil Bourque
    Nov 11 at 15:40












  • Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
    – Caleb Suhy
    Nov 12 at 0:43


















up vote
2
down vote













A Date object initialized with the no-arg constructor will access System.currTimeMilis() and use the current timestamp from the machine. In other words, the timestamp isn't "compiled into it", but instead it contains code that accesses the machine's clock and takes the timestamp from there each time the program is run.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244770%2fhow-does-the-date-object-update-without-recompiling-the-program-in-java%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Compile-time versus Run-time



    The Answer by Mureinik is correct. Objects defined in your code are constructed at run-time, not compile-time.



    Compilation is like having an engineer review an architect’s plans for a building, and then writing out more detailed specifications. No building is yet built. We are now thoroughly ready to build, but have not actually built anything until “run-time” when the construction crew arrives on site.



    In this metaphor, your source code is the architect’s drawings. The engineer’s more detailed specifications is the bytecode emitted by the Java compiler. The JVM running your app’s bytecode is the construction crew going to work on site.



    Another way to think if it:




    • Classes are determined at compile-time.

    • Objects (instances) are determined at run-time.


    java.time



    Also, you should never use the Date class. That class and the other legacy date-time classes from the earliest versions of Java are terrible, riddled with poor design choices. They were supplanted years ago by the modern java.time classes.



    The java.time classes use factory methods for instantiating rather than constructors and new.



    Instant.now()  // Capture current moment in UTC. 
    OffsetDateTime.now( ZoneOffset.UTC ) // Capture current moment in UTC.
    ZonedDateTime.now( ZoneId.of( "Africa/Casablanca" ) ) // Capture current moment as seen though the wall-clock time used by the people of a particular region (a time zone).
    LocalDate.of( 2018 , Month.JANUARY , 23 ) // A date-only value, without time-of-day and without time zone.





    share|improve this answer



















    • 1




      No constant available for Africa/Casablanca ?
      – Koray Tugay
      Nov 11 at 15:05






    • 1




      @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
      – Basil Bourque
      Nov 11 at 15:20








    • 1




      @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
      – Basil Bourque
      Nov 11 at 15:40












    • Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
      – Caleb Suhy
      Nov 12 at 0:43















    up vote
    2
    down vote



    accepted










    Compile-time versus Run-time



    The Answer by Mureinik is correct. Objects defined in your code are constructed at run-time, not compile-time.



    Compilation is like having an engineer review an architect’s plans for a building, and then writing out more detailed specifications. No building is yet built. We are now thoroughly ready to build, but have not actually built anything until “run-time” when the construction crew arrives on site.



    In this metaphor, your source code is the architect’s drawings. The engineer’s more detailed specifications is the bytecode emitted by the Java compiler. The JVM running your app’s bytecode is the construction crew going to work on site.



    Another way to think if it:




    • Classes are determined at compile-time.

    • Objects (instances) are determined at run-time.


    java.time



    Also, you should never use the Date class. That class and the other legacy date-time classes from the earliest versions of Java are terrible, riddled with poor design choices. They were supplanted years ago by the modern java.time classes.



    The java.time classes use factory methods for instantiating rather than constructors and new.



    Instant.now()  // Capture current moment in UTC. 
    OffsetDateTime.now( ZoneOffset.UTC ) // Capture current moment in UTC.
    ZonedDateTime.now( ZoneId.of( "Africa/Casablanca" ) ) // Capture current moment as seen though the wall-clock time used by the people of a particular region (a time zone).
    LocalDate.of( 2018 , Month.JANUARY , 23 ) // A date-only value, without time-of-day and without time zone.





    share|improve this answer



















    • 1




      No constant available for Africa/Casablanca ?
      – Koray Tugay
      Nov 11 at 15:05






    • 1




      @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
      – Basil Bourque
      Nov 11 at 15:20








    • 1




      @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
      – Basil Bourque
      Nov 11 at 15:40












    • Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
      – Caleb Suhy
      Nov 12 at 0:43













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    Compile-time versus Run-time



    The Answer by Mureinik is correct. Objects defined in your code are constructed at run-time, not compile-time.



    Compilation is like having an engineer review an architect’s plans for a building, and then writing out more detailed specifications. No building is yet built. We are now thoroughly ready to build, but have not actually built anything until “run-time” when the construction crew arrives on site.



    In this metaphor, your source code is the architect’s drawings. The engineer’s more detailed specifications is the bytecode emitted by the Java compiler. The JVM running your app’s bytecode is the construction crew going to work on site.



    Another way to think if it:




    • Classes are determined at compile-time.

    • Objects (instances) are determined at run-time.


    java.time



    Also, you should never use the Date class. That class and the other legacy date-time classes from the earliest versions of Java are terrible, riddled with poor design choices. They were supplanted years ago by the modern java.time classes.



    The java.time classes use factory methods for instantiating rather than constructors and new.



    Instant.now()  // Capture current moment in UTC. 
    OffsetDateTime.now( ZoneOffset.UTC ) // Capture current moment in UTC.
    ZonedDateTime.now( ZoneId.of( "Africa/Casablanca" ) ) // Capture current moment as seen though the wall-clock time used by the people of a particular region (a time zone).
    LocalDate.of( 2018 , Month.JANUARY , 23 ) // A date-only value, without time-of-day and without time zone.





    share|improve this answer














    Compile-time versus Run-time



    The Answer by Mureinik is correct. Objects defined in your code are constructed at run-time, not compile-time.



    Compilation is like having an engineer review an architect’s plans for a building, and then writing out more detailed specifications. No building is yet built. We are now thoroughly ready to build, but have not actually built anything until “run-time” when the construction crew arrives on site.



    In this metaphor, your source code is the architect’s drawings. The engineer’s more detailed specifications is the bytecode emitted by the Java compiler. The JVM running your app’s bytecode is the construction crew going to work on site.



    Another way to think if it:




    • Classes are determined at compile-time.

    • Objects (instances) are determined at run-time.


    java.time



    Also, you should never use the Date class. That class and the other legacy date-time classes from the earliest versions of Java are terrible, riddled with poor design choices. They were supplanted years ago by the modern java.time classes.



    The java.time classes use factory methods for instantiating rather than constructors and new.



    Instant.now()  // Capture current moment in UTC. 
    OffsetDateTime.now( ZoneOffset.UTC ) // Capture current moment in UTC.
    ZonedDateTime.now( ZoneId.of( "Africa/Casablanca" ) ) // Capture current moment as seen though the wall-clock time used by the people of a particular region (a time zone).
    LocalDate.of( 2018 , Month.JANUARY , 23 ) // A date-only value, without time-of-day and without time zone.






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 11 at 16:28

























    answered Nov 11 at 14:58









    Basil Bourque

    103k25354515




    103k25354515








    • 1




      No constant available for Africa/Casablanca ?
      – Koray Tugay
      Nov 11 at 15:05






    • 1




      @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
      – Basil Bourque
      Nov 11 at 15:20








    • 1




      @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
      – Basil Bourque
      Nov 11 at 15:40












    • Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
      – Caleb Suhy
      Nov 12 at 0:43














    • 1




      No constant available for Africa/Casablanca ?
      – Koray Tugay
      Nov 11 at 15:05






    • 1




      @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
      – Basil Bourque
      Nov 11 at 15:20








    • 1




      @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
      – Basil Bourque
      Nov 11 at 15:40












    • Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
      – Caleb Suhy
      Nov 12 at 0:43








    1




    1




    No constant available for Africa/Casablanca ?
    – Koray Tugay
    Nov 11 at 15:05




    No constant available for Africa/Casablanca ?
    – Koray Tugay
    Nov 11 at 15:05




    1




    1




    @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
    – Basil Bourque
    Nov 11 at 15:20






    @KorayTugay No, no constants for time zones. Politicians around the world have shown an eagerness to frequently rename and redefine their respective time zone(s). The definitions are soft-coded by way of a tzdata file stored outside the compiled classes to facilitate manual updating. The tzdata file needs updating more often and more urgently than releases of the JVM and its library classes.
    – Basil Bourque
    Nov 11 at 15:20






    1




    1




    @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
    – Basil Bourque
    Nov 11 at 15:40






    @KorayTugay We have one constant, for UTC, an offset-from-UTC of zero hours-minutes-seconds: ZoneOffset.UTC. Example: OffsetDateTime.now( ZoneOffset.UTC )
    – Basil Bourque
    Nov 11 at 15:40














    Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
    – Caleb Suhy
    Nov 12 at 0:43




    Yeah the only reason I was using the date class was due to the way the book I am reading is teaching classes. A little weird but Core Java is a pretty good book.
    – Caleb Suhy
    Nov 12 at 0:43












    up vote
    2
    down vote













    A Date object initialized with the no-arg constructor will access System.currTimeMilis() and use the current timestamp from the machine. In other words, the timestamp isn't "compiled into it", but instead it contains code that accesses the machine's clock and takes the timestamp from there each time the program is run.






    share|improve this answer

























      up vote
      2
      down vote













      A Date object initialized with the no-arg constructor will access System.currTimeMilis() and use the current timestamp from the machine. In other words, the timestamp isn't "compiled into it", but instead it contains code that accesses the machine's clock and takes the timestamp from there each time the program is run.






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        A Date object initialized with the no-arg constructor will access System.currTimeMilis() and use the current timestamp from the machine. In other words, the timestamp isn't "compiled into it", but instead it contains code that accesses the machine's clock and takes the timestamp from there each time the program is run.






        share|improve this answer












        A Date object initialized with the no-arg constructor will access System.currTimeMilis() and use the current timestamp from the machine. In other words, the timestamp isn't "compiled into it", but instead it contains code that accesses the machine's clock and takes the timestamp from there each time the program is run.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 6:50









        Mureinik

        176k21127195




        176k21127195






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244770%2fhow-does-the-date-object-update-without-recompiling-the-program-in-java%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?