public float[] convert(final float[] input, float[] output) { output = converter.convert(input, output); for (int i = input.length; --i >= 0; ) { output[i] += offset; } return output; }
public double[] convert(final double[] input, double[] output) { output = converter.convert(input, output); for (int i = input.length; --i >= 0; ) { output[i] += offset; } return output; } }
public float[] convert(final float[] input, float[] output) { output = converter.convert(input, output); for (int i = input.length; --i >= 0; ) { output[i] += offset; } return output; }
public double[] convert(final double[] input, double[] output) { output = converter.convert(input, output); for (int i = input.length; --i >= 0; ) { output[i] += offset; } return output; } }
public double convert(final double amount) { return converter.convert(amount) + offset; }
public double convert(final double amount) { return converter.convert(amount) + offset; }
/** * Converts a numeric value from this unit to another unit. * * @param amount * The numeric value. * @param outputUnit * The unit to which to convert the numeric value. * @return The numeric value in the output unit. * @throws ConversionException * The units aren't convertible. */ public double convertTo(final double amount, final Unit outputUnit) throws ConversionException { return getConverterTo(outputUnit).convert(amount); }
/** * Converts a numeric value from this unit to another unit. * * @param amount * The numeric value. * @param outputUnit * The unit to which to convert the numeric value. * @return The numeric value in the output unit. * @throws ConversionException * The units aren't convertible. */ public double convertTo(final double amount, final Unit outputUnit) throws ConversionException { return getConverterTo(outputUnit).convert(amount); }
/** * Converts numeric values from this unit to another unit. * * @param input * The input numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @param output * The output numeric values. May be the same array as the input * values. * @return The numeric values in the output unit. * @throws ConversionException * The units aren't convertible. */ public float[] convertTo(final float[] input, final Unit outputUnit, final float[] output) throws ConversionException { return getConverterTo(outputUnit).convert(input, output); }
/** * Converts numeric values from this unit to another unit. * * @param input * The input numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @param output * The output numeric values. May be the same array as the input * values. * @return The numeric values in the output unit. * @throws ConversionException * The units aren't convertible. */ public double[] convertTo(final double[] input, final Unit outputUnit, final double[] output) throws ConversionException { return getConverterTo(outputUnit).convert(input, output); }
/** * Converts numeric values from this unit to another unit. * * @param input * The input numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @param output * The output numeric values. May be the same array as the input * values. * @return The numeric values in the output unit. * @throws ConversionException * The units aren't convertible. */ public float[] convertTo(final float[] input, final Unit outputUnit, final float[] output) throws ConversionException { return getConverterTo(outputUnit).convert(input, output); }
/** * Converts numeric values from this unit to another unit. * * @param input * The input numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @param output * The output numeric values. May be the same array as the input * values. * @return The numeric values in the output unit. * @throws ConversionException * The units aren't convertible. */ public double[] convertTo(final double[] input, final Unit outputUnit, final double[] output) throws ConversionException { return getConverterTo(outputUnit).convert(input, output); }
public static void main(String[] args) throws Exception { UnitFormat udunit = UnitFormatManager.instance(); //String text = "days since 2009-06-14 04:00:00"; String text2 = "days since 2009-06-14 04:00:00 +00:00"; Unit uu2 = udunit.parse(text2); System.out.printf("%s == %s %n", text2, uu2); String text = "days since 2009-06-14 04:00:00"; Unit uu = udunit.parse(text); System.out.printf("%s == %s %n", text, uu); Unit ref = udunit.parse("ms since 1970-01-01"); Converter converter = uu.getConverterTo(ref); DateFormatter formatter = new DateFormatter(); double val = converter.convert(1.0); Date d = new Date( (long) val); System.out.printf(" val=%f date=%s (%s)%n", 1.0, d, formatter.toDateTimeStringISO(d)); double val2 = converter.convert(2.0); Date d2 = new Date( (long) val2); System.out.printf(" val=%f date=%s (%s)%n", 2.0, d, formatter.toDateTimeStringISO(d2)); }
public static void main(String[] args) throws Exception { UnitFormat udunit = UnitFormatManager.instance(); //String text = "days since 2009-06-14 04:00:00"; String text2 = "days since 2009-06-14 04:00:00 +00:00"; Unit uu2 = udunit.parse(text2); System.out.printf("%s == %s %n", text2, uu2); String text = "days since 2009-06-14 04:00:00"; Unit uu = udunit.parse(text); System.out.printf("%s == %s %n", text, uu); Unit ref = udunit.parse("ms since 1970-01-01"); Converter converter = uu.getConverterTo(ref); DateFormatter formatter = new DateFormatter(); double val = converter.convert(1.0); Date d = new Date( (long) val); System.out.printf(" val=%f date=%s (%s)%n", 1.0, d, formatter.toDateTimeStringISO(d)); double val2 = converter.convert(2.0); Date d2 = new Date( (long) val2); System.out.printf(" val=%f date=%s (%s)%n", 2.0, d, formatter.toDateTimeStringISO(d2)); }
public static void main(String[] args) throws Exception { UnitFormat udunit = UnitFormatManager.instance(); //String text = "days since 2009-06-14 04:00:00"; String text2 = "days since 2009-06-14 04:00:00 +00:00"; Unit uu2 = udunit.parse(text2); System.out.printf("%s == %s %n", text2, uu2); String text = "days since 2009-06-14 04:00:00"; Unit uu = udunit.parse(text); System.out.printf("%s == %s %n", text, uu); Unit ref = udunit.parse("ms since 1970-01-01"); Converter converter = uu.getConverterTo(ref); DateFormatter formatter = new DateFormatter(); double val = converter.convert(1.0); Date d = new Date((long) val); System.out.printf(" val=%f date=%s (%s)%n", 1.0, d, formatter.toDateTimeStringISO(d)); double val2 = converter.convert(2.0); Date d2 = new Date((long) val2); System.out.printf(" val=%f date=%s (%s)%n", 2.0, d, formatter.toDateTimeStringISO(d2)); }
Unit kelvin = format.parse("K"); System.out.println("celsius.getConverterTo(kelvin).convert(0) = \"" + celsius.getConverterTo(kelvin).convert(0) + '"'); System.out .println("kelvin.getConverterTo(celsius).convert(273.15) = \"" + kelvin.getConverterTo(celsius).convert(273.15) + '"'); myAssert(kelvin.isCompatible(celsius)); myAssert(!kelvin.equals(celsius)); final Unit minute = format.parse("min"); System.out.println("second.getConverterTo(minute).convert(60) = \"" + second.getConverterTo(minute).convert(60) + '"'); System.out.println("minute.getConverterTo(second).convert(1) = \"" + minute.getConverterTo(second).convert(1) + '"'); final Unit mixingRatio = format.parse("g/kg").clone( UnitName.newUnitName("mixing ratio"));
Unit kelvin = format.parse("K"); System.out.println("celsius.getConverterTo(kelvin).convert(0) = \"" + celsius.getConverterTo(kelvin).convert(0) + '"'); System.out .println("kelvin.getConverterTo(celsius).convert(273.15) = \"" + kelvin.getConverterTo(celsius).convert(273.15) + '"'); myAssert(kelvin.isCompatible(celsius)); myAssert(!kelvin.equals(celsius)); final Unit minute = format.parse("min"); System.out.println("second.getConverterTo(minute).convert(60) = \"" + second.getConverterTo(minute).convert(60) + '"'); System.out.println("minute.getConverterTo(second).convert(1) = \"" + minute.getConverterTo(second).convert(1) + '"'); final Unit mixingRatio = format.parse("g/kg").clone( UnitName.newUnitName("mixing ratio"));