trim Seconds from Date and return the Date - Android java.util

Android examples for java.util:Date

Description

trim Seconds from Date and return the Date

Demo Code


//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date trimSeconds(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);//from w  w  w  . j  ava2 s . co m
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.set(Calendar.SECOND, 0);
        return calendar.getTime();
    }
}

Related Tutorials