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

java.lang.Boolean needs a parseBoolean(string) method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.2.2, 1.3.1
    • core-libs
    • tiger
    • generic, x86
    • generic, windows_nt



      Name: skT88420 Date: 07/13/99


      java.lang.boolean currently has no method to directly convert from a string to a (primitive) boolean. It would be helpful to have a parseBoolean(string) method, similar to the parseInt(string) method provided in java.lang.Integer and the parseLong(string) method provided in java.lang.Long(string).
      (Review ID: 85546)
      ======================================================================

      Name: rmT116609 Date: 08/21/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      J2SE has Byte.parseByte, Double.parseDouble, Float.parseFloat, Integer.parseInt, Long.parseLong, and Short.parseShort, but no Boolean.parseBoolean. It is tedious and ugly to have to write code that looks like this:

          boolean bUseDate = Boolean.valueOf(strUseDate).booleanValue();

      when what you really want to do is this:

          boolean bUseDate = Boolean.parseBoolean(strUseDate);

      Boolean.parseBoolean should look like this:

      public static boolean parseBoolean(String s);

      Parses the string argument as a boolean. The Boolean returned represents the
      value true if the string argument is not null and is equal, ignoring case,
      to the string "true".

      Example: Boolean.parseBoolean("True") returns true.
      Example: Boolean.parseBoolean("yes") returns false.

      Parameters:
          s - a string.
      Returns:
          the boolean primitive represented by the string.
      (Review ID: 130392)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: