<strong>!_NEWLINE_!Error processing octal integer Color codes passed as parameters.!_NEWLINE_!</strong>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Allan_Kamau
Posted On:   Monday, August 27, 2001 05:55 AM

I am trying to pass Color values like 0xeeeeee or 0xEEEEEE as values to parameters from a get post (in the header). However I am unable to process the value into an integer value which is a requirement for the Color(int) constructor I will use to create the new color based on this passed value, I have tried int colorvalue=Integer.parseInt(req.getParameterValue("ColorParameter")); It is throwing an NumberFormatException which I am printing displaying the actual value of the parameter e.g NumberFormatException : 0xEEEEEE Could anyone kindly tell me how to process t   More>>


I am trying to pass Color values like 0xeeeeee or 0xEEEEEE as values to parameters from a get post (in the header). However I am unable to process the value into an integer value which is a requirement for the Color(int) constructor I will use to create the new color based on this passed value, I have tried





int colorvalue=Integer.parseInt(req.getParameterValue("ColorParameter"));





It is throwing an NumberFormatException which I am printing displaying the actual value of the parameter e.g





NumberFormatException : 0xEEEEEE




Could anyone kindly tell me how to process this value of the parameter into an integer value so I may pass it to the Color(int) constructor.
Thanks.

   <<Less

Re: <strong>!_NEWLINE_!Error processing octal integer Color codes passed as parameters.!_NEWLINE_!</strong>

Posted By:   Bogdan_Sheptunov  
Posted On:   Monday, August 27, 2001 06:39 AM

The keyword for you is Integer.decode(). Here is some sample code:




String hexValue = "0x11";


Integer decodedInt = null;


int result = 0;


try


{


    decodedInt = Integer.decode(hexValue);


}


catch (NumberFormatException e)


{


    System.out.println("Cannot convert '" + hexValue + "': " + e.getMessage());


}


if (decodedInt != null)


{


    result = decodedInt.intValue();


}


System.out.println(result); // prints out 17
About | Sitemap | Contact