Skip to content

How to create an RPM unit? #101

@samodadela

Description

@samodadela

Trying to create a new Unit<Frequency> RPM:

    @Test
    void myRpmUnit() throws IOException {
        Unit<Frequency> RPM = AlternateUnit.of(ONE.divide(MINUTE), "rpm").asType(Frequency.class);
        Quantity<Frequency> quantity = Quantities.getQuantity(60, RPM);
        assertThat(quantity.to(HERTZ).getValue().doubleValue()).isEqualTo(1.0);
    }

Specifying alternate as "rpm" I get:

java.lang.IllegalArgumentException: The parent unit: 1/min is not an unscaled SI unit

The RPM unit should have the symbol "rpm" (or "[rpm]"?) instead of 1/min. This should work in serialization and deserialization.

Tried using:

SimpleUnitFormat.getInstance().label(RPM, "rpm");

... but this works only partially: using toString() it writes "rpm", but using Jackson serialization we still get 1/min.

Using indriya 2.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions