Example usage for org.joda.time DateTime getMillis

List of usage examples for org.joda.time DateTime getMillis

Introduction

In this page you can find the example usage for org.joda.time DateTime getMillis.

Prototype

public long getMillis() 

Source Link

Document

Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z.

Usage

From source file:com.linagora.obm.ui.scenario.event.EventStepdefs.java

License:Open Source License

private boolean isDayOfMonthInPrintedWeek(DateTime dayOfMonth) {
    List<WebElement> dayElements = driver.findElements(By.className("dayLabel"));
    for (WebElement dayElement : dayElements) {
        WebElement href = dayElement.findElement(By.tagName("a"));
        if (href.getAttribute("onclick").contains(String.valueOf(dayOfMonth.getMillis() / 1000))) {
            return true;
        }/* ww  w.java  2  s  . c om*/
    }
    return false;
}

From source file:com.linagora.obm.ui.scenario.event.EventStepdefs.java

License:Open Source License

@And("^allday event \"([^\"]*)\" is inserted in the calendar at (\\d+)/(\\d+)/(\\d+)$")
public void alldayEventIsInCalendar(String title, int day, int month, int year) {
    DateTime dateTime = timelessDateTime(day, month, year);
    String expectedPartialEventId = String.valueOf(dateTime.getMillis() / 1000);

    WebElement divElement = processedCalendarPage.getDivByTitle(title);
    assertThat(divElement.getAttribute("id")).endsWith(expectedPartialEventId);
}

From source file:com.linkedin.pinot.core.segment.creator.impl.SegmentIndexCreationDriverImpl.java

License:Apache License

private long convertSDFToMillis(final String colValue) {
    final String sdfFormatStr = config.getSimpleDateFormat();
    DateTimeFormatter sdfFormatter = DateTimeFormat.forPattern(sdfFormatStr);
    DateTime dateTime = DateTime.parse(colValue, sdfFormatter);
    return dateTime.getMillis();
}

From source file:com.lithium.yoda.ToEpoch.java

License:Apache License

@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (dateOi instanceof StringObjectInspector) {
        String dateStr = ((StringObjectInspector) dateOi).getPrimitiveJavaObject(arguments[0].get());
        DateTimeFormatter dtf;//from w  ww. j a  v a 2 s.c o m
        if (hasSecondArg) {
            if (constSecondArg == null) {
                dtf = DateTimeFormat.forPattern(formatOi.getPrimitiveJavaObject(arguments[1].get()));
            } else {
                dtf = DateTimeFormat.forPattern(constSecondArg);
            }
        } else {
            dtf = ISODateTimeFormat.dateTimeParser().withOffsetParsed();
        }
        return dtf.parseDateTime(dateStr).getMillis();
    } else if (dateOi instanceof TimestampObjectInspector) {
        Timestamp ts = ((TimestampObjectInspector) dateOi).getPrimitiveJavaObject(arguments[0].get());
        if (hasSecondArg) {
            DateTime dt;
            if (constSecondArg == null) {
                dt = new DateTime(ts.getTime(),
                        DateTimeZone.forID(formatOi.getPrimitiveJavaObject(arguments[1].get())));
            } else {
                dt = new DateTime(ts.getTime(), DateTimeZone.forID(constSecondArg));
            }
            return dt.getMillis();
        } else {
            return ts.getTime();
        }
    }

    return null;
}

From source file:com.liugenxian.supporter.DateTypeHandler.java

License:Open Source License

@Override
public void setParameter(PreparedStatement ps, int i, DateTime param, JdbcType jdbcType) throws SQLException {
    ps.setTimestamp(i, new java.sql.Timestamp(param.getMillis()));
}

From source file:com.manydesigns.elements.fields.DateField.java

License:Open Source License

public void readFromRequest(HttpServletRequest req) {
    super.readFromRequest(req);

    if (mode.isView(insertable, updatable)) {
        return;/*  w w  w  .  j  a v  a  2s.  co m*/
    }

    String reqValue = req.getParameter(inputName);
    if (reqValue == null) {
        return;
    }

    stringValue = reqValue.trim();
    dateFormatError = false;
    dateValue = null;

    if (stringValue.length() == 0) {
        return;
    }

    try {
        DateTime dateTime = dateTimeFormatter.parseDateTime(stringValue);
        dateValue = new Date(dateTime.getMillis());
    } catch (Throwable e) {
        dateFormatError = true;
        logger.debug("Cannot parse date: {}", stringValue);
    }
}

From source file:com.manydesigns.elements.fields.search.DateSearchField.java

License:Open Source License

