I know this is an old post, but.. i'm going to post the answer anyways, maybe it'll be useful to someone
In order to define a custom unit in JScience, you have to extend the class SystemOfUnits
and define here all your custom units.
Check the exemple below (i'm defining the unit for ACREs)
public class MyUnits extends SystemOfUnits
{
private static HashSet<Unit<?>> UNITS = new HashSet();
private static final MyUnits INSTANCE = new MyUnits();
public static final Unit<Area> ACRE = myUnits((SI.METER.pow(2)).times(4046.8564224).asType(Area.class));
public static MyUnits getInstance()
{
return INSTANCE;
}
@Override
public Set<Unit<?>> getUnits()
{
return Collections.unmodifiableSet(UNITS);
}
private static <U extends Unit<?>> U myUnits(U unit)
{
UNITS.add(unit);
return unit;
}
}