Example usage for java.util Calendar SECOND

List of usage examples for java.util Calendar SECOND

Introduction

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

Prototype

int SECOND

To view the source code for java.util Calendar SECOND.

Click Source Link

Document

Field number for get and set indicating the second within the minute.

Usage

From source file:com.square.core.agent.desactivation.relation.DesactivationRelationsAgentJmxThead.java

@Override
public void run() {
    agent.setEtat("Agent DesactivationRelations debut de traitement");
    try {/*from   w  ww  . ja va2  s. c  o m*/
        final Calendar date = Calendar.getInstance();
        if (StringUtils.isNotBlank(agent.getDate())) {
            final SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy");
            date.setTime(formatDate.parse(agent.getDate()));
        }
        date.clear(Calendar.HOUR);
        date.clear(Calendar.MINUTE);
        date.clear(Calendar.SECOND);
        date.clear(Calendar.MILLISECOND);

        final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        agent.setEtat("Lancement desactivation relations  la date du " + format.format(date.getTime()));
        int counter = 0;

        // Cration des criteres des relations  dsactiver
        final RelationCriteresRechercheDto criterias = new RelationCriteresRechercheDto();
        criterias.setDateFinMax(date);
        criterias.setActif(true);
        criterias.setSupprime(null);

        // Calcul du nombre total
        final int nbTotal = personneService.countRelationsParCriteres(criterias);
        agent.setEtat("Traitement des relations : " + nbTotal + " lments");
        // Recuparation des ids de relations
        List<Long> listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date,
                agent.getPagination());

        while (listeRelationsADesactiver.size() > 0 && !agent.isStopping()) {
            counter += listeRelationsADesactiver.size();
            logger.debug("Dsactivation des relations en cours " + counter + " / " + nbTotal);
            personneService.desactiverRelations(listeRelationsADesactiver);

            // Rcupration des relations  dsactiver
            listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date,
                    agent.getPagination());
        }
    } catch (Exception e) {
        agent.setEtat(e.getMessage());
        e.printStackTrace();
    } finally {
        agent.getSessionFactory().openSession().close();
        agent.stop();
    }
}

From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsLoggingDao.java

/**
 * Get a {@link Date}, where hours, minutes, seconds and milliseconds are
 * set to 0./*ww  w  .jav  a2s.c  o m*/
 *
 * @return the {@link Date} .
 */
private static Date getDayStart(final Date d) {
    final Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE);
    gc.setTime(d);
    gc.set(Calendar.HOUR_OF_DAY, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    return gc.getTime();
}

From source file:com.ar.dev.tierra.api.dao.impl.MetodoPagoFacturaDAOImpl.java

@Override
public List<MetodoPagoFactura> getDay() {
    Criteria criteria = getSession().createCriteria(MetodoPagoFactura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.asc("idMetodoPagoFactura"));
    List<MetodoPagoFactura> list = criteria.list();
    return list;//w w  w  .ja v  a  2s.com
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleFacturaDAOImpl.java

@Override
public List<DetalleFactura> getDay() {
    Criteria criteria = getSession().createCriteria(DetalleFactura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.asc("idDetalleFactura"));
    List<DetalleFactura> list = criteria.list();
    return list;/*from w  w  w.  j  a  va  2 s . c  o m*/
}

From source file:com.lohika.alp.reporter.fe.dao.TestDAOImpl.java

private DetachedCriteria getFilteredCriteria(TestFilter filter) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Test.class);

    criteria.createAlias("suite", "suite");

    if (filter.getFrom() != null && filter.getTill() != null) {
        Calendar c = Calendar.getInstance();

        c.setTime(filter.getFrom());/*  www.  j  av a  2  s  .c  om*/
        c.set(Calendar.HOUR_OF_DAY, c.getActualMinimum(Calendar.HOUR_OF_DAY));
        c.set(Calendar.MINUTE, c.getActualMinimum(Calendar.MINUTE));
        c.set(Calendar.SECOND, c.getActualMinimum(Calendar.SECOND));
        c.set(Calendar.MILLISECOND, c.getActualMinimum(Calendar.MILLISECOND));
        Date from = c.getTime();

        c.setTime(filter.getTill());
        c.set(Calendar.HOUR_OF_DAY, c.getActualMaximum(Calendar.HOUR_OF_DAY));
        c.set(Calendar.MINUTE, c.getActualMaximum(Calendar.MINUTE));
        c.set(Calendar.SECOND, c.getActualMaximum(Calendar.SECOND));
        c.set(Calendar.MILLISECOND, c.getActualMaximum(Calendar.MILLISECOND));
        Date till = c.getTime();

        criteria.add(Restrictions.between("startDate", from, till));
    }

    if (filter.getTest() != "" && filter.getTest() != null) {
        try {
            criteria.add(querytr.translate("name", filter.getTest()));
        } catch (QueryTranslatorException e) {
            // TODO Put QueryTranslatorException into log
            e.printStackTrace();
        }
    }

    if (filter.getSuite() != "" && filter.getSuite() != null) {
        try {
            criteria.add(querytr.translate("suite.name", filter.getSuite()));
        } catch (QueryTranslatorException e) {
            // TODO Put QueryTranslatorException into log
            e.printStackTrace();
        }
    }
    return criteria;
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractExpiresHeaderFilter.java

@Override
protected String getHeaderValue() {
    Calendar next = Calendar.getInstance();
    next.set(Calendar.HOUR_OF_DAY, expiresTime.get(Calendar.HOUR_OF_DAY));
    next.set(Calendar.MINUTE, expiresTime.get(Calendar.MINUTE));
    next.set(Calendar.SECOND, 0);

    adjustExpires(next);/*from  w  ww .j  a  v  a 2s .  c  o m*/

    SimpleDateFormat dateFormat = new SimpleDateFormat(EXPIRES_FORMAT);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return dateFormat.format(next.getTime());
}

From source file:uk.org.funcube.fcdw.server.processor.WholeOrbitDataProcessorImpl.java

@Override
@Transactional(readOnly = false)/*from   w  w  w  .  ja v  a 2s .c  om*/
public void process(long satelliteId) {
    Calendar cal = Calendar.getInstance(TZ);
    cal.add(Calendar.HOUR, -24);

    final List<HexFrameEntity> wodList = hexFrameDao.findUnprocessedWOD(satelliteId, cal.getTime());

    LOG.debug("Found: " + wodList.size() + " unprocessed wod frames");

    long oldSeqNo = -1;

    List<String> frames = new ArrayList<String>();

    List<HexFrameEntity> processedHexFrames = new ArrayList<HexFrameEntity>();

    Date receivedDate = null;

    for (final HexFrameEntity wodFrame : wodList) {
        if (wodFrame.getFrameType() == 11) {
            receivedDate = wodFrame.getCreatedDate();
        }
        if (wodFrame.getSequenceNumber() != oldSeqNo) {
            if (oldSeqNo != -1) {
                if (frames.size() == 12) {

                    cal = Calendar.getInstance(TZ);
                    cal.setTime(receivedDate);
                    cal.set(Calendar.SECOND, 0);
                    cal.set(Calendar.MILLISECOND, 0);
                    receivedDate = cal.getTime();

                    extractAndSaveWod(satelliteId, oldSeqNo, frames, receivedDate);

                    for (HexFrameEntity hfe : processedHexFrames) {
                        hfe.setHighPrecisionProcessed(true);
                        hexFrameDao.save(hfe);
                    }
                }
                frames = new ArrayList<String>();
                processedHexFrames = new ArrayList<HexFrameEntity>();
                frames.add(wodFrame.getHexString().substring(106, wodFrame.getHexString().length()));
                processedHexFrames.add(wodFrame);
            }

            oldSeqNo = wodFrame.getSequenceNumber();
        } else {
            frames.add(wodFrame.getHexString().substring(106, wodFrame.getHexString().length()));
            processedHexFrames.add(wodFrame);
        }
    }

}

From source file:cz.cvut.fel.webrtc.handlers.WebHandler.java

public WebHandler() {
    super();/*w w  w  .  ja  va  2 s . c  om*/
    TimerTask task = new TimerTask() {

        @Override
        public void run() {
            Calendar currentDate = Calendar.getInstance();

            for (WebUser user : registry.getAll()) {
                Calendar ping = user.getLastPing();
                ping.add(Calendar.SECOND, 40);

                if (ping.before(currentDate)) {
                    try {
                        log.info("{} is unreachable.", user.getName());
                        leaveRoom(user);
                    } catch (Exception e) {
                    }
                }
            }
        }

    };

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(task, 30000, 30000);
}

From source file:net.seratch.taskun.util.CalendarUtil.java

 public static Calendar getCalendar(int yyyy, int mm, int dd, int hh,
      int mi, int ss) {
   Calendar cal = getCalendar(yyyy, mm, dd);
   cal.set(Calendar.HOUR_OF_DAY, hh);
   cal.set(Calendar.MINUTE, mi);/*w w  w  .j  ava  2 s  .  co  m*/
   cal.set(Calendar.SECOND, ss);
   return cal;
}

From source file:Main.java

/**
 *
 * This method is a utility method to create a new java.sql.Date in one line.
 *
 * @param year// ww  w. j  a  v a 2s.  c om
 * @param month
 * @param day
 * @param hour
 * @param minute
 * @param second
 *
 * @return a populated java.sql.Date with the year, month, hour, minute, and second populated, with no value for millisecond.
 *
 */
public static java.sql.Date newDate(Integer year, Integer month, Integer day, Integer hour, Integer minute,
        Integer second) {

    // test for null arguments
    if (year == null) {
        throw new IllegalArgumentException("Argument 'year' passed in was null.");
    }
    if (month == null) {
        throw new IllegalArgumentException("Argument 'month' passed in was null.");
    }
    if (day == null) {
        throw new IllegalArgumentException("Argument 'day' passed in was null.");
    }
    if (hour == null) {
        throw new IllegalArgumentException("Argument 'hour' passed in was null.");
    }
    if (minute == null) {
        throw new IllegalArgumentException("Argument 'minute' passed in was null.");
    }
    if (second == null) {
        throw new IllegalArgumentException("Argument 'second' passed in was null.");
    }

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, second);
    calendar.clear(Calendar.MILLISECOND);

    return new java.sql.Date(calendar.getTimeInMillis());
}