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

Muhammad Sodikin
2,815 PointsHelp, error on "org.json.JSONException: No value for Time"
I'm working on Building Weather App, and at stage Cleaning Up the Date and Time,
at CurrentWeather.java has
public String getFormattedTime() { SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); formatter.setTimeZone(TimeZone.getTimeZone(getTimeZone())); Date dateTime = new Date(getTime() * 1000); String timeString = formatter.format(dateTime);
return timeString;
}
and MainActivity.java has:
private CurrentWeather getCurrentDetails(String jsonData) throws JSONException { JSONObject forecast = new JSONObject(jsonData);
String timezone = forecast.getString("timezone");
Log.i(TAG, "From JSON: " + timezone);
JSONObject currently = forecast.getJSONObject("currently");
CurrentWeather currentWeather = new CurrentWeather();
currentWeather.setHumidity(currently.getDouble("humidity"));
currentWeather.setTime(currently.getLong("Time"));
currentWeather.setIcon(currently.getString("icon"));
currentWeather.setPrecipChance(currently.getDouble("precipProbability"));
currentWeather.setSummary(currently.getString("Summary"));
currentWeather.setTemperature(currently.getDouble("temperature"));
currentWeather.setTimeZone(timezone);
Log.d(TAG, currentWeather.getFormattedTime());
return currentWeather;
}
can't find the time value.
2 Answers

James Simshaw
28,738 PointsHello,
You're currently trying to get the time via currentWeather.setTime(currently.getLong("Time")); with the key Time. However, the key is "time".

Muhammad Sodikin
2,815 Pointsprojects...that sound lot of of them...haha, I will help u if I'm experts after this. Bye James.
Muhammad Sodikin
2,815 PointsMuhammad Sodikin
2,815 PointsThanks James Simshaw. Oh man, that really bad only upper case can give wrong result. Heheh. I get it right on the Log cat now. :D
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsYou're welcome. Case sensitivity causes all kinds of "fun" bugs to troubleshoot. Good luck with Android development.
Muhammad Sodikin
2,815 PointsMuhammad Sodikin
2,815 PointsOh yeah. Let's me buy you a drink, maybe. How do you doing on track now? Working on something new now aye?
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsI'm finished with what's currently available on the track and am working on a custom image cropping tool for one of my larger projects.