Package org.apache.commons.lang.time

Examples of org.apache.commons.lang.time.FastDateFormat


    this.orderString=orderString;
    this.logger = logger;
    this.logDateFormat = logDateFormat;
    this.timeZone =timeZone;
        this.startTime = new Date();
        final FastDateFormat dateformat;
        if (this.timeZone == null) {
          dateformat = FastDateFormat.getInstance(this.logDateFormat);
        } else {
          dateformat = FastDateFormat.getInstance(this.logDateFormat, TimeZone.getTimeZone(this.timeZone));
        }
        paramPut(LOG_TIME, dateformat.format(new Date()));
        this.paramPut(REPLY_TIME,REPLY_TIME);
        this.paramPut(LOG_ID, "0");
  }
View Full Code Here


              return null;
          }
          ASN1Sequence seq = (ASN1Sequence)obj;
         
          String prefix = "";
      FastDateFormat dateF = FastDateFormat.getInstance("yyyyMMdd");
          for (int i = 0; i < seq.size(); i++) {
            Attribute attr = Attribute.getInstance(seq.getObjectAt(i));
            if (!StringUtils.isEmpty(result)) {
              prefix = ", ";
            }
            if (attr.getAttrType().getId().equals(id_pda_dateOfBirth)) {
              ASN1Set set = attr.getAttrValues();
              // Come on, we'll only allow one dateOfBirth, we're not allowing such frauds with multiple birth dates
              DERGeneralizedTime time = DERGeneralizedTime.getInstance(set.getObjectAt(0));
              Date date = time.getDate();
              String dateStr = dateF.format(date);
              result += prefix + "dateOfBirth="+dateStr;
            }
            if (attr.getAttrType().getId().equals(id_pda_placeOfBirth)) {
              ASN1Set set = attr.getAttrValues();
              // same here only one placeOfBirth
View Full Code Here

        }{
        // Test time constraints
        final EndEntityProfile profile = new EndEntityProfile();
        Date now = new Date();
        Date endOfTime = new Date(Long.MAX_VALUE);
        FastDateFormat sm = FastDateFormat.getInstance("yyyy-MM-dd HH:mm");
        String staticNow = sm.format(now);
        String relativeNow = "0:00:00";
        String staticEndOfTime = sm.format(endOfTime);
        String relativeEndOfTime = "33000:00:00"; // ~100 years
        String staticInvalid = "XXXX-XX-XX XX:XX PM";
        String relativeInvalid = "XXXXX:XXX:XXX";
        String relativeNegative = "-10:00:00";
        ExtendedInformation ei = new ExtendedInformation();
View Full Code Here

              setRemainingLoginAttempts(DEFAULT_REMAININGLOGINATTEMPTS);
            }
            // In EJBCA 4.0.0 we changed the date format
          if (getVersion() < 3) {
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US);
            final FastDateFormat newDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm");
            try {
              final String oldCustomStartTime = getCustomData(ExtendedInformation.CUSTOM_STARTTIME);
              if ( !isEmptyOrRelative(oldCustomStartTime) ) {
                // We use an absolute time format, so we need to upgrade
                  final String newCustomStartTime = newDateFormat.format(oldDateFormat.parse(oldCustomStartTime));
              setCustomData(ExtendedInformation.CUSTOM_STARTTIME, newCustomStartTime);
              if (log.isDebugEnabled()) {
                log.debug("Upgraded " + ExtendedInformation.CUSTOM_STARTTIME + " from \"" + oldCustomStartTime + "\" to \"" + newCustomStartTime + "\" in ExtendedInformation.");
              }
              }
        } catch (ParseException e) {
          log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_STARTTIME + " in extended user information.", e);
        }
            try {
              final String oldCustomEndTime = getCustomData(ExtendedInformation.CUSTOM_ENDTIME);
              if ( !isEmptyOrRelative(oldCustomEndTime) ) {
                // We use an absolute time format, so we need to upgrade
                  final String newCustomEndTime = newDateFormat.format(oldDateFormat.parse(oldCustomEndTime));
              setCustomData(ExtendedInformation.CUSTOM_ENDTIME, newCustomEndTime);
              if (log.isDebugEnabled()) {
                log.debug("Upgraded " + ExtendedInformation.CUSTOM_ENDTIME + " from \"" + oldCustomEndTime + "\" to \"" + newCustomEndTime + "\" in ExtendedInformation.");
              }
              }
View Full Code Here

             * doesUserFullfillEndEntityProfile check and this is what need to upgrade from:
             *     DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US)
             */
          if (getVersion() < 13) {
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US);
            final FastDateFormat newDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm");
            try {
              final String oldStartTime = getValue(STARTTIME, 0);
              if (!isEmptyOrRelative(oldStartTime)) {
                // We use an absolute time format, so we need to upgrade
                  final String newStartTime = newDateFormat.format(oldDateFormat.parse(oldStartTime));
              setValue(STARTTIME, 0, newStartTime);
              if (log.isDebugEnabled()) {
                log.debug("Upgraded " + STARTTIME + " from \"" + oldStartTime + "\" to \"" + newStartTime + "\" in EndEntityProfile.");
              }
              }
        } catch (ParseException e) {
          log.error("Unable to upgrade " + STARTTIME + " in EndEntityProfile! Manual interaction is required (edit and verify).", e);
        }
            try {
              final String oldEndTime = getValue(ENDTIME, 0);
              if (!isEmptyOrRelative(oldEndTime)) {
                // We use an absolute time format, so we need to upgrade
                  final String newEndTime = newDateFormat.format(oldDateFormat.parse(oldEndTime));
              setValue(ENDTIME, 0, newEndTime);
              if (log.isDebugEnabled()) {
                log.debug("Upgraded " + ENDTIME + " from \"" + oldEndTime + "\" to \"" + newEndTime + "\" in EndEntityProfile.");
              }
              }
View Full Code Here

  /**
   * Converts the current value to Text using the pattern that has been set or a default pattern
   * if no pattern has been set
   */
  public static String convertToString(Calendar c, String pattern, Locale locale) {
    FastDateFormat formatter = getFormatter(pattern, locale);

    return formatter.format(c);
  }
View Full Code Here

    return formatter.format(c);
  }

  public static String convertToString(Date date, String pattern, Locale locale) {
    FastDateFormat formatter = getFormatter(pattern, locale);

    return formatter.format(date);
  }
