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!
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

Charles Romeo
1,042 PointsDate Formatter/ getTimeZone() not working correctly?
I have manually changed the longitude and latitude to reflect my current city. Everyone is coming in from forecast.io just perfectly. Yet, my time is very very off. It is currently 2:00pm where I am. The app claims it is 8:00pm. Sometimes it is closer, sometimes it is further. Just a little bit ago it said it was 4:12am. Yet it was 1:30 something. Where in the world is it 4:12 when it is 1:30 here? That is impossible (if you understand what I am trying to say there).
I have tripled checked everything code wise. I am brand new to this stuff. Any help?
Ben said in the video he saw the getTimeZone in main activity, but where? Please help me figure this out. It is my last step.
my code is as follows...
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; }

Charles Romeo
1,042 PointsLogCat claims i am under the America/Chicago timezone (which is correct) and is offset by -6 hours. Again. correct. Yet my time doesn't show up correctly?.
Charles Romeo
1,042 PointsCharles Romeo
1,042 PointsJust figured out that I am currently under GMT. For now at least.