Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8144808

LocalDateTime.parse(CharSequence t, DateTimeFormatter f) bad performance

XMLWordPrintable

    • generic
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      When parse large text file using method a, performance is bad!
      And the workaround code method b is not elegant.

      private LocalDateTime a(String time) {
          return LocalDateTime.parse(time, ofPattern("yyyyMMddHHmmss"));
      }

      // workaround code
      private LocalDateTime b(String time) {
          int year = Integer.valueOf(time.substring(0, 4));
          int month = Integer.valueOf(time.substring(4, 6));
          int day = Integer.valueOf(time.substring(6, 8));
          int hour = Integer.valueOf(time.substring(8, 10));
          int minute = Integer.valueOf(time.substring(10, 12));
          int sec = Integer.valueOf(time.substring(12));
          return LocalDateTime.of(year, month, day, hour, minute, sec);
      }

      JUSTIFICATION :
      Performance is important !

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      improved performance
      ACTUAL -
      bad performance

      CUSTOMER SUBMITTED WORKAROUND :
      private LocalDateTime b(String time) {
          int year = Integer.valueOf(time.substring(0, 4));
          int month = Integer.valueOf(time.substring(4, 6));
          int day = Integer.valueOf(time.substring(6, 8));
          int hour = Integer.valueOf(time.substring(8, 10));
          int minute = Integer.valueOf(time.substring(10, 12));
          int sec = Integer.valueOf(time.substring(12));
          return LocalDateTime.of(year, month, day, hour, minute, sec);
      }

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: