Example usage for java.util Calendar getTimeInMillis

List of usage examples for java.util Calendar getTimeInMillis

Introduction

In this page you can find the example usage for java.util Calendar getTimeInMillis.

Prototype

public long getTimeInMillis() 

Source Link

Document

Returns this Calendar's time value in milliseconds.

Usage

From source file:org.spring.data.gemfire.app.beans.Person.java

public void setBirthDate(final Calendar birthDate) {
    this.birthDate = birthDate.getTimeInMillis();
}

From source file:net.maritimecloud.identityregistry.model.database.CertificateModel.java

@PreRemove
public void preRemove() {
    if (getCertificates() != null) {
        // Dates are converted to UTC before saving into the DB
        Calendar cal = Calendar.getInstance();
        long offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
        Date now = new Date(cal.getTimeInMillis() - offset);
        for (Certificate cert : getCertificates()) {
            // Revoke certificates
            cert.setRevokedAt(now);/*from ww  w . j  a  v a  2  s. c o  m*/
            cert.setEnd(now);
            cert.setRevokeReason("cessationofoperation");
            cert.setRevoked(true);
            // Detach certificate from entity - since the model type isn't known, just blank all.
            cert.setOrganization(null);
            cert.setDevice(null);
            cert.setService(null);
            cert.setUser(null);
            cert.setVessel(null);
        }
    }
}

From source file:com.evolveum.midpoint.repo.sql.CleanupTest.java

License:asdf

private Duration createDuration(Calendar when, long now) throws Exception {
    long seconds = (now - when.getTimeInMillis()) / 1000;
    return DatatypeFactory.newInstance().newDuration("PT" + seconds + "S").negate();
}

From source file:com.comcast.cats.monitor.reboot.BarcelonaRebootMonitor.java

/**
 * Calculates the uptime of the box.//from w w w . j av a  2s. c o  m
 */
private long calculateUptime(String upTimeDays, String upTimehours)
        throws ParseException, NumberFormatException {
    Date actualUptime = DateUtils.parseDate(upTimehours, EXPECTED_DATE_FORMATS);

    if (upTimeDays != null) {
        actualUptime = DateUtils.addDays(actualUptime, Integer.parseInt(upTimeDays));
    }

    Calendar cal = Calendar.getInstance();
    cal.setTime(actualUptime);
    cal.getTimeInMillis();

    long upTimemillis = (cal.get(Calendar.HOUR_OF_DAY) * 60 * 60 * 1000)
            + (cal.get(Calendar.MINUTE) * 60 * 1000) + (cal.get(Calendar.SECOND) * 1000)
            + (cal.get(Calendar.MILLISECOND));

    return upTimemillis;
}

From source file:net.landora.animeinfo.anidb.AniDBCommand.java

public void addArgument(String name, Calendar value) {
    if (value == null) {
        addArgument(name, 0);//from  w  w  w.ja va  2  s  .c o m
    } else {
        addArgument(name, value.getTimeInMillis() / 1000l);
    }
}

From source file:com.taurus.compratae.test.ArchivoDbServiceTestCase.java

public void testBuscarTodo() {
    log.debug("Inicio testRecarga");
    setup();/*from w w w. j a va2s.c  o  m*/
    Date fecha1 = new Date();
    SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");
    String fecha = formatoDelTexto.format(fecha1);

    Date fechaEnviar = null;
    try {
        fechaEnviar = formatoDelTexto.parse(fecha);
    } catch (ParseException ex) {
        ex.printStackTrace();
    }
    Calendar cal = new GregorianCalendar();
    cal.setTimeInMillis(fechaEnviar.getTime());
    cal.add(Calendar.MINUTE, 1439);
    Date fecha2 = new java.sql.Date(cal.getTimeInMillis());
    Archivo archivo = archivoDbService.buscarEntreFechas(fechaEnviar, fecha2);
    log.debug("Fin testRecarga");
}

From source file:com.app.flickr.FlickrConnection.java

/** Method returns String massive of popular photos URLs related with specified date.
@param listSize Number of tagged photos you want to get from flickr.com.
@param year The YEAR calendar field.//from w w w .j  a va 2 s. co m
@param month The MONTH calendar field. Month value is 0-based. e.g., 0 for January.
@param date The DAY_OF_MONTH calendar field.
@param extras A comma-delimited list of extra information to fetch for each returned record. 
   Currently supported fields are: description, license, date_upload, date_taken, 
   owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, 
   o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, 
   url_c, url_l, url_o
*/
public PhotoList<Photo> getPopularPhotos(int listSize, int year, int month, int day, Set<String> extras)
        throws FlickrException, HttpException, IOException {
    //Date
    Calendar c = new GregorianCalendar();
    c.set(year, month, day);
    //c.add(Calendar.DAY_OF_YEAR, -1);
    Date date = new Date(c.getTimeInMillis());

    PhotoList<Photo> photoList = flickr.getInterestingnessInterface().getList(date, extras, listSize, 1);

    return photoList;
}

From source file:cloudnet.weather.data.forecastio.WeatherDataFetcher.java

public void fetchData(String locationData, String city, Calendar start, Calendar end) {

    try {/*from  www . j  a v  a  2 s  .c o  m*/
        URL url;
        while (start.before(end)) {
            url = new URL(urlString + locationData + "," + start.getTimeInMillis() / 1000 + "?units=si");
            File file = new File("resources/weather/" + city + "/" + start.getTimeInMillis() / 1000 + ".json");
            LOGGER.trace("downloading " + start.getTimeInMillis() / 1000);
            FileUtils.copyURLToFile(url, file);
            start.add(Calendar.HOUR, 12);
        }

    } catch (MalformedURLException e) {
        LOGGER.error("fetchData", e);
    } catch (IOException e) {
        LOGGER.error("fetchData", e);
    }
}

From source file:com.marvelution.jira.plugins.hudson.utils.DateFormatUtils.java

/**
 * Format the given time-stamp to a human-readable time string. If the 'Time Past Since Current Time' feature is
 * not used, then the ISO Datetime format is used to format the given timestamp
 * // w w w .java2s  . c o m
 * @param timestamp the {@link Calendar} to format
 * @return the formatted time-stamp
 */
public String format(Calendar timestamp) {
    return format(timestamp.getTimeInMillis());
}

From source file:eu.planets_project.tb.gui.backing.exp.MeasurementPropertyResultsBean.java

public void addResult(Calendar runDate, MeasurementImpl result) {
    if (this.results != null) {
        this.results.put(runDate.getTimeInMillis(), new RecordBean(result));
    }//  w ww.j  av a  2 s.  com
}