United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4253773 : java.lang.Boolean needs a parseBoolean(string) method

Details
Type:
Enhancement
Submit Date:
1999-07-13
Status:
Resolved
Updated Date:
2003-05-16
Project Name:
JDK
Resolved Date:
2003-05-16
Component:
core-libs
OS:
windows_nt,generic
Sub-Component:
java.lang
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.2,1.3.1
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:

Sub Tasks

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
EVALUATION

A target for Tiger.
###@###.### 2002-03-12
                                     
2002-03-12
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); 
 */
======================================================================
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b07


                                     
2004-06-14



Hardware and Software, Engineered to Work Together