Created
February 12, 2020 11:55
-
-
Save rahulshah456/4bfd71696f8a9258c2bc6933c1a16f85 to your computer and use it in GitHub Desktop.
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
| /** Basic ISO Date Format for Simple Date Format */ | |
| public static final String ISO_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; | |
| SimpleDateFormat format = new SimpleDateFormat(ISO_DATE_FORMAT,Locale.ENGLISH); | |
| String dateTimeString = format.format(new Date()); | |
| Log.d(TAG, "onCreate: dateTimeString = " + dateTimeString); | |
| try { | |
| Date date = format.parse(dateTimeString); | |
| if (date!=null){ | |
| Calendar calendar = dateToCalendar(date); | |
| String month = calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault()); | |
| Log.d(TAG, "onCreate: MonthOfYear = " + calendar.get(Calendar.MONTH)); | |
| Log.d(TAG, "onCreate: MonthOfYear = " + month); | |
| Log.d(TAG, "onCreate: DayOfYear = " + calendar.get(Calendar.DAY_OF_MONTH)); | |
| Log.d(TAG, "onCreate: Year = " + calendar.get(Calendar.YEAR)); | |
| } | |
| } catch (ParseException e) { | |
| Log.d(TAG, "onCreate: ",e); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment