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
Ashley Ewen
Courses Plus Student 1,194 PointsDate/Time returned is incorrect in Stormy after implementing location services
Hi all,
I have been working on getting Stormy location aware (like so many other people) however I'm have an issue. When i get the current location or refresh to get a new location, the 'time' being displayed i.e. as part of the "updateDisplay()" method.
"mTimeLabel.setText("At " + current.getFormattedTime() + " it will be");"
Ive checked the JSON data from forecast.io and what is being displayed matches JSON but its as if the timezone adjustments isn't being taking into account.
Time works correctly when i'm not using the google location services. Has anyone else had this issue? I haven't changed any code related to the JSON data.
Note: My timezone is Australia so im wondering if there is something i need to do with the SimpleDateFormat method.....
2 Answers
Ashley Ewen
Courses Plus Student 1,194 PointsThanks for the reply, i have fixed the issue. I was modifying the setTimezone() method initially to remove the country and '/' before the city name and it was causing problems.
I have moved the code to the updateDisplay() method and created a new locationlabel member variable to modify how its displayed. My code is below, hopefully it helps others with this issue :)
private void updateDisplay() {
........
//JSON object returns "Country/City", this removes string data from '/' backwards. Only city name displayed
mLocationLabel.setText(current.getTimezone().substring(current.getTimezone().lastIndexOf('/')+1));
}
prakashregmi
3,474 PointsI think it depends on the value of latitude and longitude variables. I tried changing the latitude value to -33.8683 and longitude value to 151.2086 and I got the exact time, weather(in Fahrenheit) of Sydney. I think you have to change the latitude and longitude value according to the city you live.