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

Code not compiling after plugging in values from model

The following lines of code throw a warning during build and this causes the app to crash on startup

SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); formatter.setTimeZone(TimeZone.getTimeZone(getTimeZone()));

the warning is as follows

To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.

Is this a version issue? or am i doing something wrong?

Getting the same, but that is just a warning, you can safely ignore it. It should not be the cause of the crash.

2 Answers

Slava Fleer
Slava Fleer
6,086 Points

Maybe need clean and rebuild the project ?

Justin Bettencourt
Justin Bettencourt
4,305 Points

I was having the same issue and found the solution in another post: https://teamtreehouse.com/forum/stormy-timezone-nullpointerexception-id-null

In the MainActivity.java class, in the method CurrentWeather(). At the end of the method where we "return new CurrentWeather();" is incorrect, and should instead be "return currentWeather;". This fixed both the crash I was having, as well as the temperature not showing properly.