POI is now on JDK 1.6, so remove 1.5 workaround

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1574049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-03-04 11:57:44 +00:00
parent d54e65c94e
commit f6a5959788

View File

@ -894,38 +894,20 @@ public class DataFormatter {
} }
/** /**
* Enables excel style rounding mode (round half up) * Enables excel style rounding mode (round half up) on the
* on the Decimal Format if possible. * Decimal Format given.
* This will work for Java 1.6, but isn't possible
* on Java 1.5.
*/ */
public static void setExcelStyleRoundingMode(DecimalFormat format) { public static void setExcelStyleRoundingMode(DecimalFormat format) {
setExcelStyleRoundingMode(format, RoundingMode.HALF_UP); setExcelStyleRoundingMode(format, RoundingMode.HALF_UP);
} }
/** /**
* Enables custom rounding mode * Enables custom rounding mode on the given Decimal Format.
* on the Decimal Format if possible.
* This will work for Java 1.6, but isn't possible
* on Java 1.5.
* @param format DecimalFormat * @param format DecimalFormat
* @param roundingMode RoundingMode * @param roundingMode RoundingMode
*/ */
public static void setExcelStyleRoundingMode(DecimalFormat format, RoundingMode roundingMode) { public static void setExcelStyleRoundingMode(DecimalFormat format, RoundingMode roundingMode) {
try { format.setRoundingMode(roundingMode);
Method srm = format.getClass().getMethod("setRoundingMode", RoundingMode.class);
srm.invoke(format, roundingMode);
} catch(NoSuchMethodException e) {
// Java 1.5
} catch(IllegalAccessException iae) {
// Shouldn't happen
throw new RuntimeException("Unable to set rounding mode", iae);
} catch(InvocationTargetException ite) {
// Shouldn't happen
throw new RuntimeException("Unable to set rounding mode", ite);
} catch(SecurityException se) {
// Not much we can do here
}
} }
/** /**