-
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.
Task-Url: #113
- Loading branch information
Showing
8 changed files
with
119 additions
and
98 deletions.
There are no files selected for viewing
32 changes: 23 additions & 9 deletions
32
...le/java17/src/main/java/tech/uom/demo/java17/format/TemperatureQuantityConverterDemo.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 |
---|---|---|
@@ -1,28 +1,42 @@ | ||
package tech.uom.demo.java17.format; | ||
|
||
import static javax.measure.Quantity.Scale.ABSOLUTE; | ||
import static javax.measure.Quantity.Scale.*; | ||
import static tech.units.indriya.unit.Units.CELSIUS; | ||
|
||
import java.text.NumberFormat; | ||
|
||
import javax.measure.Quantity; | ||
import javax.measure.Unit; | ||
import javax.measure.quantity.Temperature; | ||
|
||
import tech.units.indriya.quantity.Quantities; | ||
import tech.units.indriya.format.EBNFUnitFormat; | ||
import tech.units.indriya.format.NumberDelimiterQuantityFormat; | ||
import tech.units.indriya.format.SimpleUnitFormat; | ||
import tech.units.indriya.quantity.Quantities; | ||
|
||
public class TemperatureQuantityConverterDemo { | ||
public static void main(String[] args) { | ||
//Unit<Temperature> cByTen = CELSIUS.divide(10); | ||
//var format = EBNFUnitFormat.getInstance(); | ||
var format = SimpleUnitFormat.getInstance(); | ||
Unit<Temperature> cByTen = format.parse("°C/10").asType(Temperature.class); | ||
Quantity<Temperature> absT = Quantities.getQuantity(0d, CELSIUS, ABSOLUTE); | ||
Quantity<Temperature> absT2 = Quantities.getQuantity(0d, CELSIUS, ABSOLUTE); | ||
Quantity<Temperature> absT3 = Quantities.getQuantity(0d, cByTen, ABSOLUTE); | ||
Quantity<Temperature> sum = absT.add(absT2); | ||
System.out.println(sum); | ||
System.out.println(absT3); | ||
System.out.println(sum.to(cByTen)); | ||
Quantity<Temperature> relT = Quantities.getQuantity(0d, CELSIUS, RELATIVE); | ||
Quantity<Temperature> relT2 = Quantities.getQuantity(0d, CELSIUS, RELATIVE); | ||
Quantity<Temperature> sumAbs = absT.add(absT2); | ||
Quantity<Temperature> sumRel = relT.add(relT2); | ||
System.out.println(sumAbs); | ||
System.out.println(sumRel); | ||
System.out.printf("Abs: %s%s", sumAbs.to(cByTen), System.lineSeparator()); | ||
System.out.printf("Rel: %s%s", sumRel.to(cByTen), System.lineSeparator()); | ||
|
||
var qformat = NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), format); | ||
var source = format.parse("K/10"); | ||
var intermediary = format.parse("K"); | ||
|
||
var qs = Quantities.getQuantity(10, source, ABSOLUTE); | ||
System.out.println(qformat.format(qs)); | ||
var qs3 = Quantities.getQuantity(1, intermediary, ABSOLUTE); | ||
var qs4 = qs.multiply(qs3); | ||
System.out.println(qformat.format(qs4)); | ||
} | ||
} |
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
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
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
6 changes: 4 additions & 2 deletions
6
lang/valhalla/src/main/java/tech/uom/demo/valhalla/ValhallaDemo.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
11 changes: 8 additions & 3 deletions
11
lang/valhalla/src/test/java/tech/uom/demo/valhalla/EqualityTest.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
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
Oops, something went wrong.