cdm/src/main/java/ucar/nc2/units/SimpleUnit.java
static public boolean isCompatible(String unitString1, String unitString2) {
    Unit uu1, uu2;
    try {
      UnitFormat format = UnitFormatManager.instance();
      uu1 = format.parse(unitString1);
    } catch (Exception e) {
      if (debugParse) System.out.println("Parse " + unitString1 + " got Exception1 " + e);
      return false;
    }

    try {
      UnitFormat format = UnitFormatManager.instance();
      uu2 = format.parse(unitString2);
    } catch (Exception e) {
      if (debugParse) System.out.println("Parse " + unitString2 + " got Exception2 " + e);
      return false;
    }

    //System.out.println("udunits isCompatible "+ uu1+ " "+ uu2);
    return uu1.isCompatible(uu2);
  }
static public boolean isCompatible(String unitString1, String unitString2) {
    Unit uu1, uu2;
    try {
      UnitFormat format = UnitFormatManager.instance();
      uu1 = format.parse(unitString1);
    } catch (Exception e) {
      if (debugParse) System.out.println("Parse " + unitString1 + " got Exception1 " + e);
      return false;
    }

    try {
      UnitFormat format = UnitFormatManager.instance();
      uu2 = format.parse(unitString2);
    } catch (Exception e) {
      if (debugParse) System.out.println("Parse " + unitString2 + " got Exception2 " + e);
      return false;
    }

    //System.out.println("udunits isCompatible "+ uu1+ " "+ uu2);
    return uu1.isCompatible(uu2);
  }
static public boolean isCompatible ( String unitString1 , String unitString2 ) { Unit uu1 , uu2 ; try { UnitFormat format = UnitFormatManager . instance ( ) ; uu1 = format . parse ( unitString1 ) ; } catch ( Exception e ) { if ( debugParse ) System . out . println ( "Parse " + unitString1 + " got Exception1 " + e ) ; return false ; } try { UnitFormat format = UnitFormatManager . instance ( ) ; uu2 = format . parse ( unitString2 ) ; } catch ( Exception e ) { if ( debugParse ) System . out . println ( "Parse " + unitString2 + " got Exception2 " + e ) ; return false ; } //System.out.println("udunits isCompatible "+ uu1+ " "+ uu2); return uu1 . isCompatible ( uu2 ) ; }
Return true if unitString1 is compatible to unitString2, meaning one can be converted to the other.
If either unit string is illegal, return false.

@param unitString1 compare this unit
@param unitString2 compare this unit
@return true if the 2 units are compatible
Return true if unitString1 is compatible to unitString2 meaning one can be converted to the other . If either unit string is illegal return false .