Package java.text

Examples of java.text.SimpleDateFormat$CompiledField


      myService.setUserCredentials(settings.getExporterProperty(USERNAME).trim(), mPassword);

      URL postUrl =
              new URL("http://www.google.com/calendar/feeds/" + settings.getExporterProperty(SELECTED_CALENDAR) + "/private/full");

      SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd");
      formatDay.setTimeZone(TimeZone.getTimeZone("GMT"));
      SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss");
      formatTime.setTimeZone(TimeZone.getTimeZone("GMT"));

      ParamParser parser = new ParamParser();
      for (Program program : programs) {
        final String title = parser.analyse(formatting.getTitleValue(), program);
View Full Code Here


    public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) {
        AppleScriptRunner runner = new AppleScriptRunner();

        StringBuilder script = new StringBuilder();

        SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat formatHour = new SimpleDateFormat("HH:mm");

        String calTitle = settings.getExporterProperty(AppleiCalExporter.PROPERTY_CALENDAR_NAME);
        if (StringUtils.isBlank(calTitle)) {
          calTitle = "TV-Browser";
        }
        script.append("property myTVCalendar : \"" + calTitle + "\"\n");

        script.append("on stringToList from theString for myDelimiters\n" +
          "\ttell AppleScript\n" +
          "\t\tset theSavedDelimiters to AppleScript's text item delimiters\n" +
          "\t\tset text item delimiters to myDelimiters\n" +
          "\t\t\n" +
          "\t\tset outList to text items of theString\n" +
          "\t\tset text item delimiters to theSavedDelimiters\n" +
          "\t\t\n" +
          "\t\treturn outList\n" +
          "\tend tell\n" +
          "end stringToList\n" +
          "\n" +
          "\n" +
          "on getDateForISOdate(theISODate, theISOTime)\n" +
          "\tlocal myDate\n" +
          "\t-- converts an ISO format (YYYY-MM-DD) and time to a date object\n" +
          "\tset monthConstants to {January, February, March, April, May, June, July, August, September, October, November, December}\n" +
          "\t\n" +
          "\tset theISODate to (stringToList from (theISODate) for \"-\")\n" +
          "\tset theISOTime to (stringToList from (theISOTime) for \":\")\n" +
          "\t\n" +
          "\tset myDate to current date\n" +
          "\tset month of myDate to 1\n" +
          "\t\n" +
          "\ttell theISODate\n" +
          "\t\tset year of myDate to item 1\n" +
          "\t\tset day of myDate to item 3\n" +
          "\t\tset month of myDate to item (item 2) of monthConstants\n" +
          "\tend tell\n" +
          "\ttell theISOTime\n" +
          "\t\tset hours of myDate to item 1\n" +
          "\t\tset minutes of myDate to item 2\n" +
          "\t\tset seconds of myDate to 0\n" +
          "\tend tell\n" +
          "\t\n" +
          "\treturn myDate\n" +
          "end getDateForISOdate\n" +
          "\n");

        script.append("\n");
        script.append("tell application \"iCal\"\n");
        script.append("  if (exists (calendars whose title is myTVCalendar)) then\n");
        script.append("    set TVBrowserCalendar to first item of (calendars whose title is myTVCalendar)\n");
        script.append("  else\n");
        script.append("    set TVBrowserCalendar to make new calendar with properties {title:myTVCalendar}\n");
        script.append("  end if\n");
        script.append("\n");

        for (Program program : programs) {
            final Calendar start = CalendarToolbox.getStartAsCalendar(program);
            final Calendar end   = CalendarToolbox.getEndAsCalendar(program);

            script.append("  set startDate to my getDateForISOdate(\"").append(formatDay.format(start.getTime())).append("\", \"").append(formatHour.format(start.getTime())).append("\")\n");
            script.append("  set endDate to my getDateForISOdate(\"").append(formatDay.format(end.getTime())).append("\", \"").append(formatHour.format(end.getTime())).append("\")\n");
            script.append("\n");
            script.append("  set props to {start date:startDate, end date:endDate, summary:\"");

            ParamParser parser = new ParamParser();
View Full Code Here

    public File getFile() {
        String dir = (String) invokeMethod(getTarget(), "getDirectory", null, null);
        String prefix = (String) invokeMethod(getTarget(), "getPrefix", null, null);
        String suffix = (String) invokeMethod(getTarget(), "getSuffix", null, null);
        boolean timestamp = ((Boolean)Instruments.getField(getTarget(), "timestamp")).booleanValue();
        String date = timestamp ? new SimpleDateFormat("yyyy-MM-dd").format(new Date()) : "";

        File file = (date != null && dir != null && prefix != null && suffix != null ? new File(dir, prefix + date + suffix) : null);
        if (file != null && !file.isAbsolute()) {
            return new File(System.getProperty("catalina.base"), file.getPath());
        } else {
View Full Code Here

                StringBuffer buf = new StringBuffer(dateStr);
                dateStr = buf.replace(22, 23, "").toString();
              }
            }
            // Format the current time.
            SimpleDateFormat formatter = new SimpleDateFormat(timePattern);

            Date d = null;
            try {
                d = formatter.parse(dateStr, new ParsePosition(0));
            } catch (Exception e) {
              if(this.traceEnabled)
                traceLog.warn(
                    String.format("Failed to parse date string \"%s\" using pattern \"%s\". Cause: %s",dateStr,timePattern,e.getMessage()));
            }
View Full Code Here

   */
  public static String today(Locale locale){
    if(locale == null)
      locale = Locale.SIMPLIFIED_CHINESE;
    Calendar today = Calendar.getInstance(locale);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy��MM��dd�� EEE", locale);
    try{
      return sdf.format(today.getTime());
    }finally{
      today = null;
      sdf = null;
    }
  }
View Full Code Here

            "only one get parameter \"moment\" supported");
      }
      String momentString = momentParameterStrings[0];
      String datePattern = "yyyyMMddHHmmssSSS";
      try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern
            .substring(0, momentString.length()));
        dateFormat.setTimeZone(utcTZ);
        moment = dateFormat.parse(momentString);
      } catch (ParseException e) {
        throw new HandlerException(e);
      }
      ;
    }
