Android Date Clone clone(final Date date)

Here you can find the source of clone(final Date date)

Description

Clone date if non-null

License

Open Source License

Parameter

Parameter Description
date a parameter

Return

copied date

Declaration

public static Date clone(final Date date) 

Method Source Code

//package com.java2s;
/******************************************************************************
 *  Copyright (c) 2011 GitHub Inc./*  ww w. j a v a  2  s .co m*/
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *    Kevin Sawicki (GitHub Inc.) - initial API and implementation
 *****************************************************************************/

import java.util.Date;

public class Main {
    /**
     * Clone date if non-null
     *
     * @param date
     * @return copied date
     */
    public static Date clone(final Date date) {
        if (date == null)
            return null;
        return new Date(date.getTime());
    }
}

Related

  1. copyTime(Date originalDate, Date appliedDate)