Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7556165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:47:54+00:00 2026-05-30T11:47:54+00:00

I would really need an alternative to SimpleDateFormat, I am converting many-many Strig dates(>100k)

  • 0

I would really need an alternative to SimpleDateFormat, I am converting many-many Strig dates(>100k) from JST to GMT. The problem I have is that my code generates way to many char[] , as I noticed while profiling. For 150k dates, I get constant 150MB of memory used, and its not really an option. Thanks.

    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
    sdf.setTimeZone(tz);
    try {
        Date theResult = sdf.parse(dateToConvert);
        SimpleDateFormat rdf = new SimpleDateFormat(resultDateFormat);
        rdf.setTimeZone(resultTz);
        return rdf.format(theResult);
    } catch (ParseException e) {
        e.printStackTrace();
    }

I can not use Joda time, so that is not an option for me. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:47:55+00:00Added an answer on May 30, 2026 at 11:47 am

    Do you have a particular reason to assume that SimpleDateFormat is inefficient at parsing dates? Unless your dates have a very specific characteristic to them that lends itself to a certain optimisation, I would have thought that the JDK class will do a reasonable job of it.

    That said, on the assumption that your dates aren’t all distinct (unlikely with 100k), you could look into caching – populate a map with the String being passed in and the Date coming out. This will likely greatly reduce the amount of parsing required; it may or may not result in a noticeable speed-up/memory gain depending on the existing characteristics.

    As an aside, creating two new SimpleDateFormats each time is likely to be very inefficient. Why not create these instances once when the class is loaded (unless the format changes by the line)? This might solve your problem in itself, if the internals of the SDF are such that it involves a lot of char[] allocation on its first run. (Remember that bizarrely date formats aren’t thread-safe, though, so you might want a ThreadLocal<DateFormat> if your parsing class is used concurrently).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would really need to programmatically click on all nodes in the collection, but
I really need help with interfaces in general... Any resources that you guys would
I need to Track Unique Visitor count in my web application. I would really
I sometimes need to debug JS in other browsers, and it would be really
I would really like to see a proportional font IDE, even if I have
I would really love to push for TDD development inside the shop I'm working
I would really like to annotate a method with a reference to a single
I would really appreciate any suggestions, no matter how simple or complex, to help
I would really like to use SpringSource dm Server, but our customer requires us
I would really appreciate some feedback on what I am trying to achieve: The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.