View Full Code Here

  }

  public Date toTargetType(String toConvert) throws ConversionException
  {

    SimpleDateFormat formatter = getDateFormat();

    if (toConvert == null || toConvert.length() == 0)
      return null;

    try
    {
      return formatter.parse(toConvert);
    }
    catch (ParseException e)
    {
      // should have already been validated so this is not recoverable
      throw new ConversionException("Unable to convert value " + toConvert + " to Date using pattern "
View Full Code Here

    return getDateFormat().format(toConvert);
  }

  private SimpleDateFormat getDateFormat()
  {
    SimpleDateFormat formatter = new SimpleDateFormat(getDatePattern());
    formatter.setLenient(false);
    return formatter;
  }
View Full Code Here

    return result;
  }

  public void testZoneDate() throws ParseException {
    Date date = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat(
    "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
   
    String noColumnYet = dateFormat.format(date);
    StringBuffer result = new StringBuffer(noColumnYet);
    result.insert(noColumnYet.length() - 2, ':');
    Date parsed = MillisDateFormat.instance.parse(result.toString());
    assertEquals(date, parsed);
  }
View Full Code Here

        Mapping.rollback();

        request.setAttribute("publication", publication);
        request.setAttribute("editForm", editForm);
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        sform.setDate(formatter.format(publication.getDate()));

      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // fill data | errors
    if (errors.size() > 0) {
      try {
        Mapping.begin();
        Publication publication = Publication.getInstance(id);
        Hashtable data = new Hashtable();
        Enumeration names = request.getParameterNames();
        while (names.hasMoreElements()) {
          String name = names.nextElement().toString();
          data.put(name, request.getParameter(name));
        }
        String editForm =
          FormGenerator.getForm(publication.getType(), data);
        Mapping.rollback();

        request.setAttribute("publication", publication);
        request.setAttribute("editForm", editForm);
        request.setAttribute(ERROR_KEY, errors);
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // all it's ok : update publication
    try {
      Mapping.begin();

      Publication publication = Publication.getInstance(id);
      Hashtable data = new Hashtable();
      Enumeration names = request.getParameterNames();
      while (names.hasMoreElements()) {
        String name = names.nextElement().toString();
        String value = request.getParameter(name);
        if (!value.trim().equals("")) {
          data.put(name, request.getParameter(name));
        }
      }
      publication.setData(data, true);
      SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
      publication.setDate(formatter.parse(sform.getDate()));

      //      LockManager locks =
      //        (LockManager) servlet.getServletContext().getAttribute("locks");
      //      locks.unlock(publication);
View Full Code Here

TOP

Related Classes of java.text.SimpleDateFormat$CompiledField

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.