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.archfirst.common.datetime.DateTimeUtil.java

License:Apache License

public static final String toStringISODateTime(DateTime instant) {
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return instant.toString(fmt);
}

From source file:org.archfirst.common.datetime.DateTimeUtil.java

License:Apache License

public static final DateTime parseISODateTime(String strDateTime) {
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return fmt.parseDateTime(strDateTime);
}

From source file:org.arrow.util.TriggerUtils.java

License:Apache License

/**
 * Indicates if the given scheduler string is in ISO8601 format.
 * //from   w  w w  .j  a  va 2s .  c  o  m
 * @param str the ISO 8601 string
 * @return boolean
 */
public static boolean isIso8601(String str) {
    try {
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        fmt.parseDateTime(str);
        return true;
    } catch (IllegalArgumentException ex) {
        return false;
    }
}

From source file:org.artifactory.bintray.BintrayServiceImpl.java

License:Open Source License

private void fixDateFormat(List<BintrayItemInfo> listResult) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Build.STARTED_FORMAT);
    for (BintrayItemInfo bintrayItemInfo : listResult) {
        String createdDateFromBintray = bintrayItemInfo.getCreated();
        long createdDate = ISODateTimeFormat.dateTime().parseMillis(createdDateFromBintray);
        bintrayItemInfo.setCreated(simpleDateFormat.format(new Date(createdDate)));
    }//w w  w . j  a v  a 2 s .c  om
}

From source file:org.artifactory.build.BuildPromotionHelper.java

License:Open Source License

private void performPromotionIfNeeded(BasicStatusHolder statusHolder, Build build, Promotion promotion) {
    String status = promotion.getStatus();

    if (statusHolder.hasErrors() || statusHolder.hasWarnings()) {
        statusHolder.status(/*from  w ww. java2 s .  co  m*/
                "Skipping promotion status update: item promotion was completed with errors " + "and warnings.",
                log);
        return;
    }

    if (StringUtils.isBlank(status)) {
        statusHolder.status("Skipping promotion status update: no status received.", log);
        return;
    }

    PromotionStatusBuilder statusBuilder = new PromotionStatusBuilder(status)
            .user(authorizationService.currentUsername()).repository(promotion.getTargetRepo())
            .comment(promotion.getComment()).ciUser(promotion.getCiUser());

    String timestamp = promotion.getTimestamp();

    if (StringUtils.isNotBlank(timestamp)) {
        try {
            ISODateTimeFormat.dateTime().parseMillis(timestamp);
        } catch (Exception e) {
            statusHolder.error(
                    "Skipping promotion status update: invalid\\unparsable timestamp " + timestamp + ".", log);
            return;
        }
        statusBuilder.timestamp(timestamp);
    } else {
        statusBuilder.timestampDate(new Date());
    }

    if (promotion.isDryRun()) {
        return;
    }

    buildService.addPromotionStatus(build, statusBuilder.build());
    log.info("Promotion completed successfully for build name '{}' and number '{}' with status of '{}'",
            build.getName(), build.getNumber(), status);
}

From source file:org.artifactory.engine.SuccessfulDeploymentResponseHelper.java

License:Open Source License

private RestFolderInfo getFolderInfo(InternalRepositoryService repoService, RepoPath repoPath, String url) {
    RestFolderInfo folderInfo = new RestFolderInfo();
    FolderInfo createdFolder = repoService.getFolderInfo(repoPath);
    folderInfo.created = ISODateTimeFormat.dateTime().print(createdFolder.getCreated());
    folderInfo.createdBy = createdFolder.getCreatedBy();
    folderInfo.path = PathUtils.addTrailingSlash("/" + repoPath.getPath());
    folderInfo.repo = repoPath.getRepoKey();
    folderInfo.slf = PathUtils.addTrailingSlash(url);
    return folderInfo;
}

From source file:org.artifactory.engine.SuccessfulDeploymentResponseHelper.java

License:Open Source License

private RestFileInfo getFileInfo(InternalRepositoryService repoService, RepoPath repoPath, String url) {
    RestFileInfo fileInfo = new RestFileInfo();
    FileInfo deployedInfo = repoService.getFileInfo(repoPath);
    ChecksumsInfo checksumsInfo = deployedInfo.getChecksumsInfo();
    fileInfo.checksums = getActualChecksums(checksumsInfo);
    fileInfo.created = ISODateTimeFormat.dateTime().print(deployedInfo.getCreated());
    fileInfo.createdBy = deployedInfo.getCreatedBy();
    fileInfo.downloadUri = url;/*from ww  w. j  av  a 2s  . c om*/
    fileInfo.mimeType = deployedInfo.getMimeType();
    fileInfo.originalChecksums = getOriginalChecksums(checksumsInfo);
    fileInfo.path = "/" + repoPath.getPath();
    fileInfo.repo = repoPath.getRepoKey();
    fileInfo.size = String.valueOf(deployedInfo.getSize());
    fileInfo.slf = url;
    return fileInfo;
}

