Re: [Ikvm-developers] RE : RE: How to load Java Class in the .NET Application
Brought to you by:
jfrijters
|
From: Mark W. <mar...@gm...> - 2007-09-13 22:44:09
|
Hi,
I am converting a series of objects in C# to Java equivalents. Along the way
I am finding that some types don't convert directly and so have created a
helper class to do the conversions. Am I reinventing the wheel? Is there
something like this already done? If not, can you look (code below) at what
I have done and let me know if there is a more efficient method?
Thanks!
Mark
public static class JavaConvert
{
public static java.lang.Integer Int(int value)
{
return new java.lang.Integer(value);
}
public static int Int(java.lang.Integer value)
{
return int.Parse(value.toString());
}
public static bool Boolean(java.lang.Boolean value)
{
if (value == java.lang.Boolean.TRUE)
{
return true;
}
return false;
}
public static decimal Decimal(java.math.BigDecimal value)
{
return decimal.Parse(value.toString());
}
public static java.math.BigDecimal Decimal(decimal value)
{
return java.math.BigDecimal.valueOf((double)value);
}
public static DateTime Date(java.util.Date date)
{
return new DateTime(date.getYear(), date.getMonth(),
date.getDay(), date.getHours(), date.getMinutes(), date.getSeconds());
}
}
|