Created
June 20, 2013 10:51
-
-
Save scruffyfox/5821823 to your computer and use it in GitHub Desktop.
Get time/date string based on user's set date/time configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GregorianCalendar cal = new GregorianCalendar(); | |
| GregorianCalendar todayDate = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE)); | |
| long startDate = todayDate.getTimeInMillis(); | |
| DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(c); | |
| DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(c); | |
| String time = ""; | |
| if (getPostDate() > startDate) | |
| { | |
| time = timeFormat.format(new Date(getPostDate())); | |
| } | |
| else | |
| { | |
| time = dateFormat.format(new Date(getPostDate())); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment