Example usage for org.joda.time.format ISODateTimeFormat dateTime

List of usage examples for org.joda.time.format ISODateTimeFormat dateTime

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat dateTime.

Prototype

public static DateTimeFormatter dateTime() 

Source Link

Document

Returns a formatter that combines a full date and time, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ss.SSSZZ).

Usage

From source file:org.graylog2.indexer.searches.timeranges.AbsoluteRange.java

License:Open Source License

public AbsoluteRange(String from, String to) throws InvalidRangeParametersException {
    if (from == null || from.isEmpty() || to == null || to.isEmpty()) {
        throw new InvalidRangeParametersException();
    }/*  w  w w .jav a  2s.  c  o  m*/

    try {
        if (from.contains("T")) {
            this.from = DateTime.parse(from, ISODateTimeFormat.dateTime());
        } else {
            this.from = DateTime.parse(from, Tools.timeFormatterWithOptionalMilliseconds());
        }
        if (to.contains("T")) {
            this.to = DateTime.parse(to, ISODateTimeFormat.dateTime());
        } else {
            this.to = DateTime.parse(to, Tools.timeFormatterWithOptionalMilliseconds());
        }
    } catch (IllegalArgumentException e) {
        throw new InvalidRangeParametersException();
    }
}

From source file:org.graylog2.plugin.Tools.java

License:Open Source License

public static String getISO8601String(DateTime time) {
    return ISODateTimeFormat.dateTime().print(time);
}

From source file:org.graylog2.restclient.models.ClusterService.java

License:Open Source License

public long getIndexerFailureCountLast24Hours() throws APIException, IOException {
    IndexerFailureCountResponse r = api//from   w w  w .  ja va  2  s .c o  m
            .path(routes.FailuresResource().count(), IndexerFailureCountResponse.class).queryParam("since",
                    ISODateTimeFormat.dateTime().print(new DateTime(DateTimeZone.UTC).minusDays(1)))
            .execute();

    return r.count;
}

From source file:org.hbird.business.groundstation.base.TrackingSupport.java

License:Apache License

/**
 * @see org.hbird.exchange.groundstation.ITrackingDevice#track(org.hbird.exchange.groundstation.Track)
 *///from  w  w  w .  j  a va2s  . c o  m
