public static Field getUnsignedShortField(byte[] bytes) {
    Utils.checkState(bytes.length == 2, "2 bytes required to parse an unsigned short");
    final short shortVal = Shorts.fromByteArray(bytes);
    int intVal = shortVal >= 0 ? shortVal : 0x10000 + shortVal;
    return Field.create(intVal);
  }
public static Field getUnsignedShortField(byte[] bytes) {
    Utils.checkState(bytes.length == 2, "2 bytes required to parse an unsigned short");
    final short shortVal = Shorts.fromByteArray(bytes);
    int intVal = shortVal >= 0 ? shortVal : 0x10000 + shortVal;
    return Field.create(intVal);
  }
public static Field getUnsignedShortField ( byte [ ] bytes ) { Utils . checkState ( bytes . length == 2 , "2 bytes required to parse an unsigned short" ) ; final short shortVal = Shorts . fromByteArray ( bytes ) ; int intVal = shortVal >= 0 ? shortVal : 0x10000 + shortVal ; return Field . create ( intVal ) ; }
Adapted from https://stackoverflow.com/a/7932774/375670
@param bytes the raw bytes to interpret as an unsigned short
@return an INTEGER field with the unsigned short value
Adapted from https : // stackoverflow . com / a / 7932774 / 375670