Package java.text

Examples of java.text.SimpleDateFormat.applyPattern()


            if (requestInformation.get().handle && requestInformation.get().client.getIsActive()) {
                logger.info("Storing history");
                String createdDate;
                SimpleDateFormat sdf = new SimpleDateFormat();
                sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
                sdf.applyPattern("dd MMM yyyy HH:mm:ss");
                createdDate = sdf.format(new Date()) + " GMT";

                history.setCreatedAt(createdDate);
                history.setRequestURL(HttpUtilities.getURL(httpMethodProxyRequest.getURI().toString()));
                history.setRequestParams(httpMethodProxyRequest.getQueryString() == null ? ""
View Full Code Here


        try
        {
          SimpleDateFormat dateFormat = new SimpleDateFormat(formatsIn[i]);
          dateFormat.setLenient(false);
          Date dt = dateFormat.parse(in);         
          dateFormat.applyPattern(formatOut);
          return dateFormat.format(dt);
        }
        catch (ParseException pe)
        {
        }
View Full Code Here

      String format = (String) formatIter.next();
      if (dateParser == null) {
        dateParser = new SimpleDateFormat(format, Locale.US);
        dateParser.setTimeZone(TimeZone.getTimeZone("GMT"));
      } else {
        dateParser.applyPattern(format);
      }
      try {
        return dateParser.parse(dateValue);
      } catch (java.text.ParseException pe) {
        // ignore this exception, we will try the next format
View Full Code Here

                // -->
            else if (attribute.startsWith("second"))
                return new Element(currentDate.getSeconds()).getAttribute(attribute.fulfill(1));

            else {
                format.applyPattern("EEE, d MMM yyyy HH:mm:ss");
                return new Element(format.format(currentDate))
                        .getAttribute(attribute);
            }
        }
View Full Code Here

                // @returns Element
                // @description
                // Returns the current system time in 24-hour format.
                // -->
                if (specifier.equalsIgnoreCase("TWENTYFOUR_HOUR")) {
                    format.applyPattern("k:mm");
                    event.setReplaced(new Element(format.format(currentDate))
                            .getAttribute(attribute.fulfill(3)));
                }
                // <--[tag]
                // @attribute <util.date.time.year>
View Full Code Here

                    // To get the exact millisecond count, use <@link tag server.current_time_millis>.
                    // -->
                else if (specifier.equalsIgnoreCase("duration"))
                    event.setReplaced(new Duration(System.currentTimeMillis() / 50).getAttribute(attribute.fulfill(3)));
                else {
                    format.applyPattern("K:mm a");
                    event.setReplaced(format.format(currentDate));
                }

            }
            // <--[tag]
View Full Code Here

            // Returns the current system time, formatted as specified
            // Example format: [EEE, MMM d, yyyy K:mm a] will become "Mon, Jan 1, 2112 0:01 AM"
            // -->
            else if (subType.equalsIgnoreCase("FORMAT") && !subTypeContext.equalsIgnoreCase("")) {
                try {
                    format.applyPattern(event.getSubTypeContext());
                    event.setReplaced(format.format(currentDate));
                }
                catch (Exception ex) {
                    dB.echoError("Error: invalid pattern '" + event.getSubTypeContext() + "'");
                    dB.echoError(ex);
View Full Code Here

                    dB.echoError("Error: invalid pattern '" + event.getSubTypeContext() + "'");
                    dB.echoError(ex);
                }
            }
            else {
                format.applyPattern("EEE, MMM d, yyyy");
                event.setReplaced(format.format(currentDate));
            }

        }
View Full Code Here

        try
        {
          SimpleDateFormat dateFormat = new SimpleDateFormat(formatsIn[i], Locale.ENGLISH);
          dateFormat.setLenient(false);
          Date dt = dateFormat.parse(in);         
          dateFormat.applyPattern(formatOut);
          return dateFormat.format(dt);
        }
        catch (ParseException pe)
        {
        }
View Full Code Here

  public static Date parse(String date) {
    Date d = null;
    SimpleDateFormat sdf = new SimpleDateFormat();
    for (int n = 0; n < masks.length; n++) {
      try {
        sdf.applyPattern(masks[n]);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        sdf.setLenient(true);
        d = sdf.parse(date, new ParsePosition(0));
        if (d != null) break;
      } catch (Exception e) {}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.