Example usage for org.joda.time DateTime getSecondOfMinute

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

Introduction

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

Prototype

public int getSecondOfMinute() 

Source Link

Document

Get the second of minute field value.

Usage

From source file:org.talend.components.netsuite.client.model.search.SearchDateFieldAdapter.java

License:Open Source License

protected XMLGregorianCalendar convertDateTime(String input) {
    String valueToParse = input;//from  ww  w .  jav  a2 s  .co  m
    String dateTimeFormatPattern = dateFormatPattern + " " + timeFormatPattern;
    if (input.length() == dateFormatPattern.length()) {
        dateTimeFormatPattern = dateFormatPattern;
    } else if (input.length() == timeFormatPattern.length()) {
        DateTime dateTime = new DateTime();
        DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(dateFormatPattern);
        valueToParse = dateFormatter.print(dateTime) + " " + input;
    }

    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(dateTimeFormatPattern);

    DateTime dateTime;
    try {
        dateTime = dateTimeFormatter.parseDateTime(valueToParse);
    } catch (IllegalArgumentException e) {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                NetSuiteRuntimeI18n.MESSAGES.getMessage("error.searchDateField.invalidDateTimeFormat",
                        valueToParse));
    }

    XMLGregorianCalendar xts = datatypeFactory.newXMLGregorianCalendar();
    xts.setYear(dateTime.getYear());
    xts.setMonth(dateTime.getMonthOfYear());
    xts.setDay(dateTime.getDayOfMonth());
    xts.setHour(dateTime.getHourOfDay());
    xts.setMinute(dateTime.getMinuteOfHour());
    xts.setSecond(dateTime.getSecondOfMinute());
    xts.setMillisecond(dateTime.getMillisOfSecond());
    xts.setTimezone(dateTime.getZone().toTimeZone().getOffset(dateTime.getMillis()) / 60000);

    return xts;
}

From source file:org.traccar.protocol.H02ProtocolEncoder.java

License:Apache License

private Object formatCommand(DateTime time, String uniqueId, String type, String... params) {

    StringBuilder result = new StringBuilder(String.format("*%s,%s,%s,%02d%02d%02d", MARKER, uniqueId, type,
            time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute()));

    for (String param : params) {
        result.append(",").append(param);
    }/*from   w  w w  .j  av a 2 s .com*/

    result.append("#");

    return result.toString();
}

From source file:org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl.java

License:Open Source License

@Override
public List<Result<ExecutionTimeOfAPIValues>> getExecutionTimeByAPI(String apiName, String version,
        String tenantDomain, String fromDate, String toDate, String drillDown, String mediationType)
        throws APIMgtUsageQueryServiceClientException {
    List<Result<ExecutionTimeOfAPIValues>> result = new ArrayList<Result<ExecutionTimeOfAPIValues>>();
    try {/*from w  ww  .j a  v  a2  s  .  c  om*/
        StringBuilder query = new StringBuilder(
                "from " + APIUsageStatisticsClientConstants.API_EXECUTION_TIME_AGG + " on("
                        + APIUsageStatisticsClientConstants.API_NAME + "=='" + apiName + "'");
        if (version != null) {
            query.append(" AND " + APIUsageStatisticsClientConstants.API_VERSION + "=='" + version + "'");
        }
        if (tenantDomain != null) {
            query.append(" AND " + APIUsageStatisticsClientConstants.API_CREATOR_TENANT_DOMAIN + "=='"
                    + tenantDomain + "'");
        }
        if (fromDate != null && toDate != null) {
            String granularity = APIUsageStatisticsClientConstants.SECONDS_GRANULARITY;

            Map<String, Integer> durationBreakdown = this.getDurationBreakdown(fromDate, toDate);
            LocalDateTime currentDate = LocalDateTime.now(DateTimeZone.UTC);
            DateTimeFormatter formatter = DateTimeFormat
                    .forPattern(APIUsageStatisticsClientConstants.TIMESTAMP_PATTERN);
            LocalDateTime fromLocalDateTime = LocalDateTime.parse(fromDate, formatter);//GMT time

            if (fromLocalDateTime.isBefore(currentDate.minusYears(1))) {
                granularity = APIUsageStatisticsClientConstants.MONTHS_GRANULARITY;
            } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_MONTHS) > 0
                    || durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_WEEKS) > 0) {
                granularity = APIUsageStatisticsClientConstants.DAYS_GRANULARITY;
            } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_DAYS) > 0) {
                granularity = APIUsageStatisticsClientConstants.HOURS_GRANULARITY;
            } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_HOURS) > 0) {
                granularity = APIUsageStatisticsClientConstants.MINUTES_GRANULARITY;
            }
            query.append(") within " + getTimestamp(fromDate) + "L, " + getTimestamp(toDate) + "L per '"
                    + granularity + "'");
        } else {
            query.append(") within " + 0 + "L, " + new Date().getTime() + "L per 'months'");
        }
        query.append(" select " + APIUsageStatisticsClientConstants.API_NAME + ", "
                + APIUsageStatisticsClientConstants.API_CONTEXT + ", "
                + APIUsageStatisticsClientConstants.API_CREATOR + ", "
                + APIUsageStatisticsClientConstants.API_VERSION + ", "
                + APIUsageStatisticsClientConstants.TIME_STAMP + ", "
                + APIUsageStatisticsClientConstants.RESPONSE_TIME + ", "
                + APIUsageStatisticsClientConstants.SECURITY_LATENCY + ", "
                + APIUsageStatisticsClientConstants.THROTTLING_LATENCY + ", "
                + APIUsageStatisticsClientConstants.REQUEST_MEDIATION_LATENCY + ", "
                + APIUsageStatisticsClientConstants.RESPONSE_MEDIATION_LATENCY + ", "
                + APIUsageStatisticsClientConstants.BACKEND_LATENCY + ", "
                + APIUsageStatisticsClientConstants.OTHER_LATENCY + ";");
        JSONObject jsonObj = APIUtil.executeQueryOnStreamProcessor(
                APIUsageStatisticsClientConstants.APIM_ACCESS_SUMMARY_SIDDHI_APP, query.toString());
        long timeStamp;
        if (jsonObj != null) {
            JSONArray jArray = (JSONArray) jsonObj.get(APIUsageStatisticsClientConstants.RECORDS_DELIMITER);
            for (Object record : jArray) {
                JSONArray recordArray = (JSONArray) record;
                if (recordArray.size() == 12) {
                    Result<ExecutionTimeOfAPIValues> result1 = new Result<ExecutionTimeOfAPIValues>();
                    ExecutionTimeOfAPIValues executionTimeOfAPIValues = new ExecutionTimeOfAPIValues();
                    executionTimeOfAPIValues.setApi((String) recordArray.get(0));
                    executionTimeOfAPIValues.setContext((String) recordArray.get(1));
                    executionTimeOfAPIValues.setApiPublisher((String) recordArray.get(2));
                    executionTimeOfAPIValues.setVersion((String) recordArray.get(3));
                    timeStamp = (Long) recordArray.get(4);
                    DateTime time = new DateTime(timeStamp).withZone(DateTimeZone.UTC);
                    executionTimeOfAPIValues.setYear(time.getYear());
                    executionTimeOfAPIValues.setMonth(time.getMonthOfYear());
                    executionTimeOfAPIValues.setDay(time.getDayOfMonth());
                    executionTimeOfAPIValues.setHour(time.getHourOfDay());
                    executionTimeOfAPIValues.setMinutes(time.getMinuteOfHour());
                    executionTimeOfAPIValues.setSeconds(time.getSecondOfMinute());
                    executionTimeOfAPIValues.setApiResponseTime((Long) recordArray.get(5));
                    executionTimeOfAPIValues.setSecurityLatency((Long) recordArray.get(6));
                    executionTimeOfAPIValues.setThrottlingLatency((Long) recordArray.get(7));
                    executionTimeOfAPIValues.setRequestMediationLatency((Long) recordArray.get(8));
                    executionTimeOfAPIValues.setResponseMediationLatency((Long) recordArray.get(9));
                    executionTimeOfAPIValues.setBackendLatency((Long) recordArray.get(10));
                    executionTimeOfAPIValues.setOtherLatency((Long) recordArray.get(11));
                    result1.setValues(executionTimeOfAPIValues);
                    result1.setTableName(APIUsageStatisticsClientConstants.API_EXECUTION_TIME_AGG);
                    result1.setTimestamp(RestClientUtil.longToDate(new Date().getTime()));
                    result.add(result1);
                }
            }
        }
        if (!result.isEmpty() && fromDate != null && toDate != null) {
            insertZeroElementsAndSort(result, drillDown, getDateToLong(fromDate), getDateToLong(toDate));
        }
    } catch (APIManagementException e) {
        handleException("Error occurred while querying from Stream Processor ", e);
    } catch (ParseException e) {
        handleException("Couldn't parse the date", e);
    }
    return result;
}

