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

java.lang.NumberFormatException: For input string: "O4701301910" and not for "06891960012"

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0_80"
      Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Jonas-iMac.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      When I run this code:
      public static void main(String[] args) {
      System.out.println(Long.valueOf("06891960012"));
      System.out.println(Long.valueOf("O4701301910"));
      }

      Below the console output:
      6891960012
      Exception in thread "main" java.lang.NumberFormatException: For input string: "O4701301910"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:6)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Convert string "O4701301910" for Long

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Output 4701301910
      ACTUAL -
      java.lang.NumberFormatException: For input string: "O4701301910"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      public class Main {

      public static void main(String[] args) {
      System.out.println(Long.valueOf("06891960012"));
      System.out.println(Long.valueOf("O4701301910"));
      }
      }

      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: