I'm doing a Android App and I want to do a variable that will see what day of the month it's (like, if the user is seeing the app in April 18, I'll have a variable that will see that it's day 18), and then I could do somenthing like this: if (today == 12){ ... } else if (today == 13) (...)
Asked
Active
Viewed 46 times
0
-
possible duplicate: http://stackoverflow.com/questions/17192776/get-value-of-day-month-form-date-object-in-android – onatm Mar 22 '15 at 00:32
2 Answers
0
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = format.parse(dtStart);
String today = (String) android.text.format.DateFormat.format("dd", date);

onatm
- 816
- 1
- 11
- 29
-
Okay, but is DTStart gives error, says it can not find the symbol, something. I'm newcomer it ... – Caroline Prudente Mar 28 '15 at 14:50
0
Calendar calendar = Calendar.getInstance(Locale.getDefault());
int dayOfMonth= calendar.get(DAY_OF_MONTH);

Gabe Sechan
- 90,003
- 9
- 87
- 127