@Override
public void readFromRequest(HttpServletRequest req) {
    minStringValue = StringUtils.trimToNull(req.getParameter(minInputName));
    try {/*from w w  w. j av a 2s .c o m*/
        DateTime dateTime = dateTimeFormatter.parseDateTime(minStringValue);
        minValue = new Date(dateTime.getMillis());
    } catch (Throwable e) {
        minValue = null;
    }

    maxStringValue = StringUtils.trimToNull(req.getParameter(maxInputName));
    try {
        DateTime dateTime = dateTimeFormatter.parseDateTime(maxStringValue);
        maxValue = new Date(dateTime.getMillis());
    } catch (Throwable e) {
        maxValue = null;
    }

    searchNullValue = (NULL_VALUE.equals(minStringValue) || NULL_VALUE.equals(maxStringValue));
}

From source file:com.marand.thinkmed.medications.pharmacist.impl.PharmacistTaskCreatorImpl.java

License:Open Source License

@Override
public void updatePharmacistReviewTask(@Nonnull final String taskId, final DateTime dueTime,
        final String lastEditorName, final DateTime lastEditTime) {
    Preconditions.checkNotNull(taskId, "taskId");

    final Map<String, Object> variables = new HashMap<>();
    variables.put(PharmacistReviewTaskDef.LAST_EDITOR_NAME.getName(), lastEditorName);
    variables.put(PharmacistReviewTaskDef.LAST_EDIT_TIMESTAMP_MILLIS.getName(), lastEditTime.getMillis());
    processService.setDueDate(taskId, dueTime);
    processService.setVariables(taskId, variables);
}

From source file:com.marand.thinkmed.medications.pharmacist.impl.PharmacistTaskCreatorImpl.java

License:Open Source License

private NewTaskRequestDto createPharmacistReviewTaskRequest(final String patientId, final DateTime dueTime,
        final String lastEditorName, final DateTime lastEditTime, final PrescriptionChangeTypeEnum changeType,
        final PharmacistReviewTaskStatusEnum status) {
    return new NewTaskRequestDto(PharmacistReviewTaskDef.INSTANCE,
            PharmacistReviewTaskDef.getTaskTypeEnum().buildKey(String.valueOf(patientId)), "Pharmacist review",
            "Pharmacist review", TherapyAssigneeEnum.PHARMACIST.name(), dueTime, null,
            Pair.of(MedsTaskDef.PATIENT_ID, patientId),
            Pair.of(PharmacistReviewTaskDef.LAST_EDITOR_NAME, lastEditorName),
            Pair.of(PharmacistReviewTaskDef.LAST_EDIT_TIMESTAMP_MILLIS, lastEditTime.getMillis()),
            Pair.of(PharmacistReviewTaskDef.CHANGE_TYPE, changeType.name()),
            Pair.of(PharmacistReviewTaskDef.STATUS, status.name()));
}

From source file:com.marand.thinkmed.medications.pharmacist.impl.PharmacistTaskHandlerImpl.java

License:Open Source License

@Override
public void editPerfusionSyringeTask(@Nonnull final String taskId, @Nonnull final Integer numberOfSyringes,
        final boolean isUrgent, @Nonnull final DateTime dueDate, final boolean printSystemLabel) {
    StringUtils.checkNotBlank(taskId, "taskId is required");
    Preconditions.checkNotNull(numberOfSyringes, "numberOfSyringes is required");
    Preconditions.checkNotNull(dueDate, "dueDate is required");

    final Map<String, Object> processVariables = new HashMap<>();
    processVariables.put(PreparePerfusionSyringeProcess.numberOfSyringes.name(), numberOfSyringes);
    processVariables.put(PreparePerfusionSyringeProcess.isUrgent.name(), isUrgent);
    processVariables.put(PreparePerfusionSyringeProcess.dueDateTimeMillis.name(), dueDate.getMillis());
    processVariables.put(PreparePerfusionSyringeProcess.printSystemLabel.name(), printSystemLabel);
    final Map<String, Object> localVariables = new HashMap<>();
    localVariables.put(PerfusionSyringeTaskDef.NUMBER_OF_SYRINGES.getName(), numberOfSyringes);
    localVariables.put(PerfusionSyringeTaskDef.IS_URGENT.getName(), isUrgent);
    localVariables.put(PerfusionSyringeTaskDef.PRINT_SYSTEM_LABEL.getName(), printSystemLabel);

    final TaskDto taskDto = processService.loadTaskWithCustomDetails(taskId, false,
            EnumSet.of(TaskDetailsEnum.PROCESS_INFO));
    bpmService.setProcessVariables(taskDto.getProcessBusinessKey(), PreparePerfusionSyringeProcess.class,
            processVariables);/*from  w w  w  .ja va 2s.c o m*/
    processService.setVariablesLocal(taskId, localVariables);
    processService.setDueDate(taskId, dueDate);
}