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.wso2.carbon.apimgt.rest.api.util.utils.RestApiUtil.java

License:Open Source License

/**
 * Returns date in RFC3339 format./*from  w w w .  j a  va 2s.co m*/
 * Example: 2008-11-13T12:23:30-08:00
 *
 * @param date Date object
 * @return date string in RFC3339 format.
 */
public static String getRFC3339Date(Date date) {
    DateTimeFormatter jodaDateTimeFormatter = ISODateTimeFormat.dateTime();
    DateTime dateTime = new DateTime(date);
    return jodaDateTimeFormatter.print(dateTime);
}

From source file:org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment.util.MessageHandler.java

License:Open Source License

/**
 * This method adds Timestamp for SOAP header, and adds Content-length for HTTP header for
 * avoiding HTTP chunking./*from   w ww  . j  a v  a 2s .  c  o  m*/
 *
 * @param context - Context of the SOAP Message
 */
@Override
public boolean handleMessage(SOAPMessageContext context) {

    Boolean outBoundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    if (outBoundProperty) {
        SOAPMessage message = context.getMessage();
        SOAPHeader header = null;
        SOAPEnvelope envelope = null;
        try {
            header = message.getSOAPHeader();
            envelope = message.getSOAPPart().getEnvelope();
        } catch (SOAPException e) {
            Response.serverError().entity("SOAP message content cannot be read.").build();
        }
        try {
            if ((header == null) && (envelope != null)) {
                header = envelope.addHeader();
            }
        } catch (SOAPException e) {
            Response.serverError().entity("SOAP header cannot be added.").build();
        }

        SOAPFactory soapFactory = null;
        try {
            soapFactory = SOAPFactory.newInstance();
        } catch (SOAPException e) {
            Response.serverError().entity("Cannot get an instance of SOAP factory.").build();
        }

        QName qNamesSecurity = new QName(PluginConstants.WS_SECURITY_TARGET_NAMESPACE,
                PluginConstants.CertificateEnrolment.SECURITY);
        SOAPHeaderElement Security = null;
        Name attributeName = null;
        try {
            if (header != null) {
                Security = header.addHeaderElement(qNamesSecurity);
            }
            if (soapFactory != null) {
                attributeName = soapFactory.createName(PluginConstants.CertificateEnrolment.TIMESTAMP_ID,
                        PluginConstants.CertificateEnrolment.TIMESTAMP_U,
                        PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY);
            }
        } catch (SOAPException e) {
            Response.serverError().entity("Security header cannot be added.").build();
        }

        QName qNameTimestamp = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY,
                PluginConstants.CertificateEnrolment.TIMESTAMP);
        SOAPHeaderElement timestamp = null;
        try {
            if (header != null) {
                timestamp = header.addHeaderElement(qNameTimestamp);
                timestamp.addAttribute(attributeName, PluginConstants.CertificateEnrolment.TIMESTAMP_0);
            }
        } catch (SOAPException e) {
            Response.serverError().entity("Exception while adding timestamp header.").build();
        }
        DateTime dateTime = new DateTime();
        DateTime expiredDateTime = dateTime.plusMinutes(VALIDITY_TIME);
        String createdISOTime = dateTime.toString(ISODateTimeFormat.dateTime());
        String expiredISOTime = expiredDateTime.toString(ISODateTimeFormat.dateTime());
        createdISOTime = createdISOTime.substring(TIMESTAMP_BEGIN_INDEX,
                createdISOTime.length() - TIMESTAMP_END_INDEX);
        createdISOTime = createdISOTime + TIME_ZONE;
        expiredISOTime = expiredISOTime.substring(TIMESTAMP_BEGIN_INDEX,
                expiredISOTime.length() - TIMESTAMP_END_INDEX);
        expiredISOTime = expiredISOTime + TIME_ZONE;
        QName qNameCreated = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY,
                PluginConstants.CertificateEnrolment.CREATED);
        SOAPHeaderElement SOAPHeaderCreated = null;

        try {
            if (header != null) {
                SOAPHeaderCreated = header.addHeaderElement(qNameCreated);
                SOAPHeaderCreated.addTextNode(createdISOTime);
            }
        } catch (SOAPException e) {
            Response.serverError().entity("Exception while creating SOAP header.").build();
        }
        QName qNameExpires = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY,
                PluginConstants.CertificateEnrolment.EXPIRES);
        SOAPHeaderElement SOAPHeaderExpires = null;
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        String messageString = null;
        try {
            if (header != null) {
                SOAPHeaderExpires = header.addHeaderElement(qNameExpires);
                SOAPHeaderExpires.addTextNode(expiredISOTime);
            }
            if ((timestamp != null) && (Security != null)) {
                timestamp.addChildElement(SOAPHeaderCreated);
                timestamp.addChildElement(SOAPHeaderExpires);
                Security.addChildElement(timestamp);
            }
            message.saveChanges();
            message.writeTo(outputStream);
            messageString = new String(outputStream.toByteArray(), PluginConstants.CertificateEnrolment.UTF_8);
        } catch (SOAPException e) {
            Response.serverError().entity("Exception while creating timestamp SOAP header.").build();
        } catch (IOException e) {
            Response.serverError().entity("Exception while writing message to output stream.").build();
        }

        Map<String, List<String>> headers = (Map<String, List<String>>) context
                .get(MessageContext.HTTP_REQUEST_HEADERS);
        headers = new HashMap<String, List<String>>();
        if (messageString != null) {
            headers.put(PluginConstants.CONTENT_LENGTH, Arrays.asList(String.valueOf(messageString.length())));
        }
        context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    }
    return true;
}

From source file:org.wso2.carbon.mdm.mobileservices.windowspc.services.wstep.util.MessageHandler.java

License:Open Source License

/**
 * This method adds Timestamp for SOAP header, and adds Content-length for HTTP header for
 * avoiding HTTP chunking.// w w w .  j a  v  a 2s .  c om
 *
 * @param context
 */
@Override
public boolean handleMessage(SOAPMessageContext context) {

    Boolean outBoundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    if (outBoundProperty) {

        SOAPMessage message = context.getMessage();
        SOAPHeader header = null;
        SOAPEnvelope envelope = null;

        try {
            header = message.getSOAPHeader();
            envelope = message.getSOAPPart().getEnvelope();
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        if (header == null) {
            try {
                header = envelope.addHeader();
            } catch (SOAPException e) {
                Response.serverError().build();
            }
        }
        SOAPFactory soapFactory = null;

        try {
            soapFactory = SOAPFactory.newInstance();
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        QName qNamesSecurity = new QName(Constants.CertificateEnrollment.WS_SECURITY_TARGET_NAMESPACE,
                Constants.CertificateEnrollment.SECURITY);

        SOAPHeaderElement Security = null;

        try {
            Security = header.addHeaderElement(qNamesSecurity);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        Name attributeName = null;
        try {
            attributeName = soapFactory.createName(Constants.CertificateEnrollment.TIMESTAMP_ID,
                    Constants.CertificateEnrollment.TIMESTAMP_U,
                    Constants.CertificateEnrollment.WSS_SECURITY_UTILITY);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        QName qNameTimestamp = new QName(Constants.CertificateEnrollment.WSS_SECURITY_UTILITY,
                Constants.CertificateEnrollment.TIMESTAMP);
        SOAPHeaderElement timestamp = null;

        try {
            timestamp = header.addHeaderElement(qNameTimestamp);
            timestamp.addAttribute(attributeName, Constants.CertificateEnrollment.TIMESTAMP_0);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        DateTime dateTime = new DateTime();
        DateTime expiredDateTime = dateTime.plusMinutes(5);
        String createdISOTime = dateTime.toString(ISODateTimeFormat.dateTime());
        String expiredISOTime = expiredDateTime.toString(ISODateTimeFormat.dateTime());
        createdISOTime = createdISOTime.substring(0, createdISOTime.length() - 6);
        createdISOTime = createdISOTime + "Z";
        expiredISOTime = expiredISOTime.substring(0, expiredISOTime.length() - 6);
        expiredISOTime = expiredISOTime + "Z";

        QName qNameCreated = new QName(Constants.CertificateEnrollment.WSS_SECURITY_UTILITY,
                Constants.CertificateEnrollment.CREATED);
        SOAPHeaderElement SOAPHeaderCreated = null;

        try {
            SOAPHeaderCreated = header.addHeaderElement(qNameCreated);
            SOAPHeaderCreated.addTextNode(createdISOTime);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        QName qNameExpires = new QName(Constants.CertificateEnrollment.WSS_SECURITY_UTILITY,
                Constants.CertificateEnrollment.EXPIRES);
        SOAPHeaderElement SOAPHeaderExpires = null;

        try {
            SOAPHeaderExpires = header.addHeaderElement(qNameExpires);
            SOAPHeaderExpires.addTextNode(expiredISOTime);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        try {
            timestamp.addChildElement(SOAPHeaderCreated);
            timestamp.addChildElement(SOAPHeaderExpires);
            Security.addChildElement(timestamp);
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        try {
            message.saveChanges();
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        try {
            message.writeTo(outputStream);
        } catch (IOException e) {
            Response.serverError().build();
        } catch (SOAPException e) {
            Response.serverError().build();
        }

        String messageString = null;
        try {
            messageString = new String(outputStream.toByteArray(), Constants.CertificateEnrollment.UTF_8);
        } catch (UnsupportedEncodingException e) {
            Response.serverError().build();
        }

        Map<String, List<String>> headers = (Map<String, List<String>>) context
                .get(MessageContext.HTTP_REQUEST_HEADERS);
        headers = new HashMap<String, List<String>>();
        headers.put(Constants.CertificateEnrollment.CONTENT_LENGTH,
                Arrays.asList(String.valueOf(messageString.length())));
        context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

    }
    return true;
}

From source file:org.wso2.siddhi.debs2016.input.DataLoaderThread.java

License:Open Source License

public void run() {
    try (BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName), 10 * 1024 * 1024)) {
        String line = bufferedReader.readLine();
        Object[] eventData;/*from  w  w w . jav  a2 s. c om*/
        String user;
        while (line != null) {
            Iterator<String> dataStreamIterator = splitter.split(line).iterator();
            switch (fileType) {
            case POSTS:
                String postsTimeStampString = dataStreamIterator.next();
                if (("").equals(postsTimeStampString)) {
                    break;
                }
                DateTime postDateTime = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)
                        .parseDateTime(postsTimeStampString);
                long postsTimeStamp = postDateTime.getMillis();
                long postID = Long.parseLong(dataStreamIterator.next());
                long userID = Long.parseLong(dataStreamIterator.next());
                String post = dataStreamIterator.next();
                user = dataStreamIterator.next();
                eventData = new Object[] { 0L, postsTimeStamp, postID, userID, post, user, 0L, 0L,
                        Constants.POSTS };
                eventBufferList.put(eventData);

                break;
            case COMMENTS:
                String commentTimeStampString = dataStreamIterator.next();
                if (("").equals(commentTimeStampString)) {
                    break;
                }
                DateTime commentDateTime = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)
                        .parseDateTime(commentTimeStampString);
                long commentTimeStamp = commentDateTime.getMillis();
                long commentID = Long.parseLong(dataStreamIterator.next());
                userID = Long.parseLong(dataStreamIterator.next());
                String comment = dataStreamIterator.next();
                user = dataStreamIterator.next();
                String commentReplied = dataStreamIterator.next();

                if (("").equals(commentReplied)) {
                    commentReplied = MINUS_ONE;
                }

                long commentRepliedId = Long.parseLong(commentReplied);
                String postCommented = dataStreamIterator.next();

                if (("").equals(postCommented)) {
                    postCommented = MINUS_ONE;
                }
                long postCommentedId = Long.parseLong(postCommented);
                eventData = new Object[] { 0L, commentTimeStamp, userID, commentID, comment, user,
                        commentRepliedId, postCommentedId, Constants.COMMENTS };
                eventBufferList.put(eventData);

                break;
            case FRIENDSHIPS:
                String friendshipsTimeStampString = dataStreamIterator.next();
                if (("").equals(friendshipsTimeStampString)) {
                    break;
                }
                DateTime friendshipDateTime = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)
                        .parseDateTime(friendshipsTimeStampString);
                long friendshipTimeStamp = friendshipDateTime.getMillis();
                long user1ID = Long.parseLong(dataStreamIterator.next());
                long user2ID = Long.parseLong(dataStreamIterator.next());
                eventData = new Object[] { 0L, friendshipTimeStamp, user1ID, user2ID, 0L, 0L, 0L, 0L,
                        Constants.FRIENDSHIPS };
                eventBufferList.put(eventData);
                break;
            case LIKES:
                String likeTimeStampString = dataStreamIterator.next(); //e.g., 2010-02-09T04:05:20.777+0000
                if (("").equals(likeTimeStampString)) {
                    break;
                }
                DateTime likeDateTime = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)
                        .parseDateTime(likeTimeStampString);
                long likeTimeStamp = likeDateTime.getMillis();
                userID = Long.parseLong(dataStreamIterator.next());
                commentID = Long.parseLong(dataStreamIterator.next());
                eventData = new Object[] { 0L, likeTimeStamp, userID, commentID, 0L, 0L, 0L, 0L,
                        Constants.LIKES };
                eventBufferList.put(eventData);
                break;
            }
            line = bufferedReader.readLine();
        }

        Long postsTimeStampLong = -1L;
        Long postID = -1L;
        Long userID = -1L;
        eventData = new Object[] { -1L, postsTimeStampLong, postID, userID, 0L, 0L, 0L, 0L, Constants.POSTS };
        eventBufferList.put(eventData);

    } catch (NumberFormatException | InterruptedException | IOException e) {
        e.printStackTrace();
    }

}

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

License:Apache License

public static String formatIsoDate(DateTime datetime) {
    return ISODateTimeFormat.dateTime().print(datetime);
}

From source file:org.zgis.wps.swat.WeatherFetchAlgorithm.java

License:Apache License

private static String getObservations(String sosUrl, String sensor, String observedProperty, int years)
        throws IOException {
    String result = null;/*w ww  .j  av  a 2  s  . co m*/
    String offering = null; // "SOE_GWL_MASL";
    String procedure = sensor;
    // String observedProperty =
    // "http://vocab.smart-project.info/sensorweb/phenomenon/Humidity";
    String responseFormat = "http://www.opengis.net/om/2.0"; // "http://www.opengis.net/waterml/2.0";
    // String temporalFilter =
    // "om:phenomenonTime,2014-02-17T12:00:00/2014-02-18T20:00:00";

    DateTimeFormatter fmt = DateTimeFormat.forPattern(" yyyy-MM-dd'T'HH:mm:ss");
    DateTimeFormatter fmtTz = DateTimeFormat.forPattern(" yyyy-MM-dd'T'HH:mm:ssZZ");
    DateTimeFormatter fmtIso = ISODateTimeFormat.dateTime();

    DateTime now = DateTime.parse("2016-01-01 00:00:00");
    DateTime minusYears = now.minusYears(years);

    String temporalFilter = "om:phenomenonTime," + minusYears.toString(fmtIso) + "/" + now.toString(fmtIso);

    StringBuilder resultList = new StringBuilder();
    StringBuilder kvpRequestParams = new StringBuilder();
    kvpRequestParams.append("?service=" + "SOS");
    kvpRequestParams.append("&version=" + "2.0.0");
    kvpRequestParams.append("&request=" + "GetObservation");

    if (procedure != null && !procedure.isEmpty()) {
        kvpRequestParams.append("&procedure=" + URLEncoder.encode(procedure, "UTF-8"));
    }

    if (observedProperty != null && !observedProperty.isEmpty()) {
        kvpRequestParams.append("&observedProperty=" + URLEncoder.encode(observedProperty, "UTF-8"));
    }

    if (responseFormat != null && !responseFormat.isEmpty()) {
        kvpRequestParams.append("&responseFormat=" + URLEncoder.encode(responseFormat, "UTF-8"));
    }
    // om:phenomenonTime,2010-01-01T12:00:00/2011-07-01T14:00:00
    if (temporalFilter != null && !temporalFilter.isEmpty()) {
        kvpRequestParams.append("&temporalFilter=" + URLEncoder.encode(temporalFilter, "UTF-8"));
    }

    // set the connection timeout value to xx milliseconds
    final HttpParams httpParams = new BasicHttpParams();
    HttpClient httpclient = new DefaultHttpClient(httpParams);
    HttpGet httpget = new HttpGet(sosUrl + kvpRequestParams.toString());

    HttpResponse response;
    HttpEntity entity;

    response = httpclient.execute(httpget);
    HttpEntity resEntity = response.getEntity();
    BufferedReader rd = new BufferedReader(new InputStreamReader(resEntity.getContent()));
    String line;
    while ((line = rd.readLine()) != null) {
        resultList.append(line);
    }
    final String responseBody = resultList.toString();
    OM2MeasParse read = new OM2MeasParse();
    List<ObservationModel> tvps = read.readData(responseBody);

    httpclient.getConnectionManager().shutdown();

    Collections.sort(tvps, new Comparator<ObservationModel>() {
        public int compare(ObservationModel m1, ObservationModel m2) {
            return m1.getDatetime().compareTo(m2.getDatetime());
        }
    });

    if (tvps.size() > 0) {
        return "OK - [" + sensor + "] last: " + tvps.get(tvps.size() - 1).getDate();
    } else {
        return "MISSING";
    }
}

From source file:petascope.wcs.server.core.TimeString.java

License:Open Source License

/**
 * Date to millisecond parser. Accepts the standard ISO 8601 + shorter codes.
 *
 * @return long number of miliseconds// w w  w .  j a v  a2 s.c  om
 */
public static long parseMillis(String TString) throws IllegalArgumentException {
    long Millis;
    int NumberOfSymbols = TString.length();

    switch (NumberOfSymbols) {
    case 24:
        DTF = ISODateTimeFormat.dateTime();
        Millis = DTF.parseMillis(TString);

        break;
    case 22:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SS");
        Millis = DTF.parseMillis(TString);

        break;
    case 19:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss");
        Millis = DTF.parseMillis(TString);

        break;
    case 16:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm");
        Millis = DTF.parseMillis(TString);

        break;
    case 13:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH");
        Millis = DTF.parseMillis(TString);

        break;
    case 10:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd");
        Millis = DTF.parseMillis(TString);

        break;
    case 7:
        DTF = DateTimeFormat.forPattern("yyyy-MM");
        Millis = DTF.parseMillis(TString);

        break;
    case 4:
        DTF = DateTimeFormat.forPattern("yyyy");
        Millis = DTF.parseMillis(TString);

        break;
    default:
        throw new IllegalArgumentException("Unknown DateTime format.");
    }

    return Millis;
}

From source file:petascope.wcs.server.core.TimeString.java

License:Open Source License

/**
 * @param str string containing date//from w  ww  .j  av  a2s.  c o m
 * @return joda DateTime corresponding to the input string
 * @throws IllegalArgumentException
 */
public static DateTime parse(String str) throws IllegalArgumentException {
    DateTime date;
    int NumberOfSymbols = str.length();

    System.out.println("Parsing date '" + str + "', with length " + str.length());

    switch (NumberOfSymbols) {
    case 24:
        DTF = ISODateTimeFormat.dateTime();
        date = DTF.parseDateTime(str);

        break;
    case 22:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SS");
        date = DTF.parseDateTime(str);

        break;
    case 19:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss");
        date = DTF.parseDateTime(str);

        break;
    case 16:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm");
        date = DTF.parseDateTime(str);

        break;
    case 13:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH");
        date = DTF.parseDateTime(str);

        break;
    case 10:
        DTF = DateTimeFormat.forPattern("yyyy-MM-dd");
        date = DTF.parseDateTime(str);

        break;
    case 7:
        DTF = DateTimeFormat.forPattern("yyyy-MM");
        date = DTF.parseDateTime(str);

        break;
    case 4:
        DTF = DateTimeFormat.forPattern("yyyy");
        date = DTF.parseDateTime(str);

        break;
    default:
        throw new IllegalArgumentException("Unknown DateTime format.");
    }

    return date;
}

From source file:playRepository.SVNRepository.java

License:Apache License

private ObjectNode fileAsJson(String path, org.tmatesoft.svn.core.io.SVNRepository repository)
        throws SVNException, IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SVNProperties prop = new SVNProperties();
    repository.getFile(path, -1l, prop, baos);
    SVNDirEntry entry = repository.info(path, -1l);
    long size = entry.getSize();
    boolean isBinary;
    String mimeType;/*w  w  w.  j  a v  a  2s . c  om*/
    String data = null;

    if (size > MAX_FILE_SIZE_CAN_BE_VIEWED) {
        isBinary = true;
        mimeType = "application/octet-stream";
    } else {
        byte[] bytes = baos.toByteArray();
        isBinary = RawText.isBinary(bytes);
        if (!isBinary) {
            data = new String(bytes, FileUtil.detectCharset(bytes));
        }
        mimeType = new Tika().detect(bytes, path);
    }

    String author = prop.getStringValue(SVNProperty.LAST_AUTHOR);
    User user = User.findByLoginId(author);

    String commitDate = prop.getStringValue(SVNProperty.COMMITTED_DATE);
    DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime();
    Long commitTime = dateFormatter.parseMillis(commitDate);

    ObjectNode result = Json.newObject();
    result.put("type", "file");
    result.put("revisionNo", prop.getStringValue(SVNProperty.COMMITTED_REVISION));
    result.put("author", author);
    result.put("avatar", getAvatar(user));
    result.put("userName", user.name);
    result.put("userLoginId", user.loginId);
    result.put("createdDate", commitTime);
    result.put("commitMessage", entry.getCommitMessage());
    result.put("commiter", author);
    result.put("size", size);
    result.put("isBinary", isBinary);
    result.put("mimeType", mimeType);
    result.put("data", data);

    return result;
}

From source file:propel.core.utils.StringUtils.java

License:Open Source License

/**
 * Returns ISO standard and other frequently used date/time parsers
 *///  ww  w  .j  a  v a 2s  .  c  om
private static DateTimeParser[] createCommonDateTimeParsers() {
    return new DateTimeParser[] { ISODateTimeFormat.basicDateTimeNoMillis().getParser(), // yyyyMMdd'T'HHmmssZ
            ISODateTimeFormat.basicDateTime().getParser(), // yyyyMMdd'T'HHmmss.SSSZ
            ISODateTimeFormat.dateHourMinuteSecondFraction().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS (only 3 ms positions used though)
            ISODateTimeFormat.dateTimeNoMillis().getParser(), // yyyy-MM-dd'T'HH:mm:ssZZ
            ISODateTimeFormat.dateTime().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSZZ (ISO 8601)
            DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z").getParser(), // RFC 2822
            DateTimeFormat.forPattern("yyyy/MM/dd").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("HH:mm").getParser(), DateTimeFormat.forPattern("HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("HH:mm:ss.SSSSSSSSS").getParser() };
}