OFBiz
  1. OFBiz
  2. OFBIZ-4201

DateFormat.getDateTimeInstance() is very expensive, we can cache it to improve performance

    Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Release Branch 10.04
    • Fix Version/s: SVN trunk
    • Component/s: framework
    • Labels:
      None

      Description

      In the files:

      ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilDateTime.java line:702
      ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java line:314
      ./apache-ofbiz-10.04/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java line: 78

      DateFormat.getDateTimeInstance() is called for every function call of "toGmtTimestampString" or "formatDate". We can cache the value by adding a static class field and improve performance.

      This is similar to the Apache Bug https://issues.apache.org/bugzilla/show_bug.cgi?id=48778

        Activity

        Xiaoming Shi created issue -
        Xiaoming Shi made changes -
        Field Original Value New Value
        Description In the files:

        ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilDateTime.java line:702
        ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java line:314

        DateFormat.getDateTimeInstance() is called for every function call of "toGmtTimestampString" or "formatDate". We can cache the value by adding a static class field and improve performance.

        This is similar to the Apache Bug https://issues.apache.org/bugzilla/show_bug.cgi?id=48778


        In the files:

        ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilDateTime.java line:702
        ./apache-ofbiz-10.04/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java line:314
        ./apache-ofbiz-10.04/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java line: 78

        DateFormat.getDateTimeInstance() is called for every function call of "toGmtTimestampString" or "formatDate". We can cache the value by adding a static class field and improve performance.

        This is similar to the Apache Bug https://issues.apache.org/bugzilla/show_bug.cgi?id=48778


        Jan le Roux committed 1165076 (3 files)
        Reviews: none

        Closes https://issues.apache.org/jira/browse/OFBIZ-4201

        "DateFormat.getDateTimeInstance() is very expensive, we can cache it to improve performance"

        jlr: It's not really cache but a static class constant

        Hide
        Jacques Le Roux added a comment -

        Thanks for report Shi,

        It's done in trunk at r1165076

        Show
        Jacques Le Roux added a comment - Thanks for report Shi, It's done in trunk at r1165076
        Jacques Le Roux made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Jacques Le Roux [ jacques.le.roux ]
        Fix Version/s SVN trunk [ 12311928 ]
        Resolution Fixed [ 1 ]
        Jan le Roux committed 1165084 (3 files)
        Reviews: none

        Revert r1165076 (at Adrian's right demand)

        Actually I hastily did it bad using static instead of caching. Anyway, I checked there are no real needs to change current code in OFBiz for perf.: one instance is in an exception and the other not called OOTB...

        Was: Closes https://issues.apache.org/jira/browse/OFBIZ-4201

        "DateFormat.getDateTimeInstance() is very expensive, we can cache it to improve performance"

        Show
        Jacques Le Roux added a comment - We will certainly use http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/time/FastDateFormat.html rather
        Jacques Le Roux made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]

          People

          • Assignee:
            Jacques Le Roux
            Reporter:
            Xiaoming Shi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development