Example usage for org.joda.time.format DateTimeFormatter parseDateTime

List of usage examples for org.joda.time.format DateTimeFormatter parseDateTime

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter parseDateTime.

Prototype

public DateTime parseDateTime(String text) 

Source Link

Document

Parses a date-time from the given text, returning a new DateTime.

Usage

From source file:com.sonicle.webtop.vfs.Service.java

License:Open Source License

public void processWizardDownloadLink(HttpServletRequest request, HttpServletResponse response,
        PrintWriter out) {//from   w w w.  j ava2 s.  c  o  m
    UserProfile up = getEnv().getProfile();

    try {
        String crud = ServletUtils.getStringParameter(request, "crud", true);
        if (crud.equals("s2")) {
            String fileId = ServletUtils.getStringParameter(request, "fileId", true);
            String expirationDate = ServletUtils.getStringParameter(request, "expirationDate", null);
            String authMode = ServletUtils.getStringParameter(request, "authMode", true);
            String password = ServletUtils.getStringParameter(request, "password", null);

            StoreNodeId nodeId = (StoreNodeId) new StoreNodeId().parse(fileId);
            int storeId = Integer.valueOf(nodeId.getStoreId());

            DateTimeFormatter ymdHmsFmt = DateTimeUtils.createYmdHmsFormatter(up.getTimeZone());
            SharingLink dl = new SharingLink();
            dl.setType(SharingLink.TYPE_DOWNLOAD);
            dl.setStoreId(storeId);
            dl.setFilePath(nodeId.getPath());
            if (!StringUtils.isBlank(expirationDate)) {
                DateTime dt = ymdHmsFmt.parseDateTime(expirationDate);
                dl.setExpiresOn(DateTimeUtils.withTimeAtEndOfDay(dt));
            }
            dl.setAuthMode(authMode);
            dl.setPassword(password);
            dl = manager.addDownloadLink(dl);

            String servicePublicUrl = WT.getServicePublicUrl(up.getDomainId(), SERVICE_ID);
            JsWizardData data = new JsWizardData();
            data.put("urls", VfsManager.generateLinkPublicURLs(servicePublicUrl, dl));
            new JsonResult(data).printTo(out);
        }

    } catch (Exception ex) {
        logger.error("Error in WizardDownloadLink", ex);
        new JsonResult(false, ex.getMessage()).printTo(out);
    }
}

From source file:com.sonicle.webtop.vfs.Service.java

License:Open Source License

public void processWizardUploadLink(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    UserProfile up = getEnv().getProfile();

    try {//  w ww.  ja  va 2  s.  c o  m
        String crud = ServletUtils.getStringParameter(request, "crud", true);
        if (crud.equals("s2")) {
            String fileId = ServletUtils.getStringParameter(request, "fileId", true);
            String expirationDate = ServletUtils.getStringParameter(request, "expirationDate", null);
            String authMode = ServletUtils.getStringParameter(request, "authMode", true);
            String password = ServletUtils.getStringParameter(request, "password", null);

            StoreNodeId nodeId = (StoreNodeId) new StoreNodeId().parse(fileId);
            int storeId = Integer.valueOf(nodeId.getStoreId());

            DateTimeFormatter ymdHmsFmt = DateTimeUtils.createYmdHmsFormatter(up.getTimeZone());
            SharingLink ul = new SharingLink();
            ul.setType(SharingLink.TYPE_UPLOAD);
            ul.setStoreId(storeId);
            ul.setFilePath(nodeId.getPath());
            if (!StringUtils.isBlank(expirationDate)) {
                DateTime dt = ymdHmsFmt.parseDateTime(expirationDate);
                ul.setExpiresOn(DateTimeUtils.withTimeAtEndOfDay(dt));
            }
            ul.setAuthMode(authMode);
            ul.setPassword(password);
            ul = manager.addUploadLink(ul);

            String servicePublicUrl = WT.getServicePublicUrl(up.getDomainId(), SERVICE_ID);
            JsWizardData data = new JsWizardData();
            data.put("urls", VfsManager.generateLinkPublicURLs(servicePublicUrl, ul));
            new JsonResult(data).printTo(out);
        }

    } catch (Exception ex) {
        logger.error("Error in WizardUploadLink", ex);
        new JsonResult(false, ex.getMessage()).printTo(out);
    }
}

From source file:com.sos.jobnet.utils.TimeKeyCalculator.java

License:Apache License

public TimeKeyCalculator(String timeKey, DateTimeFormatter format, DurationFieldType type) {
    this.timeKey = timeKey;
    this.format = format;
    this.type = type;
    this.timeValue = format.parseDateTime(timeKey);
    this.calculatedTimeValue = timeValue.toMutableDateTime();
}

From source file:com.sos.scheduler.model.objects.JSObjAt.java

License:Apache License

public DateTime getDtAt() {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    return fmtDate.parseDateTime(getAt());
}

From source file:com.sos.scheduler.model.objects.JSObjDate.java

License:Apache License

public DateTime getDtDate() {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    return fmtDate.parseDateTime(getDate());
}

From source file:com.sos.scheduler.model.objects.JSObjHoliday.java

License:Apache License

public DateTime getDtHoliday() {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    return fmtDate.parseDateTime(getDate());
}

From source file:com.sos.scheduler.model.objects.JSObjPeriod.java

License:Apache License

private static DateTime getDate(DateTime baseDate, String timeString) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter fmtDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    String dateString = fmtDate.print(baseDate) + " ";
    return fmtDateTime.parseDateTime(dateString + timeString);
}

From source file:com.superrent.modules.CommonFunc.java

public static int compareDates(String first, String second) throws ParseException {

    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    DateTime firstdt = f.parseDateTime(first);
    DateTime seconddt = f.parseDateTime(second);

    return firstdt.compareTo(seconddt);
}

From source file:com.thinkbiganalytics.Formatters.java

License:Apache License

/**
 * convert the String to a DateTime field using the defined formatters
 */// w  w  w.ja v  a  2s .c o  m
public static DateTime parseDateTime(String timeStr) {
    for (DateTimeFormatter formatter : DATE_TIME_FORMATTERS) {
        try {
            return formatter.parseDateTime(timeStr);
        } catch (IllegalArgumentException e) {
        }
    }

    throw new IllegalArgumentException(
            "Date/time cannot be parsed - acceptable examples: " + getDateTimeExamples());
}

From source file:com.thoughtworks.studios.shine.cruise.GoDateTime.java

License:Apache License

public static DateTime parseToUTC(String timestampString) throws GoDateTimeException {

    DateTimeFormatter format = ISODateTimeFormat.dateTimeNoMillis();
    DateTime dateTime;/*from  ww  w  . j  a  va2s  .c  om*/
    try {
        dateTime = format.parseDateTime(timestampString);
    } catch (java.lang.IllegalArgumentException e) {
        // sigh. handle old cruise timestamp format, e.g. 2008-09-19 02:18:39 +0800
        format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss Z");
        try {
            dateTime = format.parseDateTime(timestampString);
        } catch (java.lang.IllegalArgumentException e2) {
            // give up !!
            throw new GoDateTimeException("Could not parse datetime " + timestampString, e2);
        }
    }
    return dateTime.toDateTime(DateTimeZone.forID("UTC"));
}