Saturday, May 14, 2011

Subtract ndays from given Date

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
 
   /**
         * @param date
         * @param days
         * @param format
         * @return
         */
        public static String subtractDays(Date date, Integer days,String format) {

              
                String formattedDate = null;
                if(null != date && null != format){
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(date);
                        calendar.add(Calendar.DATE, -days);
                        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                        formattedDate=dateFormat.format(calendar.getTime());
                }
                return formattedDate;
        }

Monday, May 9, 2011

Adding ndays to given Date

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

       /**
         * @param date
         * @param days
         * @param format
         * @return

         */
        public static String addDays(Date date, Integer days, String format) {

                String formattedDate = null;
                if(null != date && null != format){
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(date);
                        calendar.add(Calendar.DATE, days);

                        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                        formattedDate = dateFormat.format(calendar.getTime());
                }
              
                return formattedDate;
        }
      


Saturday, February 26, 2011

What is a Framework?

Framework is special software that is capable of developing applications based on certain architecture having ability to generate certain logics of application development dynamically.