Example usage for java.util GregorianCalendar getTimeInMillis

List of usage examples for java.util GregorianCalendar getTimeInMillis

Introduction

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

Prototype

public long getTimeInMillis() 

Source Link

Document

Returns this Calendar's time value in milliseconds.

Usage

From source file:op.tools.SYSCalendar.java

public static Date bom(Date d) {
    GregorianCalendar gc = toGC(d);
    gc.set(GregorianCalendar.DATE, 1);
    return new Date(startOfDay(new Date(gc.getTimeInMillis())));
}

From source file:op.tools.SYSCalendar.java

/**
 * EndOfMonth/* w ww  .  j a  v a  2  s  .c  o  m*/
 * Berechnet das Enddatum eines Monats, passend zum Parameter
 *
 * @param d Datum innerhalb des entsprechenden Monats.
 * @return Enddatum des Monats
 */
public static Date eom(Date d) {
    GregorianCalendar gc = toGC(d);
    int ieom = eom(gc);
    gc.set(GregorianCalendar.DATE, ieom);
    return new Date(endOfDay(new Date(gc.getTimeInMillis())));
}

From source file:org.hoteia.qalingo.app.business.job.email.EmailCleanerTasklet.java

public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    GregorianCalendar calendar = new GregorianCalendar();
    int day = calendar.get(GregorianCalendar.DAY_OF_YEAR);

    // TODO : Denis : 20130924 : add number of day configuration in database

    calendar.set(GregorianCalendar.DAY_OF_YEAR, day - 7);
    int row = emailService.deleteSendedEmail(new Timestamp(calendar.getTimeInMillis()));
    logger.debug(row + " emails deleted");
    return RepeatStatus.FINISHED;
}

From source file:edu.lternet.pasta.portal.statistics.GrowthStats.java

private ArrayList<Integer> buildFrequencies(GregorianCalendar start, GregorianCalendar end, int scale,
        Long[] list) {/*from  w  w  w  . j ava 2s .co  m*/

    ArrayList<Integer> freqs = new ArrayList<Integer>();

    GregorianCalendar lower = (GregorianCalendar) start.clone();
    GregorianCalendar upper = new GregorianCalendar();

    while (lower.getTimeInMillis() <= end.getTimeInMillis()) {
        upper.setTime(lower.getTime());
        upper.add(scale, 1);

        int freq = 0;

        for (int i = 0; i < list.length; i++) {
            if (lower.getTimeInMillis() <= list[i] && list[i] < upper.getTimeInMillis()) {
                freq++;
                //System.out.printf("%d - %d - %d - %d%n", lower.getTimeInMillis(), list[i], upper.getTimeInMillis(), freq);
            }
        }
        freqs.add(freq);
        lower.setTime(upper.getTime());

    }

    return freqs;

}

From source file:org.hoteia.qalingo.app.business.job.status.ServerStatusCleanerTasklet.java

public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    GregorianCalendar calendar = new GregorianCalendar();
    int day = calendar.get(GregorianCalendar.DAY_OF_YEAR);

    // TODO : Denis : 20131209 : add number of day configuration in database ?

    calendar.set(GregorianCalendar.DAY_OF_YEAR, day - 7);
    int row = serverService.deleteSendedServerStatus(new Timestamp(calendar.getTimeInMillis()));
    logger.debug(row + " server status deleted");
    return RepeatStatus.FINISHED;
}

From source file:org.holistic.ws_proxy.WSProxyHelper.java

public void processRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    GregorianCalendar m_objGCalendar = new GregorianCalendar();
    long m_inicio = m_objGCalendar.getTimeInMillis();
    if (HTTP_GET.equals(req.getMethod().toUpperCase()))
        doGet(req, resp);/*w w  w .jav  a2s. c  o  m*/
    else
        doPost(req, resp);
    m_objGCalendar = new GregorianCalendar();
    long m_fin = m_objGCalendar.getTimeInMillis();
    log.info("Request processing time (mseg): " + (m_fin - m_inicio));
}

From source file:org.mili.core.io.DirectoryCleanerTest.java

@Test
@Ignore // use another variant to set the actual date
public void shouldIsFileExpiredWithFileTime() throws Exception {
    DirectoryCleaner dc = new DirectoryCleaner();
    GregorianCalendar gc = new GregorianCalendar();
    gc.roll(Calendar.DAY_OF_YEAR, -10);
    assertTrue(dc.isFileExpired(gc.getTimeInMillis(), 4));
    assertFalse(dc.isFileExpired(gc.getTimeInMillis(), 10));
    assertFalse(dc.isFileExpired(gc.getTimeInMillis(), 11));
}

From source file:com.twinflag.coofiletouch.AuthorityUtil.java

public boolean isLaterThanToday(String date) {
    boolean retValue = false;
    if (date != null) {
        int dayDif = 0;
        int year = 0;
        int month = 0;
        int day = 0;
        String monthStr = null;//w  w  w  .  j av  a  2  s. co m
        String dayStr = null;
        Date toCompareDate = null;
        Date currentDate = null;
        Calendar calendar = null;
        String toCompareDateString = null;
        String currentDateString = null;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        toCompareDateString = "20" + date;
        try {
            toCompareDate = simpleDateFormat.parse(toCompareDateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        // ??
        calendar = Calendar.getInstance();
        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH);
        if (month < 10) {
            monthStr = "0" + month;
        } else {
            monthStr = "" + month;
        }
        day = calendar.get(Calendar.DAY_OF_MONTH);
        if (day < 10) {
            dayStr = "0" + day;
        } else {
            dayStr = "" + day;
        }
        currentDateString = "" + year + monthStr + dayStr;
        try {
            currentDate = simpleDateFormat.parse(currentDateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        GregorianCalendar cal1 = new GregorianCalendar();
        GregorianCalendar cal2 = new GregorianCalendar();
        cal1.setTime(toCompareDate);
        cal2.setTime(currentDate);
        dayDif = (int) ((cal2.getTimeInMillis() - cal1.getTimeInMillis()) / (1000 * 3600 * 24));
        if (dayDif <= 0) {
            retValue = true;
        }
    }
    return retValue;
}

From source file:org.kuali.kfs.coa.batch.dataaccess.impl.AccountingPeriodFiscalYearMakerImpl.java

/**
 * Adds one year to the given date/*from w w w. ja v a 2 s  . c  o m*/
 * 
 * @param inDate date to increment
 * @return Date incoming date plus one year
 */
protected java.sql.Date addYearToDate(Date inDate) {
    GregorianCalendar currentCalendarDate = new GregorianCalendar();
    currentCalendarDate.clear();

    currentCalendarDate.setTimeInMillis(inDate.getTime());
    currentCalendarDate.add(GregorianCalendar.YEAR, 1);

    return new Date(currentCalendarDate.getTimeInMillis());
}

From source file:com.anite.zebra.hivemind.impl.TimedTaskRunnerImpl.java

private boolean isTaskDueToday(TimedTask timedTask) {
    boolean taskOK = false;
    Calendar calendar = Calendar.getInstance();
    GregorianCalendar now = new GregorianCalendar();

    now.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23,
            59, 59);/*from w w w. jav  a2s.c o  m*/
    Date lastThingToday = new Date(now.getTimeInMillis());

    if (timedTask.getRunTaskDate() == null || timedTask.getRunTaskDate().equals(lastThingToday)
            || timedTask.getRunTaskDate().before(lastThingToday)) {

        taskOK = true;
    }
    return taskOK;

}