|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.neilmoomey.util.Type
A common source of frustration for Java programmers is strongly typed variables.
I created this class to help solve that problem. Use this static class to easily
convert any Java type to any other Java type. Works with byte, double, float, int,
long, short, and String. It includes error checking to warn you when exceeding
the range of a data type. Just add the jar file to your CLASSPATH and follow this
example. Because it's a static class you don't need to create an object to use it.
Example of use:
import com.neilmoomey.util.Type; String s = "12345.6789"; float f = Type.toFloat(s);
Constructor Summary | |
Type()
|
Method Summary | |
static void |
main(java.lang.String[] args)
|
static byte |
toByte(double d)
double to byte |
static byte |
toByte(float f)
float to byte |
static byte |
toByte(int i)
int to byte |
static byte |
toByte(long l)
long to byte |
static byte |
toByte(short sh)
short to byte |
static byte |
toByte(java.lang.String s)
String to byte |
static double |
toDouble(byte b)
byte to double |
static double |
toDouble(float f)
float to double |
static double |
toDouble(int i)
int to double |
static double |
toDouble(long l)
long to double |
static double |
toDouble(short s)
short to double |
static double |
toDouble(java.lang.String s)
String to double |
static float |
toFloat(byte b)
byte to float |
static float |
toFloat(double d)
double to float |
static float |
toFloat(int i)
int to float |
static float |
toFloat(long l)
long to float |
static float |
toFloat(short sh)
short to float |
static float |
toFloat(java.lang.String s)
String to float |
static int |
toInt(byte b)
byte to int |
static int |
toInt(double d)
double to int |
static int |
toInt(float f)
float to int |
static int |
toInt(long l)
long to int |
static int |
toInt(short sh)
short to int |
static int |
toInt(java.lang.String s)
String to int |
static long |
toLong(byte b)
byte to Long |
static long |
toLong(double d)
double to Long |
static long |
toLong(float f)
float to Long |
static long |
toLong(int i)
int to Long |
static long |
toLong(short sh)
short to Long |
static long |
toLong(java.lang.String s)
String to Long |
static short |
toShort(byte b)
byte to Short |
static short |
toShort(double d)
double to Short |
static short |
toShort(float f)
float to Short |
static short |
toShort(int i)
int to Short |
static short |
toShort(long l)
long to Short |
static short |
toShort(java.lang.String s)
String to Short |
static java.lang.String |
toString(byte d)
byte to String |
static java.lang.String |
toString(double d)
double to String |
static java.lang.String |
toString(float f)
float to String |
static java.lang.String |
toString(int i)
int to String |
static java.lang.String |
toString(long l)
long to String |
static java.lang.String |
toString(short sh)
short to String |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Type()
Method Detail |
public static byte toByte(double d)
public static byte toByte(float f)
public static byte toByte(int i)
public static byte toByte(long l)
public static byte toByte(short sh)
public static byte toByte(java.lang.String s)
public static double toDouble(byte b)
public static double toDouble(float f)
public static double toDouble(int i)
public static double toDouble(long l)
public static double toDouble(short s)
public static double toDouble(java.lang.String s)
public static float toFloat(byte b)
public static float toFloat(double d)
public static float toFloat(int i)
public static float toFloat(long l)
public static float toFloat(short sh)
public static float toFloat(java.lang.String s)
public static int toInt(byte b)
public static int toInt(double d)
public static int toInt(float f)
public static int toInt(long l)
public static int toInt(short sh)
public static int toInt(java.lang.String s)
public static long toLong(byte b)
public static long toLong(double d)
public static long toLong(float f)
public static long toLong(int i)
public static long toLong(short sh)
public static long toLong(java.lang.String s)
public static short toShort(byte b)
public static short toShort(double d)
public static short toShort(float f)
public static short toShort(int i)
public static short toShort(long l)
public static short toShort(java.lang.String s)
public static java.lang.String toString(byte d)
public static java.lang.String toString(double d)
public static java.lang.String toString(float f)
public static java.lang.String toString(int i)
public static java.lang.String toString(long l)
public static java.lang.String toString(short sh)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |