N
N
Neonoviiwolf2017-02-15 19:30:49
Java
Neonoviiwolf, 2017-02-15 19:30:49

Change Calendar date in android?

Good!
Is it possible to add or subtract N days in Calendar and have it give out what the number will be, of course, taking into account the month and high year? Or do you need to write everything in the old fashioned way with pens?
Now I get the date for today

TextView forDate = new TextView();
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String strDate = sdf.format(calendar.getTime());
        forDate.setText(forDate.getText() + " " + strDate);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Gapchenko, 2017-02-15
@Neonoviiwolf

calendar.add(Calendar.DAY_OF_YEAR, 10);
forDate.setText(calendar.getTime());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question