Java Date Set setDateSecond(Date dateParam, int second)

Here you can find the source of setDateSecond(Date dateParam, int second)

Description

set Date Second

License

Apache License

Declaration

public static Date setDateSecond(Date dateParam, int second) 

Method Source Code

//package com.java2s;
/*//from ww w. j av  a  2 s.  c  o  m
 * Copyright 2004 JavaFree.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

public class Main {

    public static Date setDateSecond(Date dateParam, int second) {
        Calendar dteComp = Calendar.getInstance();
        dteComp.setTime(dateParam);
        dteComp.set(Calendar.SECOND, second);
        return dteComp.getTime();
    }
}

Related

  1. setDate(Date date, int year, int month, int day)
  2. setDate(Date dateToSet, int hours, int minutes, int seconds, int milisec, TimeZone zone, Locale locale)
  3. SetDate(int year, int month, int day)
  4. setDate(int year, int month, int day)
  5. setDateHourMinute(Date dateParam, String hourMinute, String format)
  6. setDateToDayStart(final Date date)
  7. setDateToStartOfDay(Date date)
  8. setDayStart(final Date date)
  9. setField(Date date, int field, int value)