@Override
public List<CommandBase> track(Track command) {
    LOG.debug("Creating tracking commands ...");
    List<String> missing = command.checkArguments();
    if (!missing.isEmpty()) {
        LOG.error("Missing command arguments for the command '{}' - '{}'; tracking not possible",
                command.getClass().getSimpleName(), missing);
        return NO_COMMANDS;
    }

    LocationContactEvent contact = command.getLocationContactEvent();
    Satellite satellite = command.getSatellite();

    if (!validateArgument(contact, StandardArguments.START)) {
        return NO_COMMANDS;
    }
    if (!validateArgument(satellite, StandardArguments.SATELLITE_ID)) {
        return NO_COMMANDS;
    }

    String groundStationId = configuration.getGroundstationId();
    GroundStation groundStation = null;
    try {
        groundStation = (GroundStation) dao.resolve(groundStationId);
    } catch (Exception e) {
        LOG.error("Failed to resolve groundstation for the ID '{}'", groundStationId, e);
        return NO_COMMANDS;
    }

    if (groundStation == null) {
        LOG.error("GroundStation not found for the ID '{}'", groundStationId);
        return NO_COMMANDS;
    }

    long now = System.currentTimeMillis();
    long contactStartTime = contact.getStartTime();

    if (!validateByTime(contactStartTime, now, configuration.isSkipOutDatedCommands())) {
        return NO_COMMANDS;
    }

    if (!isTrackingPossible(contact, groundStation, satellite)) {
        return NO_COMMANDS;
    }

    ContactParameterRange azimuth = contact.getAzimuth();
    ExtendedContactParameterRange elevation = contact.getElevation();
    ContactParameterRange doppler = contact.getDoppler();
    LOG.info("Creating tracking commands for the satellite '{}' in the ground station '{}'", satellite,
            groundStation);
    LOG.info("   Contact - start: {}; end: {}", Dates.toDefaultDateFormat(contactStartTime),
            Dates.toDefaultDateFormat(contact.getEndTime()));
    LOG.info("   Azimuth - start: {}; end: {}", azimuth.getStart(), azimuth.getEnd());
    LOG.info("   Elevation - max: {}", elevation.getMax());
    LOG.info("   Doppler - start: {}; end: {}", doppler.getStart(), doppler.getEnd());

    List<PointingData> pointingData = null;
    try {
        pointingData = orbitDataCalculator.calculateContactData(contact, groundStation,
                configuration.getCommandInterval());
    } catch (Exception e) {
        LOG.error(
                "Failed to calculate pointing data for the contact; ground station: '{}'; satellite: '{}'; contact start time: '{}'; Exception: ",
                new Object[] { groundStation.getGroundStationID(), satellite.getSatelliteID(),
                        Dates.toIso8601DateFormat(contactStartTime), e });
        return NO_COMMANDS;
    }

    LOG.debug("Optimizing pointing data");
    pointingData = optimize(pointingData, configuration, optimizer);
    LOG.debug("Pointing data optimized");

    List<CommandBase> commands = new LinkedList<CommandBase>();
    commands.addAll(createPreContactCommands(groundStation, satellite, pointingData, configuration, command));
    commands.addAll(createContactCommands(groundStation, satellite, pointingData, configuration, command));
    commands.addAll(createPostContactCommands(groundStation, satellite, pointingData, configuration, command));

    int size = commands.size();
    String firstCommand = new DateTime(commands.get(0).getExecutionTime())
            .toString(ISODateTimeFormat.dateTime());
    String lastCommand = new DateTime(commands.get(size - 1).getExecutionTime())
            .toString(ISODateTimeFormat.dateTime());
    LOG.info(
            "Created {} tracking commands for the satellite '{}' in groundstation '{}'; first command at {}; last command at {}",
            new Object[] { size, satellite, groundStation, firstCommand, lastCommand });

    return commands;
}

From source file:org.iexhub.connectors.PDQQueryManager.java

License:Apache License

/**
 * @param queryText//from   w w  w.ja  v  a  2s. co m
 * @param patientId
 * @throws IOException
 */
private void logIti47AuditMsg(String queryText, String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti47AuditMsgTemplate));

    // Substitutions...
    patientId = patientId.replace("'", "");
    patientId = patientId.replace("&", "&amp;");

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", PDQQueryManager.endpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    logMsg = logMsg.replace("$PatientIdMtom$", Base64.getEncoder().encodeToString(patientId.getBytes()));

    logMsg = logMsg.replace("$QueryByParameterMtom$", Base64.getEncoder().encodeToString(queryText.getBytes()));

    logMsg = logMsg.replace("$PatientId$", patientId);

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti47AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}

From source file:org.iexhub.connectors.PIXManager.java

License:Apache License

/**
 * @param patientId/*from www . j av a 2s.com*/
 * @throws IOException
 */
private void logIti44AuditMsg(String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti44AuditMsgTemplate));

    // Substitutions...
    patientId = patientId.replace("'", "");
    patientId = patientId.replace("&", "&amp;");

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", PIXManager.endpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    logMsg = logMsg.replace("$PatientIdMtom$", Base64.getEncoder().encodeToString(patientId.getBytes()));

    logMsg = logMsg.replace("$PatientId$", patientId);

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti44AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}

From source file:org.iexhub.connectors.PIXManager.java

License:Apache License

/**
 * @param queryText/*  ww  w.j  a  va  2  s  .  c  o m*/
 * @param patientId
 * @throws IOException
 */
