JDK-4253773 : java.lang.Boolean needs a parseBoolean(string) method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.2.2,1.3.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-07-13
  • Updated: 2017-05-16
  • Resolved: 2003-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Duplicate :  
Description

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)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b07
14-06-2004

WORK AROUND Name: skT88420 Date: 07/13/99 boolean myBoolean; String myString = "true"; myBoolean = Boolean.toString(myString).booleanValue(); /* it would be cleaner to have * myBoolean = Boolean.parseBoolean(myString); */ ======================================================================
11-06-2004

EVALUATION A target for Tiger. ###@###.### 2002-03-12
12-03-2002