From source file:org.xmlcml.euclid.JodaDate.java

License:Apache License

@SuppressWarnings("deprecation")
public static Date parseJodaDate(DateTime jodaDate) {
    int year = jodaDate.getYear();
    int month = jodaDate.getMonthOfYear();
    int day = jodaDate.getDayOfMonth();
    int hour = jodaDate.getHourOfDay();
    int min = jodaDate.getMinuteOfDay();
    int sec = jodaDate.getSecondOfMinute();
    // arghh/* w  w  w. j  a v a2s. c o  m*/
    Date date = new Date(year - 1900, month, day, hour, min, sec);
    return date;
}

From source file:proxi.model.ProxiCSVWriter.java

License:Open Source License

private static String[] dateTimeCutter(DateTime dt) {
    String[] dtParts = new String[6];

    String year = "" + dt.getYear();
    String month = fixWith2Chars(dt.getMonthOfYear());
    String day = fixWith2Chars(dt.getDayOfMonth());
    String hour = fixWith2Chars(dt.getHourOfDay());
    String minute = fixWith2Chars(dt.getMinuteOfHour());
    String second = fixWith2Chars(dt.getSecondOfMinute());

    dtParts[0] = year;/*from  w ww.ja v  a 2  s .c  om*/
    dtParts[1] = month;
    dtParts[2] = day;
    dtParts[3] = hour;
    dtParts[4] = minute;
    dtParts[5] = second;

    return dtParts;

}

From source file:pt.ist.fenixedu.integration.api.FenixAPIv1.java

License:Open Source License

private SummariesManagementBean fillSummaryManagementBean(ExecutionCourse executionCourse, Shift shift,
        Space space, String date, JsonObject title, JsonObject content, Boolean taught, int attendance) {

    MultiLanguageString titleMLS, contentMLS;
    try {//from  w  ww .ja  va 2s.  c  o  m
        titleMLS = MultiLanguageString.fromLocalizedString(LocalizedString.fromJson(title));
        contentMLS = MultiLanguageString.fromLocalizedString(LocalizedString.fromJson(content));
    } catch (Exception e) {
        throw newApplicationError(Status.PRECONDITION_FAILED, "invalid parameters",
                "'title' or 'content' is not a valid multi-language string");
    }

    DateTime lessonDateTime = DateTimeFormat.forPattern(dayHourSecondPattern).parseDateTime(date);
    YearMonthDay lessonDate = lessonDateTime.toYearMonthDay();
    Partial lessonTime = new Partial().with(DateTimeFieldType.hourOfDay(), lessonDateTime.getHourOfDay())
            .with(DateTimeFieldType.minuteOfHour(), lessonDateTime.getMinuteOfHour())
            .with(DateTimeFieldType.secondOfDay(), lessonDateTime.getSecondOfMinute());

    Optional<Lesson> lesson = shift.getAssociatedLessonsSet().stream()
            .filter(l -> l.getAllLessonDates().stream().anyMatch(lessonDate::equals))
            .filter(l -> l.getSala().equals(space)).findFirst();

    if (!lesson.isPresent()) {
        throw newApplicationError(Status.PRECONDITION_FAILED, "invalid parameters",
                "invalid lesson date or room");
    }

    Person person = getPerson();
    Professorship professorship = executionCourse.getProfessorship(person);
    String teacherName = person.getName();
    LessonInstance lessonInstance = lesson.get().getLessonInstanceFor(lessonDate);
    Summary summary = lessonInstance != null ? lessonInstance.getSummary() : null;
    ShiftType shiftType = shift.getSortedTypes().first();

    return new SummariesManagementBean(titleMLS, contentMLS, attendance, NORMAL_SUMMARY, professorship,
            teacherName, null, shift, lesson.get(), lessonDate, space, lessonTime, summary, professorship,
            shiftType, taught);
}

From source file:pt.utl.ist.codeGenerator.database.WrittenTestsRoomManager.java

License:Open Source License