View Full Code Here

    return formatter.format(date);
  }

  public static FastDateFormat getFormatter(String pattern, Locale locale){
    FastDateFormat formatter = null;
   
    if (StringUtils.isBlank(pattern)) {
      // If the pattern being requested is empty, then use a default formatter
      formatter = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, locale);
    } else {
View Full Code Here

    return messageTypeCombo;
  }

  private void syncFromMessage() throws JMSException {
    Calendar cal = Calendar.getInstance();
    FastDateFormat fmt = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSSZ");

    if (message.getJMSReplyTo() != null) {
      replyToDomain = Domain.getDomain(message.getJMSReplyTo());
    } else {
      replyToDomain = Domain.QUEUE;
    }
    tglbtnQueue.setText(replyToDomain.toString());

    messageIdField.setText(message.getJMSMessageID());
    replyToField.setText(JMSUtils.getDestinationName(message.getJMSReplyTo()));
    destinationField.setText(JMSUtils.getDestinationName(message.getJMSDestination()));
    correlationIDField.setText(message.getJMSCorrelationID());
    typeField.setText(message.getJMSType());
    timestampField.setText(fmt.format(new Date(message.getJMSTimestamp())));
    expirationSpinner.setValue(message.getJMSExpiration());
    priroritySpinner.setValue(message.getJMSPriority());
    if (message instanceof TextMessage) {
      messageTypeCombo.setSelectedItem(MessageType.TextMessage);
    } else if (message instanceof BytesMessage) {
View Full Code Here

        assertEquals("Round trip", in, out);
    }

    private String formatAsImap(Date date, TimeZone zone) {
        assertNotNull(date);
        FastDateFormat format = FastDateFormat.getInstance(
                "dd-MMM-yyyy hh:mm:ss Z", zone, Locale.US);
        String out = format.format(date);
        if (out.charAt(0) == '0') {
            out = ' ' + out.substring(1, out.length());
        }
        return out;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.time.FastDateFormat

Copyright © 2018 www.massapicom. 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.