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 trialMike Hansen
Python Web Development Techdegree Student 3,419 PointsThe time is shown as e.m. instead of AM ?
I wrote the little time scripts and it shows the time, but it shows e.m. instead of AM?
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;
}
What is the mistake?
5 Answers
Mike Hansen
Python Web Development Techdegree Student 3,419 PointsHey James! So i wrote what you told me and it now says: The time is 12:56 e.m.
It's kinda weird and i checked for spelling fails but can't seem to find any..
Harry James
14,780 PointsHey Mike!
That's unusual. Can you please try temporarily removing the .setTimeZone() method and seeing whether that makes the time say a.m. instead?
Speak again soon! :)
Mike Hansen
Python Web Development Techdegree Student 3,419 PointsHey again James, i removed the: formatter.setTimeZone(TimeZone.getTimeZone(getTimeZone())); and it's still e.m. ... i really don't know what to do here?
Mike Hansen
Python Web Development Techdegree Student 3,419 PointsHey again James, i removed the: formatter.setTimeZone(TimeZone.getTimeZone(getTimeZone())); and it's still e.m. ... i really don't know what to do here?
Harry James
14,780 PointsHey again Mike,
Just posting this to let you know that I will put a new answer up in the next couple days (Sunday at the latest) - I'm currently busy preparing for an interview :)
Harry James
14,780 PointsHey again Mike,
Could I ask that you provide your project files here. This will allow me to view all of the code you have written and see the problem you are having for myself. I'll then be able to trace down where the problem lies.
To do this, right-click on your project in Android Studio and press Show in Explorer. Then, upload your project directory into a service like Google Drive, Mega.co.nz, OneDrive or another service of your choice.
Then, share the project via a URL and I'll download it and try and reproduce your problem, then find a solution.
IMPORTANT:
WHEN SENDING ACROSS YOUR PROJECT - REPLACE YOUR FORECAST.IO API KEY WITH "###" - I WILL REPLACE IT WITH MY OWN KEY FOR TESTING.
Mike Hansen
Python Web Development Techdegree Student 3,419 PointsHey harry, my computer chrashed and restarted to Fabric so i lost it all :( i'm gonna remake to whole app soon when i have time and see if it's fixed else i'm gonna write here again.
Harry James
14,780 PointsHey Mike!
That sucks :'(
Just also wanted to let you know that you can Download the Project Files on each video under the Downloads section if you don't want to restart the project from scratch.
Let me know if you run into the issue again and I'll make sure to look into it! Sadly, I haven't been able to reproduce it on my side.
Mike Hansen
Python Web Development Techdegree Student 3,419 Pointsi will remmember that :) and i hope that i won't run into it again!
Harry James
14,780 PointsHarry James
14,780 PointsHey Mike!
Could you please try adding in this line of code:
Log.d("MainActivity", "The time is: " + timeString);
After you initialize the timeString variable.
Then, run your app and check the Logcat to see what the timeString variable is equal to and post the result back here.
This will let us know whether the issue is with your font or with the program.
Speak to you soon! :)