I'm currently testing out some webapp technologies in a java project and was wondering why the pages sometimes load fast and sometimes take almost 5s to load.
I finally found out that it is this line
LocalDateTime now = new LocalDateTime();
When it's called the first time, it takes forever to get the current time. When called after that, even somewhere completely different, it's pretty fast however.
I'm currently using
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
Has anyone had any similar experience? Really stuck here.. I could use LocalDateTime some time early in my application to fasten up subsequent calls - but this seems pretty dull tho.
EDIT
I misuse Spring for that now:
@Service
public class JodaTimeLoader {
public JodaTimeLoader() {
LocalDateTime loadMe = new LocalDateTime();
}
}
Joda-Time is designed for long running enterprise systems where a one-off up front load time is irrelevant compared to the faster performance during the rest of the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With