private void logIti45AuditMsg(String queryText, String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti45AuditMsgTemplate));

    // Substitutions...
    patientId = patientId.replace("'", "");
    patientId = patientId.replace("&", "&amp;");

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", PIXManager.endpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    // Query text must be Base64 encoded...
    logMsg = logMsg.replace("$PixQueryMtom$", Base64.getEncoder().encodeToString(queryText.getBytes()));

    logMsg = logMsg.replace("$PatientIdMtom$", Base64.getEncoder().encodeToString(patientId.getBytes()));

    logMsg = logMsg.replace("$PatientId$", patientId);

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti45AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}

From source file:org.iexhub.connectors.XdsB.java

License:Apache License

/**
 * @param queryText/*  w  ww .j  av a 2 s. c  om*/
 * @param patientId
 * @throws IOException
 */
private void logIti18AuditMsg(String queryText, String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti18AuditMsgTemplate));

    // Substitutions...
    if ((patientId != null) && (patientId.length() > 0)) {
        patientId = patientId.replace("'", "");
        patientId = patientId.replace("&", "&amp;");
    } else {
        patientId = new String("");
    }

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", XdsB.registryEndpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    // Query text must be Base64 encoded...
    logMsg = logMsg.replace("$RegistryQueryMtom$", Base64.getEncoder().encodeToString(queryText.getBytes()));

    logMsg = logMsg.replace("$PatientId$", patientId);

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti18AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}

From source file:org.iexhub.connectors.XdsB.java

License:Apache License

/**
 * @param documentId//  w  w  w.j  a v  a 2  s  . c o m
 * @param repositoryUniqueId
 * @param homeCommunityId
 * @param patientId
 * @throws IOException
 */
private void logIti43AuditMsg(String documentId, String repositoryUniqueId, String homeCommunityId,
        String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti43AuditMsgTemplate));

    // Substitutions...
    if ((patientId != null) && (patientId.length() > 0)) {
        patientId = patientId.replace("'", "");
        patientId = patientId.replace("&", "&amp;");
    } else {
        patientId = new String("");
    }

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", XdsB.registryEndpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    // Repository ID text must be Base64 encoded...
    logMsg = logMsg.replace("$RepositoryIdMtom$",
            Base64.getEncoder().encodeToString(repositoryUniqueId.getBytes()));

    logMsg = logMsg.replace("$PatientId$", patientId);

    logMsg = logMsg.replace("$DocumentId$", documentId);

    if (homeCommunityId != null) {
        logMsg = logMsg.replace("$HomeCommunityId$", homeCommunityId);
    } else {
        logMsg = logMsg.replace("$HomeCommunityId$", "");
    }

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti43AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}

From source file:org.iexhub.connectors.XdsBRepositoryManager.java

License:Apache License

/**
 * @param submissionSetId/*from   www.  j av  a 2  s.  c  om*/
 * @param patientId
 * @throws IOException
 */
private void logIti41AuditMsg(String submissionSetId, String patientId) throws IOException {
    String logMsg = FileUtils.readFileToString(new File(iti41AuditMsgTemplate));

    // Substitutions...
    patientId = patientId.replace("'", "");
    patientId = patientId.replace("&", "&amp;");

    DateTime now = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    logMsg = logMsg.replace("$DateTime$", fmt.print(now));

    logMsg = logMsg.replace("$AltUserId$", "IExHub");

    logMsg = logMsg.replace("$IexhubIpAddress$", InetAddress.getLocalHost().getHostAddress());

    logMsg = logMsg.replace("$IexhubUserId$", "http://" + InetAddress.getLocalHost().getCanonicalHostName());

    logMsg = logMsg.replace("$DestinationIpAddress$", XdsBRepositoryManager.repositoryEndpointUri);

    logMsg = logMsg.replace("$DestinationUserId$", "IExHub");

    logMsg = logMsg.replace("$PatientId$", patientId);

    logMsg = logMsg.replace("$SubmissionSetId$", submissionSetId);

    if (logSyslogAuditMsgsLocally) {
        log.info(logMsg);
    }

    if ((sysLogConfig == null) || (iti41AuditMsgTemplate == null)) {
        return;
    }

    // Log the syslog message and close connection
    Syslog.getInstance("sslTcp").info(logMsg);
    Syslog.getInstance("sslTcp").flush();
}