For example,the input parameters are 2011-01-01 and 2012-01-01,
and I want to parse this period day by day like 2011-01-01~2011-01-02, 2011-01-02~2011-01-03…
Finally,store them in a array of String?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For parsing the date from a string, I recommend using SimpleDateFormat.
That way you will obtain a Date object. Use the Date object to create a GregorianCalendar.
Then, you can use GregorianCalendar’s
addmethod to increase it one day at a time until you reach your end date.Here’s a code example:
This puts your dates in a list. You can convert it to an array like this: