2013年10月31日星期四

Seeking a function , yyyy-mm-dd date format type subtraction short number of days to get a new date

For example 2010-01-05 obtained after adding 21 new date format for yyyy-mm-dd

Thank
------ Solution ---------------------------------- ----------
into milliseconds together, then format
------ Solution ----------------- ---------------------------

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = format.parse("2010-01-05");
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.DATE, 21);
        date = c.getTime();
        System.out.println(format.format(date));

------ Solution ------- -------------------------------------
Well , 2nd Floor positive solution . My project is a tool for these methods to the class to use.

没有评论:

发表评论