Android Open Source - WeatherBar Util






From Project

Back to project page WeatherBar.

License

The source code is released under:

MIT License

If you think the Android project WeatherBar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cjbarker.wb;
//from ww w.j a v a  2s. c  o m
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Util {
  
  public static final String DEFAULT_DATE_FORMAT = "EEE MMM dd HH:mm zzz yyyy";
  
  public static final boolean isEmpty(String s) {
    if (s == null || s.trim().equals("")) {
      return true;
    }
    else {
      return false;
    }
  }
  
  public static String getLocalTime(long utc) {
    return getLocalTime(utc, DEFAULT_DATE_FORMAT);
  }
  
  /**
   * Converts the UTC to the local device's time zone.
   * 
   * @param utc    Epoch UTC time in milliseconds
   * @param timeFmt  Date/Time formatter
   * @return      Local time formatted in string 
   */
  public static String getLocalTime(long utc, String timeFmt) {
    timeFmt = (Util.isEmpty(timeFmt)) ? DEFAULT_DATE_FORMAT : timeFmt;
    Date utcDate = new Date(utc);
        SimpleDateFormat sdf = new SimpleDateFormat(timeFmt);
        sdf.setTimeZone(TimeZone.getDefault());
        return sdf.format(utcDate);
  }
}




Java Source Code List

com.cjbarker.wb.Main.java
com.cjbarker.wb.Notifier.java
com.cjbarker.wb.Prefs.java
com.cjbarker.wb.Util.java
com.cjbarker.wb.receiver.BatteryLevel.java
com.cjbarker.wb.receiver.Connection.java
com.cjbarker.wb.receiver.Screen.java
com.cjbarker.wb.ws.ClientRequestTest.java
com.cjbarker.wb.ws.ClientRequest.java
com.cjbarker.wb.ws.ClientResponse.java
com.cjbarker.wb.ws.OpenWeatherTest.java
com.cjbarker.wb.ws.OpenWeather.java
com.cjbarker.wb.ws.WeatherTest.java
com.cjbarker.wb.ws.Weather.java