Question

I have something like this

I/global  ( 3622): Loaded time zone names for en in 355ms.
I/global  ( 3622): Loaded time zone names for en in 307ms.
I/global  ( 3622): Loaded time zone names for en in 309ms.
I/global  ( 3622): Loaded time zone names for en in 310ms.
I/global  ( 3622): Loaded time zone names for en in 324ms.

and I do not have any idea where this log comes from.

I was doing some research on this topic and I guess it comes from

new Date();

but I am not sure.

I need advice what should I do to speed the things up. I have application that is very slow at this moment and the delay comes exactly at this five lines above it takes around a second and a half just to read the time :(.

if you advice is to put a global variable and to read the time just ones sorry I can't do that :(. I need the time in my functions at that moment (it is impossible to read the time just ones :( ).

Was it helpful?

Solution

I found my problem

The problem is that there's no way right now to circumvent this issue due to the design of the SimpleDateFormat api. Only faster phones might fix this by just taking less time to collect those strings.

So I hope there will be no problem with the time zone in the next versions of android skd, and in the newer phones.

till then careful with this line

 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");

cause the delay comes from there

if you use formatting with no time zone it works perfect (with no delay)

 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

OTHER TIPS

I also noticed this when parsing a stream of content containing dates. I realized in my case (and probably the case of many of us) the date format string was the same for each of the SimpleDateFormat objects created.

So, I managed to solved this issue by creating just one SimpleDateFormat object and reusing it whenever I needed to parse dates. There are too many ways of implementing this depending on how your code is structured so I won't go into details.

The delay for loading the time zones still happens once, of course, when the object is created.

Make sure you instantiate only one SimpleDateFormat object, then re-use it wherever you need. This way the time zone names will load only once.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top