Unit of measure class for mass in java
For just Mass, I would define some constants.

public final static Mass kg = new Mass(1);
public final static Mass lb = new Mass(1/2.2, kg);
public final static Mass oz = new Mass(1/16.0, lb);


And define your conversions with the “to” (and “from”) units passed in.

public double in(Mass unit) {
    return mass / unit.mass;
}

public static double convert(double quantity, Mass from, Mass to) {
    return quantity * from.mass / to.mass;
}


Of course, you’d need to remove the “set” members, and make the Mass a constant value class.

private final double mass;

public Mass(double kg) {
    mass =  kg;
}

public Mass(double quantity, Mass unit) {
    mass = quantity * unit.mass;
}


New units just mean defining new class constants.

Mass weight = new Mass( 100, Mass.kg );
double pounds = weight.in( Mass.lb );
double ounces = weight.in( Mass.oz );


As described in the comments, you could expand this to a complete unit calculator, if you tracked the power of each unit dimension in the quantity class.