Reputation: 111
Here is my data structure which is all the days in february. How can i make the day today to be equal from the data for example today is 22 = 21. enter image description here
Here is my current code
SimpleDateFormat day = new SimpleDateFormat("dd");
Calendar calendar = Calendar.getInstance();
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
ArrayList<String> allDays = new ArrayList<>();
for(int i = 0; i < daysInMonth; i++){
allDays.add(day.format(calendar.getTime()));
}
Upvotes: 1
Views: 381
Reputation: 1118
try with this code,
SimpleDateFormat day = new SimpleDateFormat("dd");
Calendar calendar = Calendar.getInstance();
List<String> allDays = new ArrayList<>();
for(int i = 0; i < calendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++){
allDays.add(i, String.valueOf(i+1));
}
Upvotes: 1