Code example for TimeUnit

Methods: convert

0
    */ 
   protected static String getTimeZoneOffset() {
      Calendar mCalendar = new GregorianCalendar();
      TimeZone mTimeZone = mCalendar.getTimeZone();
      int mGMTOffset = mTimeZone.getOffset(mCalendar.getTimeInMillis());
      return Long.toString(TimeUnit.HOURS.convert(mGMTOffset, TimeUnit.MILLISECONDS));
   } 
    
   /** 
    * Create user agent string 
    *  
    * @param context Android application context 
    * @return user agent string  
    */ 
   protected static String getUserAgentString(Context context) {
      TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
      String device = android.os.Build.MANUFACTURER;
      if (device == null || device.equals("unknown")) {
         device = "Simulator";
      } 
      String model = android.os.Build.MODEL;