public DateTime getNextDateTime(final ExecutionSemester executionPeriod) {
    EvaluationRoomManager evaluationRoomManager = evaluationRoomManagerMap.get(executionPeriod);
    if (evaluationRoomManager == null) {
        evaluationRoomManager = new EvaluationRoomManager(
                executionPeriod.getBeginDateYearMonthDay().plusMonths(1).toDateTimeAtMidnight(),
                executionPeriod.getEndDateYearMonthDay().minusDays(31).toDateTimeAtMidnight(), 120, this);
        evaluationRoomManagerMap.put(executionPeriod, evaluationRoomManager);
    }// w  ww. ja  va 2  s . com

    DateTime dateTime;
    Space oldRoom;

    do {
        dateTime = evaluationRoomManager.getNextDateTime();
        oldRoom = evaluationRoomManager.getNextOldRoom();

    } while (SpaceUtils.isFree(oldRoom, dateTime.toYearMonthDay(), dateTime.plusMinutes(120).toYearMonthDay(),
            new HourMinuteSecond(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(),
                    dateTime.getSecondOfMinute()),
            dateTime.plusMinutes(120).getHourOfDay() == 0
                    ? new HourMinuteSecond(dateTime.plusMinutes(119).getHourOfDay(),
                            dateTime.plusMinutes(119).getMinuteOfHour(),
                            dateTime.plusMinutes(119).getSecondOfMinute())
                    : new HourMinuteSecond(dateTime.plusMinutes(120).getHourOfDay(),
                            dateTime.plusMinutes(120).getMinuteOfHour(),
                            dateTime.plusMinutes(120).getSecondOfMinute()),
            new DiaSemana(dateTime.getDayOfWeek() + 1), FrequencyType.DAILY, Boolean.TRUE, Boolean.TRUE));
    return dateTime;
}

From source file:stroom.pipeline.server.writer.PathCreator.java

License:Apache License

public static String replaceTimeVars(String path) {
    // Replace some of the path elements with system variables.
    final DateTime dateTime = new DateTime(DateTimeZone.UTC);
    path = replace(path, "year", dateTime.getYear(), 4);
    path = replace(path, "month", dateTime.getMonthOfYear(), 2);
    path = replace(path, "day", dateTime.getDayOfMonth(), 2);
    path = replace(path, "hour", dateTime.getHourOfDay(), 2);
    path = replace(path, "minute", dateTime.getMinuteOfHour(), 2);
    path = replace(path, "second", dateTime.getSecondOfMinute(), 2);
    path = replace(path, "millis", dateTime.getMillisOfSecond(), 3);
    path = replace(path, "ms", dateTime.getMillis(), 0);

    return path;/*from   w ww.  ja v a2s  .co m*/
}

From source file:test.sql.CustomerDataManager.java

License:Apache License

public String makeSubject() {
    // String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8);

    DateTime now = new DateTime();
    int year, month, day, hour, minute, second;
    year = now.year().get();/*from  ww  w . j  av a 2 s  .  com*/
    month = now.monthOfYear().get();
    day = now.dayOfMonth().get();
    hour = now.getHourOfDay();
    minute = now.getMinuteOfHour();
    second = now.getSecondOfMinute();

    StringBuilder sb = new StringBuilder();
    sb.append(LINKAGE_SUBJECT_PREFIX);
    sb.append(StressTester.randomString(8));
    sb.append("_");
    sb.append(Integer.toString(year));
    if (month < 10)
        sb.append("0");
    sb.append(Integer.toString(month));
    if (day < 10)
        sb.append("0");
    sb.append(Integer.toString(day));
    sb.append("_");
    if (hour < 10)
        sb.append("0");
    sb.append(Integer.toString(hour));
    if (minute < 10)
        sb.append("0");
    sb.append(Integer.toString(minute));
    if (second < 10)
        sb.append("0");
    sb.append(Integer.toString(second));

    return sb.toString();
}

From source file:test.sql.TrackingDataManager.java

License:Apache License

public String makeSubject() {
    String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8);

    DateTime now = new DateTime();
    int year, month, day, hour, minute, second;
    year = now.year().get();/*www.  jav a2 s  .c  o  m*/
    month = now.monthOfYear().get();
    day = now.dayOfMonth().get();
    hour = now.getHourOfDay();
    minute = now.getMinuteOfHour();
    second = now.getSecondOfMinute();

    StringBuilder sb = new StringBuilder();
    sb.append(LINKAGE_SUBJECT_PREFIX);
    sb.append(StressTester.randomString(8));
    sb.append("_");
    sb.append(Integer.toString(year));
    if (month < 10)
        sb.append("0");
    sb.append(Integer.toString(month));
    if (day < 10)
        sb.append("0");
    sb.append(Integer.toString(day));
    sb.append("_");
    if (hour < 10)
        sb.append("0");
    sb.append(Integer.toString(hour));
    if (minute < 10)
        sb.append("0");
    sb.append(Integer.toString(minute));
    if (second < 10)
        sb.append("0");
    sb.append(Integer.toString(second));

    return sb.toString();
}