examples/iot-nirvana/common/src/main/java/com/google/cloud/demo/iot/nirvana/common/TemperatureUtils.java
/**
   * Generate the Cloud Datastore unique identifier for a city
   *
   * @param city City for which to generate the unique identifier
   * @return String containing the Cloud Datastore uiquer identifier
   * @throws FormatException
   */
Generate the Cloud Datastore unique identifier for a city
@param city City for which to generate the unique identifier
@return String containing the Cloud Datastore uiquer identifier
@throws FormatException
Generate the Cloud Datastore unique identifier for a city @param city City for which to generate the unique identifier @return String containing the Cloud Datastore uiquer identifier @throws FormatException
public static String generateCityKey(City city) throws FormatException {
    String key;
    String id = city.getLat() + "-" + city.getLng();
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      key = new String(Hex.encodeHex(md.digest(id.getBytes("UTF-8")))).toUpperCase();
    } catch (NoSuchAlgorithmException e) {
      String message = String.format(GENERATE_KEY_ERR, id, e.getMessage());
      throw new FormatException(message, e);
    } catch (UnsupportedEncodingException e) {
      String message = String.format(GENERATE_KEY_ERR, id, e.getMessage());
      throw new FormatException(message, e);
    }
    return key;
  }
public static String generateCityKey ( City city ) throws FormatException { String key ; String id = city . getLat ( ) + "-" + city . getLng ( ) ; try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; key = new String ( Hex . encodeHex ( md . digest ( id . getBytes ( "UTF-8" ) ) ) ) . toUpperCase ( ) ; } catch ( NoSuchAlgorithmException e ) { String message = String . format ( GENERATE_KEY_ERR , id , e . getMessage ( ) ) ; throw new FormatException ( message , e ) ; } catch ( UnsupportedEncodingException e ) { String message = String . format ( GENERATE_KEY_ERR , id , e . getMessage ( ) ) ; throw new FormatException ( message , e ) ; } return key ; }
Generate the Cloud Datastore unique identifier for a city
 @param city City for which to generate the unique identifier
 @return String containing the Cloud Datastore uiquer identifier
 @throws FormatException
Generate the Cloud Datastore unique identifier for a city @param city City for which to generate the unique identifier @return String containing the Cloud Datastore uiquer identifier @throws FormatException