Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Hooking Up the Model to the View Setting the Weather Icon

George Brandt
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
George Brandt
Python Development Techdegree Graduate 9,649 Points

App crashes

04-30 13:18:40.462 24370-24370/com.georgesapps.stormy E/AndroidRuntime: FATAL EXCEPTION: main Process: com.georgesapps.stormy, PID: 24370 java.lang.NullPointerException: id == null at java.util.TimeZone.getTimeZone(TimeZone.java:556) at com.georgesapps.stormy.CurrentWeather.getFormattedTime(CurrentWeather.java:76) at com.georgesapps.stormy.MainActivity.updateDisplay(MainActivity.java:109) at com.georgesapps.stormy.MainActivity.access$200(MainActivity.java:28) at com.georgesapps.stormy.MainActivity$1$1.run(MainActivity.java:83) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

George Brandt
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
George Brandt
Python Development Techdegree Graduate 9,649 Points

public String getFormattedTime(){

    SimpleDateFormat formatter = new SimpleDateFormat("h:mm: a");

    formatter.setTimeZone(TimeZone.getTimeZone(getmTimeZone()));

    Date dateTime = new Date(getmTime() * 1000);

    String timeString = formatter.format(dateTime);

    return timeString;
George Brandt
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
George Brandt
Python Development Techdegree Graduate 9,649 Points

private void updateDisplay() {

    mTemperatureLabel.setText(mCurrentWeather.getmTemperature() + "");

    mTimeLabel.setText("At " + mCurrentWeather.getFormattedTime() + "it will be");

    mHumidityValue.setText(mCurrentWeather.getmHumidity() + "");

    mPrecipValue.setText(mCurrentWeather.getmPrecipChance() + "%");

    mSummaryLabel.setText(mCurrentWeather.getmSummary());