Here you can find the source of stripToMinutes(java.sql.Timestamp timestamp)
Parameter | Description |
---|---|
timestamp | The timestamp value to be strip to minutes |
public static java.sql.Timestamp stripToMinutes(java.sql.Timestamp timestamp)
//package com.java2s; /*//from w w w . ja v a2s. c om * @(#)Utility.java * * Copyright (c) 2003 DCIVision Ltd * All rights reserved. * * This software is the confidential and proprietary information of DCIVision * Ltd ("Confidential Information"). You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of the license * agreement you entered into with DCIVision Ltd. */ import java.util.Calendar; public class Main { /** * Call this function to round off the second and millisecond of time. * * @param timestamp The timestamp value to be strip to minutes * @return */ public static java.sql.Timestamp stripToMinutes(java.sql.Timestamp timestamp) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timestamp.getTime()); int day = cal.get(Calendar.DATE); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); int hour = cal.get(Calendar.HOUR_OF_DAY); int time = cal.get(Calendar.MINUTE); cal.clear(); cal.set(year, month, day, hour, time); timestamp = new java.sql.Timestamp(cal.getTimeInMillis()); return timestamp; } }