Example usage for java.util Date clone

List of usage examples for java.util Date clone

Introduction

In this page you can find the example usage for java.util Date clone.

Prototype

public Object clone() 

Source Link

Document

Return a copy of this object.

Usage

From source file:org.kordamp.ezmorph.object.DateMorpher.java

/**
 * Sets the defaultValue to use if the value to be morphed is null.
 *
 * @param defaultValue return value if the value to be morphed is null
 *///from   w  w  w . j  a  v a 2s. c o m
public void setDefaultValue(Date defaultValue) {
    this.defaultValue = (Date) defaultValue.clone();
}

From source file:cn.newcapec.framework.core.utils.dataUtils.DateMorpherEx.java

public void setDefaultValue(Date defaultValue) {
    if (defaultValue != null)
        this.defaultValue = ((Date) defaultValue.clone());
    else// www .  j a  v  a2s  .  com
        this.defaultValue = null;
}

From source file:com.silverpeas.calendar.DateTest.java

/**
 * Test of clone method, of class Date.//w  ww  .j  a v  a2 s .co m
 */
@Test
public void cloneADateCreatesANewInstanceForTheSameDate() {
    Date expected = new Date(getInstance().getTime());

    Date actual = expected.clone();
    assertThat(actual == expected, is(false));
    assertThat(actual, isEqualTo(expected));
}

From source file:org.opendatakit.persistence.engine.pgres.RelationRowMapper.java

@Override
public CommonFieldsBase mapRow(ResultSet rs, int rowNum) throws SQLException {

    CommonFieldsBase row;//from   w  w w .  j a va2s  . c o m
    try {
        row = relation.getEmptyRow(user);
        row.setFromDatabase(true);
    } catch (Exception e) {
        throw new IllegalStateException("failed to create empty row", e);
    }

    /**
     * Correct for the funky handling of nulls by the various accessors...
     */
    for (DataField f : relation.getFieldList()) {
        switch (f.getDataType()) {
        case BINARY:
            byte[] blobBytes = rs.getBytes(f.getName());
            row.setBlobField(f, blobBytes);
            break;
        case LONG_STRING:
        case URI:
        case STRING:
            row.setStringField(f, rs.getString(f.getName()));
            break;
        case INTEGER:
            long l = rs.getLong(f.getName());
            if (rs.wasNull()) {
                row.setLongField(f, null);
            } else {
                row.setLongField(f, Long.valueOf(l));
            }
            break;
        case DECIMAL: {
            String value = rs.getString(f.getName());
            if (value == null) {
                row.setNumericField(f, null);
            } else {
                row.setNumericField(f, new WrappedBigDecimal(value));
            }
        }
            break;
        case BOOLEAN:
            Boolean b = rs.getBoolean(f.getName());
            if (rs.wasNull()) {
                row.setBooleanField(f, null);
            } else {
                row.setBooleanField(f, b);
            }
            break;
        case DATETIME:
            Date d = rs.getTimestamp(f.getName());
            if (d == null) {
                row.setDateField(f, null);
            } else {
                row.setDateField(f, (Date) d.clone());
            }
            break;
        default:
            throw new IllegalStateException("Did not expect non-primitive type in column fetch");
        }
    }
    return row;
}

From source file:org.apache.roller.weblogger.pojos.User.java

public void setDateCreated(final Date date) {
    if (date != null) {
        dateCreated = (Date) date.clone();
    } else {/*from ww w  .  java  2  s.com*/
        dateCreated = null;
    }
}

From source file:org.tonguetied.administration.ServerData.java

/**
 * Create a new instance of ServerData.//from  w  ww  . ja  va 2 s.  co m
 * 
 * @param version the version of the application
 * @param buildNumber the build number of the application
 * @param buildDate the date this application was built
 */
public ServerData(final String version, final String buildNumber, final Date buildDate) {
    // assign a copy of this parameter to avoid later changes to mutable 
    // object
    this.buildDate = (Date) buildDate.clone();
    this.buildNumber = buildNumber;
    this.version = version;
    this.setupDate = new Date();
}

From source file:org.sofun.platform.web.rest.api.team.ReSTMemberRankingTable.java

public void setLastUpdated(Date lastUpdated) {
    if (lastUpdated != null) {
        this.lastUpdated = (Date) lastUpdated.clone();
    }//  w w  w  .  j a  va2 s .c o m
}

From source file:org.apache.usergrid.apm.service.NetworkTestData.java

public static ClientNetworkMetrics getGeneratedMetricBean(long givenAppId, Date start, Date end) {
    ClientNetworkMetrics bean = new ClientNetworkMetrics();
    bean.setAppConfigType(configs[generator.nextInt(4)]);

    int index = generator.nextInt(uids.length);

    if (givenAppId == 0) {
        bean.setAppId(appId[generator.nextInt(3)]);
    } else {/*from www.jav  a 2  s .  c  om*/
        bean.setAppId(givenAppId);
    }
    bean.setDeviceId(deviceIds[index]);
    bean.setNetworkCarrier(networkCarriers[generator.nextInt(3)]);
    bean.setNetworkType(networkType[generator.nextInt(3)]);
    bean.setUrl(wsUrls[index]);

    bean.setStartTime((Date) start.clone());
    bean.setEndTime((Date) end.clone());
    bean.setTimeStamp((Date) end.clone());

    long latency = getSimulatedLatency(bean.getNetworkType(), bean.getNetworkCarrier(), bean.getUrl());
    double rate = getFailureRate(bean.getNetworkType(), bean.getNetworkCarrier(), bean.getUrl());

    bean.setLatency(latency / 2);
    bean.setNumSamples(new Long(generator.nextInt(5) + 1));

    Double numErrors = (rate * bean.getNumSamples());

    bean.setNumErrors(numErrors.longValue());

    return bean;
}

From source file:com.omertron.tvrageapi.model.ShowInfo.java

public void setStartDate(Date startDate) {
    this.startDate = (Date) startDate.clone();
}

From source file:jp.co.opentone.bsol.linkbinder.dto.AbstractDto.java

/**
 * Date?clone????.//from ww w  .j a  v a 2  s.co m
 * @param value ?
 * @return ???clone. value?null???null.
 */
protected Date cloneField(Date value) {
    Date clone = null;
    if (null != value) {
        clone = (Date) value.clone();
    }
    return clone;
}