Author: amilas Date: Thu Dec 20 21:59:06 2007 New Revision: 606104 URL: http://svn.apache.org/viewvc?rev=606104&view=rev Log: fixed the issue Axis2-3414
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java?rev=606104&r1=606103&r2=606104&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java (original) +++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java Thu Dec 20 21:59:06 2007 @@ -106,7 +106,7 @@ int second = 0; int miliSecond = 0; int timeZoneOffSet = TimeZone.getDefault().getRawOffset(); - + int milliSecondPartLength = 0; if (source.length() >= 8) { if ((source.charAt(2) != ':' )|| (source.charAt(5) != ':')){ throw new RuntimeException("Invalid time format (" + source + ") having : s in wrong places"); @@ -114,6 +114,9 @@ hour = Integer.parseInt(source.substring(0, 2)); minite = Integer.parseInt(source.substring(3, 5)); second = Integer.parseInt(source.substring(6, 8)); + + + if (source.length() > 8) { String rest = source.substring(8); if (rest.startsWith(".")) { @@ -122,19 +125,21 @@ // this is in gmt time zone timeZoneOffSet = 0; miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("Z"))); - + milliSecondPartLength = rest.substring(1,rest.lastIndexOf("Z")).trim().length(); } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) { // this is given in a general time zione String timeOffSet = null; if (rest.lastIndexOf("+") > 0) { timeOffSet = rest.substring(rest.lastIndexOf("+") + 1); miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("+"))); + milliSecondPartLength = rest.substring(1, rest.lastIndexOf("+")).trim().length(); // we keep +1 or -1 to finally calculate the value timeZoneOffSet = 1; } else if (rest.lastIndexOf("-") > 0) { timeOffSet = rest.substring(rest.lastIndexOf("-") + 1); miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("-"))); + milliSecondPartLength = rest.substring(1, rest.lastIndexOf("-")).trim().length(); // we keep +1 or -1 to finally calculate the value timeZoneOffSet = -1; } @@ -149,6 +154,7 @@ } else { // i.e it does not have time zone miliSecond = Integer.parseInt(rest.substring(1)); + milliSecondPartLength = rest.substring(1).trim().length(); } } else { @@ -179,7 +185,17 @@ calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minite); calendar.set(Calendar.SECOND, second); + if (milliSecondPartLength != 3) { + // milisecond part represenst the fraction of the second so we have to + // find the fraction and multiply it by 1000. So if milisecond part + // has three digits nothing required + miliSecond = miliSecond * 1000; + for (int i = 0; i < milliSecondPartLength; i++) { + miliSecond = miliSecond / 10; + } + } calendar.set(Calendar.MILLISECOND, miliSecond); + calendar.set(Calendar.ZONE_OFFSET, timeZoneOffSet); return calendar; Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?rev=606104&r1=606103&r2=606104&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original) +++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Thu Dec 20 21:59:06 2007 @@ -873,6 +873,8 @@ minite = Integer.parseInt(source.substring(14, 16)); second = Integer.parseInt(source.substring(17, 19)); + int milliSecondPartLength = 0; + if (source.length() > 19) { String rest = source.substring(19); if (rest.startsWith(".")) { @@ -881,19 +883,21 @@ // this is in gmt time zone timeZoneOffSet = 0; miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("Z"))); - + milliSecondPartLength = rest.substring(1,rest.lastIndexOf("Z")).trim().length(); } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) { // this is given in a general time zione String timeOffSet = null; if (rest.lastIndexOf("+") > 0) { timeOffSet = rest.substring(rest.lastIndexOf("+") + 1); miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("+"))); + milliSecondPartLength = rest.substring(1, rest.lastIndexOf("+")).trim().length(); // we keep +1 or -1 to finally calculate the value timeZoneOffSet = 1; } else if (rest.lastIndexOf("-") > 0) { timeOffSet = rest.substring(rest.lastIndexOf("-") + 1); miliSecond = Integer.parseInt(rest.substring(1, rest.lastIndexOf("-"))); + milliSecondPartLength = rest.substring(1, rest.lastIndexOf("-")).trim().length(); // we keep +1 or -1 to finally calculate the value timeZoneOffSet = -1; } @@ -908,6 +912,7 @@ } else { // i.e it does not have time zone miliSecond = Integer.parseInt(rest.substring(1)); + milliSecondPartLength = rest.substring(1).trim().length(); } } else { @@ -938,6 +943,15 @@ calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minite); calendar.set(Calendar.SECOND, second); + if (milliSecondPartLength != 3){ + // milisecond part represenst the fraction of the second so we have to + // find the fraction and multiply it by 1000. So if milisecond part + // has three digits nothing required + miliSecond = miliSecond * 1000; + for (int i = 0; i < milliSecondPartLength; i++) { + miliSecond = miliSecond / 10; + } + } calendar.set(Calendar.MILLISECOND, miliSecond); calendar.set(Calendar.ZONE_OFFSET, timeZoneOffSet); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]