Source Code : Convert an integer to an HTML RGB value
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Convert an integer to an HTML RGB value
/*******************************************************************************
* Copyright (c) 2004 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
/**
* Collection of string utilities.
*
*/
public class StringUtil
{
/**
* Convert an integer to an HTML RGB value. The result is of the form
* #hhhhhh. The input rgb integer value will be clipped into the range 0 ~
* 0xFFFFFF
*
* @param rgb
* the integer RGB value
* @return the value as an HTML RGB string
*/
public static String toRgbText( int rgb )
{
// clip input value.
if ( rgb > 0xFFFFFF )
rgb = 0xFFFFFF;
if ( rgb < 0 )
rgb = 0;
String str = "000000" + Integer.toHexString( rgb ); //$NON-NLS-1$
return "#" + str.substring( str.length( ) - 6 ); //$NON-NLS-1$
}
}
Thank with us