Friday 7 April 2017

Get Time updated with an interval

17:19:00 Posted by Kumanan ,

public static String getUpdateTime(String updatedTime, int minute) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        long t = c.getTimeInMillis();
        Date date = null;
        try {
            date = df.parse(updatedTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long millis = date.getTime();

        Date afterAddingTenMins = new Date(millis + (minute * ONE_MINUTE_IN_MILLIS));
        String formattedDate = df.format(afterAddingTenMins);

        return formattedDate;
    }