Code Monkey home page Code Monkey logo

Comments (9)

candrews avatar candrews commented on July 20, 2024

Locale.getDefault() may return any locale - and any formatting rules. For example, it may even return a locale which does not use the Gregorian calendar. HTTP dates are expected to be in a specific format, and as far as I know, using Locale.US is the way to do that.

from httpresponsecache.

swankjesse avatar swankjesse commented on July 20, 2024

Which device+OS are you using? I believe that in ICS (and earlier?) the US and default locales are always preloaded and available immediately.

from httpresponsecache.

iNoles avatar iNoles commented on July 20, 2024

I was testing in the gingerbread emulator. It did show that line in each time you instance SimpleDateFormat.

from httpresponsecache.

tprochazka avatar tprochazka commented on July 20, 2024

I can confirm. Tested on 2.3.5 on the HTC Rom, in log is

04-08 12:26:09.980: I/global(19394): Loaded time zone names for en_US in 987ms.

But on ICS it is OK

from httpresponsecache.

tprochazka avatar tprochazka commented on July 20, 2024

What about simply cache whole instance of SimpleDateFormat("formatString", Locale.US) as static variable?

from httpresponsecache.

candrews avatar candrews commented on July 20, 2024

SimpleDateFormat is not thread safe, see http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
So we can't have one global instance.

from httpresponsecache.

tprochazka avatar tprochazka commented on July 20, 2024

And it's problem synchronize it? I don't think that it will be bottleneck, it is only very small time compared by whole network communication. But if you don't think it, another way is use ThreadLocal.

from httpresponsecache.

jaypatrickhoward avatar jaypatrickhoward commented on July 20, 2024

Could potentially store one instance of SimpleDateFormat (with US locale) then use ".clone()" to get a copy each time a thread needs to use it. Not sure whether concurrent use of two instances cloned from the same original instance would be thread-safe. If so, though, it gets around the locale lookup problem.

from httpresponsecache.

candrews avatar candrews commented on July 20, 2024

Please see issue #19

from httpresponsecache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.