-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
424: Scaling / multiplication is unable to apply factors to temperatures
Task-Url: unitsofmeasurement/indriya#424
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
console/impl/seshat/src/main/java/tech/uom/demo/impl/seshat/TemperatureConverterDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package tech.uom.demo.impl.seshat; | ||
|
||
import javax.measure.IncommensurableException; | ||
import javax.measure.UnconvertibleException; | ||
import javax.measure.UnitConverter; | ||
|
||
import tech.uom.seshat.UnitServices; | ||
|
||
public class TemperatureConverterDemo { | ||
|
||
public static void main(String[] args) { | ||
var format = UnitServices.current().getFormatService().getUnitFormat(); | ||
|
||
var source = format.parse("°C/10"); | ||
var dest = format.parse("°C"); | ||
UnitConverter converter = null; | ||
try { | ||
converter = source.getConverterToAny(dest); | ||
} catch (UnconvertibleException | IncommensurableException e) { | ||
e.printStackTrace(); | ||
} | ||
if (converter != null) { | ||
var converted = converter.convert(10); | ||
System.out.println(converted); | ||
} | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
console/java17/src/main/java/tech/uom/demo/java17/TemperatureConverterDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package tech.uom.demo.java17; | ||
|
||
import javax.measure.IncommensurableException; | ||
import javax.measure.UnconvertibleException; | ||
import javax.measure.UnitConverter; | ||
import javax.measure.spi.ServiceProvider; | ||
|
||
public class TemperatureConverterDemo { | ||
|
||
public static void main(String[] args) { | ||
var format = ServiceProvider.current().getFormatService().getUnitFormat(); | ||
|
||
var source = format.parse("°C/10"); | ||
var dest = format.parse("°C"); | ||
UnitConverter converter = null; | ||
try { | ||
converter = source.getConverterToAny(dest); | ||
} catch (UnconvertibleException | IncommensurableException e) { | ||
e.printStackTrace(); | ||
} | ||
if (converter != null) { | ||
var converted = converter.convert(10); | ||
System.out.println(converted); | ||
} | ||
} | ||
|
||
} |