From source file:org.artifactory.post.services.CallHomeService.java

License:Open Source License

/**
 * Produces callHomeEntity/*  w w w. j a  v a 2 s  . co  m*/
 *
 * @return {@link HttpEntity}
 *
 * @throws IOException on serialization errors
 */
private HttpEntity callHomeEntity() throws IOException {
    CallHomeRequest request = new CallHomeRequest();
    request.version = artifactoryVersion.getString();
    request.licenseType = getLicenseType();
    request.licenseOEM = addonsManager.isPartnerLicense() ? "VMware" : null;
    Date licenseValidUntil = addonsManager.getLicenseValidUntil();
    if (licenseValidUntil != null) {
        request.licenseExpiration = ISODateTimeFormat.dateTime().print(new DateTime(licenseValidUntil));
    }
    request.setDist(System.getProperty("artdist"));
    request.environment.hostId = addonsManager.addonByType(HaCommonAddon.class).getHostId();
    request.environment.licenseHash = addonsManager.getLicenseKeyHash();
    request.environment.attributes.osName = System.getProperty(PARAM_OS_NAME);
    request.environment.attributes.osArch = System.getProperty(PARAM_OS_ARCH);
    request.environment.attributes.javaVersion = System.getProperty(PARAM_JAVA_VERSION);

    addFeatures(request);

    return serializeToStringEntity(request);
}

From source file:org.artifactory.repo.remote.browse.S3RepositoryBrowser.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
private List<RemoteItem> parseResponse(String content) {
    List<RemoteItem> items = Lists.newArrayList();
    Document document = XmlUtils.parse(content);
    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();
    String prefix = root.getChildText("Prefix", ns);

    // retrieve folders
    List<Element> folders = root.getChildren("CommonPrefixes", ns);
    for (Element folder : folders) {
        String directoryPath = folder.getChildText("Prefix", ns);
        String folderName = StringUtils.removeStart(directoryPath, prefix);
        if (StringUtils.isNotBlank(folderName)) {
            if (secured) {
                directoryPath = StringUtils.removeStart(directoryPath, getPrefix(rootUrl));
            }/*from   w  w  w  .  j  a va2  s .co m*/
            items.add(new RemoteItem(rootUrl + directoryPath, true));
        }
    }

    // retrieve files
    List<Element> files = root.getChildren("Contents", ns);
    for (Element element : files) {
        String filePath = element.getChildText("Key", ns);
        String fileName = StringUtils.removeStart(filePath, prefix);
        if (StringUtils.isNotBlank(fileName) && !folderDirectoryWithSameNameExists(fileName, items)) {
            // the date format is of the form yyyy-mm-ddThh:mm:ss.timezone, e.g., 2009-02-03T16:45:09.000Z
            String sizeStr = element.getChildText("Size", ns);
            long size = sizeStr == null ? 0 : Long.parseLong(sizeStr);
            String lastModifiedStr = element.getChildText("LastModified", ns);
            long lastModified = lastModifiedStr == null ? 0
                    : ISODateTimeFormat.dateTime().parseMillis(lastModifiedStr);
            if (secured) {
                RemoteItem remoteItem = new RemoteItem(rootUrl + filePath, false, size, lastModified);
                String filePath2 = StringUtils.removeStart(filePath, getPrefix(rootUrl));
                String url = rootUrl + filePath2;
                String securedPath = buildSecuredS3RequestUrl(url, httpRepo, getPrefix(url));
                remoteItem.setEffectiveUrl(securedPath);
                items.add(remoteItem);
            } else {
                items.add(new RemoteItem(rootUrl + filePath, false, size, lastModified));
            }
        }
    }

    return items;
}

From source file:org.artifactory.request.TraceLoggingRepoRequestContext.java

License:Open Source License

@Override
public void log(String message) {
    super.log(message);
    ((TraceLoggingResponse) getArtifactoryResponse())
            .log(ISODateTimeFormat.dateTime().print(System.currentTimeMillis()) + " " + message);
}