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 3312264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:58:27+00:00 2026-05-17T21:58:27+00:00

Previously, when I first design a stock application related software, I decide to use

  • 0

Previously, when I first design a stock application related software, I decide to use java.util.Date to represent date/time information of a stock.

Later, I realize most of the methods in java.util.Date is deprecated. Hence, very soon, I refactor all my code to make use of java.util.Calendar

However, there is 2 shortcomings I encounter.

  1. Construct java.util.Calendar is comparative slower than java.util.Date
  2. Within the accessors getCalendar method of Stock class, I need to clone a copy, as Calendar is a mutable class

Here is the current source code for Stock.java

Recently, I discover Joda-Time. I do the following benchmarking, by creating 1,000,000 java.util.Date, java.util.Calendar and org.joda.time.DateTime. I found org.joda.time.DateTime performs better than java.util.Calendar, during instantiation.

Here is the benchmarkingalt text result.

This instantiation speed is important, especially many instance of Stocks will be created, to represent a long price history of a stock.

Do you think is it worth to migrate from Java Calendar to Joda Date Time, to gain application speed performance? Is there any trap I need to pay attention to?

  • 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-17T21:58:28+00:00Added an answer on May 17, 2026 at 9:58 pm

    Note that java.util.Date is mutable too – so if it’s a problem now you’re using Calendar, it would have been a problem using Date too. That said, using Joda Time is definitely worth doing just because it’s a much, much better API.

    How certain are you that performance is actually an issue in your particular app? You say there will be “many instances” of Stock created… how many? Have you profiled it? I wouldn’t expect it to actually make a significant difference in most situations. It’s not obvious from your benchmarking graph what you’re actually measuring.

    Moving to Joda Time is a good idea in general, but I would measure the performance to see how much difference it really makes for you.

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

Sidebar

Related Questions

I recently read the Head First Design Patterns book and I especially liked how
I have a design question. I have a nested repeater structure that is 4
After months of frustration and of time spent in inserting needles in voodoo dolls
First up, this might be the wrong place to ask this question.. So, sincere
I previously asked a question over on Pro Webmasters about putting Javascript at the
I'm deleting a previously asked question and asking again more succinctly now that I
This is my first post on SO, so hi! I'm new to Xcode and
BorderLayout does something strange. If I add two panels to a Container with the
Perhaps it doesn't matter to the compiler once it optimizes, but in C/C++, I

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.