Package java.text

Examples of java.text.SimpleDateFormat.parseObject()


      public StringBuffer format(Object pObj, StringBuffer pAppendTo, FieldPosition pPos) {
        return df.format(((Calendar) pObj).getTime(), pAppendTo, pPos);
      }
      public Object parseObject(String pSource, ParsePosition pPos) {
        Calendar cal = Calendar.getInstance();
        cal.setTime((Date) df.parseObject(pSource, pPos));
        return cal;
      }
    };
    testAllElement(otherDateTimeFormat, otherDateFormat, otherTimeFormat);
  }
View Full Code Here


          java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(.*[\\-,\\+]{1}[0-9]{1,2}):([0-9]{1,2})");
          java.util.regex.Matcher matcher = pattern.matcher(strValue);
          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";
View Full Code Here

          }
        } 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()) + ")";
View Full Code Here

        String strValue = (String) value;
        Format formatter = null;
        try {
          boolean spaces = strValue.indexOf(' ') != -1;
          formatter = ERXRestUtils.dateFormat(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 Date()) + ")";
View Full Code Here

    long days = 0;
    Format format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String currentTime = format.format(new Date());

    try {
      Date currentDate = (Date) format.parseObject(currentTime);
      Date targetDate = (Date) format.parseObject("2012-7-27 00:00:00");
      days = (targetDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24);
    } catch (ParseException e) {
      e.printStackTrace();
    }
View Full Code Here

    Format format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String currentTime = format.format(new Date());

    try {
      Date currentDate = (Date) format.parseObject(currentTime);
      Date targetDate = (Date) format.parseObject("2012-7-27 00:00:00");
      days = (targetDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24);
    } catch (ParseException e) {
      e.printStackTrace();
    }
   
View Full Code Here

      for (String s : Page.getLink(url)) {
        ArrayList<String[]> a = Page.scanPage(s);
        for (String[] l : a) {
          String time = l[1];
          time = time.substring(0, 11) + time.substring(15);
          Date d = (Date) formatter.parseObject(time);
          Calendar cal = Calendar.getInstance();
          cal.setTime(d);
          if (cal.get(Calendar.HOUR_OF_DAY) > 8
              && cal.get(Calendar.HOUR_OF_DAY) < 18
              && cal.get(Calendar.DAY_OF_WEEK) != 1
View Full Code Here

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        DefaultFeatureCollection features = new DefaultFeatureCollection(null, null);
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(timeFeatureType);
        fb.add("one");
        fb.add(dateFormat.parseObject("2006-04-04 22:00:00"));
        features.add(fb.buildFeature(null));
       
        fb.add("two");
        fb.add(dateFormat.parseObject("2006-05-05 20:00:00"));
        features.add(fb.buildFeature(null));
View Full Code Here

        fb.add("one");
        fb.add(dateFormat.parseObject("2006-04-04 22:00:00"));
        features.add(fb.buildFeature(null));
       
        fb.add("two");
        fb.add(dateFormat.parseObject("2006-05-05 20:00:00"));
        features.add(fb.buildFeature(null));
       
        fb.add("three");
        fb.add(dateFormat.parseObject("2006-06-28 18:00:00"));
        features.add(fb.buildFeature(null));
View Full Code Here

        fb.add("two");
        fb.add(dateFormat.parseObject("2006-05-05 20:00:00"));
        features.add(fb.buildFeature(null));
       
        fb.add("three");
        fb.add(dateFormat.parseObject("2006-06-28 18:00:00"));
        features.add(fb.buildFeature(null));
       
        fs = (FeatureStore) store.getFeatureSource("TimeFeature");
        fs.addFeatures(features);
        ft = cb.buildFeatureType(fs);
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.