Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSTimestamp


    String formattedValue;
    if (value == null || value instanceof NSKeyValueCoding.Null) {
      formattedValue = null;
    }
    else if (value instanceof NSTimestamp) {
      NSTimestamp timestamp = (NSTimestamp) value;
      String rfcFormat = ERXProperties.stringForKeyWithDefault("er.rest.rfcDateFormat", "rfc822");
      if ("rfc3339".equals(rfcFormat)) {
        formattedValue = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date(timestamp.getTime()));
        formattedValue = formattedValue.substring(0, formattedValue.length()-2) + ":" + formattedValue.substring(formattedValue.length()-2);         
      } else {
        formattedValue = ERXRestUtils.timestampFormat(false, context).format(timestamp);
      }
    }
View Full Code Here


          if (matcher.matches()) {
            try {
              strValue = matcher.group(1) + matcher.group(2);
              parsedValue = formatter.parseObject(strValue);
              if (parsedValue instanceof java.util.Date) {
                parsedValue = new NSTimestamp((Date)parsedValue);
              }
            } catch (Throwable t) {
              String msg = "Failed to parse '" + strValue + "' as a timestamp";
              if (formatter != null) {
                msg += " (example: " + formatter.format(new NSTimestamp()) + ")";
              }
              msg += ".";
              throw new IllegalArgumentException(msg, t);
            }
          } else {
            strValue  = null;
            throw new IllegalArgumentException(strValue + " didn't match the " + pattern.pattern() + " pattern", new Throwable());
          }
        } else {
          Format formatter = null;
          try {
            formatter = ERXRestUtils.timestampFormat(spaces, context);
            parsedValue = formatter.parseObject(strValue);   
          }
          catch (Throwable t) {
            String msg = "Failed to parse '" + strValue + "' as a timestamp";
            if (formatter != null) {
              msg += " (example: " + formatter.format(new NSTimestamp()) + ")";
            }
            msg += ".";
            throw new IllegalArgumentException(msg, t);
          }
        }
View Full Code Here

    public SimpleXML2FOP2PDF1(WOContext context) {
        super(context);
    }

  public NSTimestamp now() {
    return new NSTimestamp();
  }
View Full Code Here

  public String returnThisApplicationName() {
    return WOApplication.application().name();
  }

  public NSTimestamp currentTime() {
    return new NSTimestamp();
  }
View Full Code Here

                String s = defaultValue.toString();
                s = s.substring(s.indexOf("@")+1);
                if(adaptorType == AdaptorDateType) {
                    defaultValue = ERXTimestampUtilities.timestampForString(s);
                } else if (adaptorType == AdaptorNumberType) {
                    NSTimestamp temp = ERXTimestampUtilities.timestampForString(s);
                    if(temp != null) {
                        defaultValue = ERXTimestampUtilities.unixTimestamp(temp);
                    } else {
                        //the value will be coerced by the eo...
                        defaultValue = ERXValueUtilities.bigDecimalValue(s);
View Full Code Here

        catch (ClassNotFoundException cnfe) {
          throw new UnmarshallException(cnfe.getMessage());
        }
      }
      if (NSTimestamp.class.equals(clazz)) {
        NSTimestamp timestamp = new NSTimestamp(time, NSTimeZone.getTimeZone(tz));
        state.setSerialized(o, timestamp);
        return timestamp;
      }
      throw new UnmarshallException("invalid class " + clazz);
    }
View Full Code Here

        this.isGuessingEarly = isGuessingEarly;
    }

    @Override
    public NSTimestamp parseObject(String text) throws ParseException {
        NSTimestamp parsedTimestamp = null;
       
        try {
            // Attempt to parse the string with the given pattern.
            Date parsedDate = super.parse(text);
            parsedTimestamp = new NSTimestamp(parsedDate);
        }
        catch (ParseException e) {
           
            // If the input doesn't match the pattern, use Chronic to parse the input.
            Span span = Chronic.parse(text, options());
            if (span == null) {
                throw e;
            }
            else {
                if (span.isSingularity() || isGuessingEarly()) {
                    parsedTimestamp = new NSTimestamp(span.getBeginCalendar().getTime());
                }
                else {
                    parsedTimestamp = new NSTimestamp(span.getEndCalendar().getTime());
                }
            }
        }
       
        return parsedTimestamp;
View Full Code Here

        return TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT);
    }

    public String radioValue(){
        if(_radioValue == null) {
            NSTimestamp dateValue = (NSTimestamp)objectPropertyValue();
            _radioValue = dateValue==null ? empty : date;
        }
        return _radioValue;
    }
View Full Code Here

    @Override
    public void takeValuesFromRequest (WORequest request, WOContext context) {
        super.takeValuesFromRequest (request,context);
        if (context.wasFormSubmitted()) {
          if (radioValue().equals(date)){
            NSTimestamp date = null;
            try {

              if (time==null || time.length()!=5) {
                date = (NSTimestamp)ALL_FORMAT.parseObject(day+" "+ month +" "+year);
              } else {
View Full Code Here

        }
        return yearList;
    }

    public String time() throws Exception {
        NSTimestamp date = (NSTimestamp)objectPropertyValue();
        if (date != null)
            time = TIME_FORMAT.format(date);
        else
            time = TIME_FORMAT.format(new NSTimestamp());
        return time;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSTimestamp

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.