JSR 275 - Units, Percent per second

Posted by I82Much on Stack Overflow See other posts from Stack Overflow or by I82Much
Published on 2010-05-24T13:18:46Z Indexed on 2010/05/24 13:21 UTC
Read the original article Hit count: 272

Hi all,

I need to represent the unit of Percent per second using the JScience.org's JSR 275 units and measures implementation. I am trying to do to the following:

Unit<Dimensionless> PERCENT_PER_SECOND = NonSI.PERCENT.divide(Si.SECOND).asType(Dimensionless.class)

but I am getting a ClassCastException when I try to do that.

The following works, but I'm not sure if there's a better way:

public interface PercentOverTime extends Quantity {}
public static Unit<PercentOverTime> PERCENT_PER_SECOND = new BaseUnit<PercentOverTime>("%/s");

Any thoughts? The closest I could find to this is the question on Cooking Measurements (which is how I saw how to define your own units).

© Stack Overflow or respective owner

Related posts about java

Related posts about units-of-measurement