Package java.text

Examples of java.text.SimpleDateFormat


           
            for (int i=0;i<dos_list.size();i++){
             
              DOSEntry  this_entry = (DOSEntry)dos_list.get(i);
             
              String ts = new SimpleDateFormat("hh:mm:ss - ").format( new Date(this_entry.last_time ));
           
              pw.println( ts + this_entry.ip );
            }
           
          }catch( Throwable e ){
View Full Code Here


    return n < 10 ? "0".concat(String.valueOf(n)) : String.valueOf(n);
  }
 
  private static String formatDate(long date, String format) {
    if (date == 0) {return "";}
    SimpleDateFormat temp = new SimpleDateFormat(format);
    return temp.format(new Date(date));
  }
View Full Code Here

      }
     
      synchronized (Logger.class) {
        // Create the date format first *before* we do checkAndSwapLog,
        // just in case we end up invoking logToFile...
        format = new SimpleDateFormat(timeStampFormat);
        checkAndSwapLog();
      }
     
     
    } catch (Throwable t) {
View Full Code Here

      }
    });
  }

  private void setUpLogPanel(final LogPanel logPanel) {
    String date = (new SimpleDateFormat("EEEE, d MMMM yyyy"))
    .format(new Date());
    logPanel.logMessage("Weka Knowledge Flow was written by Mark Hall");
    logPanel.logMessage("Weka Knowledge Flow");
    logPanel.logMessage("(c) 2002-" + Copyright.getToYear() + " "
        + Copyright.getOwner() + ", " + Copyright.getAddress());
View Full Code Here

  {
    try{
      // see rfc822 [EEE,] dd MMM yyyy HH:mm::ss z
      // assume 4 digit year
       
      SimpleDateFormat  format;
     
      if ( date_str.indexOf( "," ) == -1 ){
       
        format = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z", Locale.US );
       
      }else{
       
        format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US );
      }
     
     
      return( format.parse( date_str ));
     
    }catch( ParseException e ){
     
      String[]  fallbacks =
     
        "dd MMM yyyy HH:mm:ss z",        // As above but laxer
        "EEE dd MMM yyyy HH:mm:ss z",      // As above but laxer
        "EEE MMM dd HH:mm:ss z yyyy",      // Fri Sep 26 00:00:00 EDT 2008
        "EEE MMM dd HH:mm z yyyy",        // Fri Sep 26 00:00 EDT 2008 
        "EEE MMM dd HH z yyyy",          // Fri Sep 26 00 EDT 2008 
        "yyyy-MM-dd HH:mm:ss",          // 2009-02-08 22:56:45 
        "yyyy-MM-dd",              // 2009-02-08 
      };
     
        // remove commas as these keep popping up in silly places
     
      date_str = date_str.replace( ',', ' ' );
     
        // remove duplicate white space
     
      date_str = date_str.replaceAll( "(\\s)+", " " );
     
      for (int i=0;i<fallbacks.length;i++){
       
        try{
          returnnew SimpleDateFormat(fallbacks[i], Locale.US ).parse( date_str ));
         
        }catch( ParseException f ){
        }
      }
     
View Full Code Here

   
    for (int i=0;i<formats.length;i++){

      try{
       
        SimpleDateFormat format = new SimpleDateFormat( formats[i], Locale.US );
             
        return( format.parse( date_str ));

      }catch( ParseException e ){
     
        // Debug.printStackTrace(e);
      }
View Full Code Here

     *
     * @param seconds The current timestamp in seconds.
     * @return a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".
     */
    public static String fromUnixTime(int seconds) {
        SimpleDateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.ENGLISH);
        return formatter.format(new Date(seconds * 1000L));
    }
View Full Code Here

     * @param format The format of the date/time String to return.
     * @return a formatted date/time String in the given format.
     */
    public static String fromUnixTime(int seconds, String format) {
        format = convertToSimpleDateFormat(format);
        SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.ENGLISH);
        return formatter.format(new Date(seconds * 1000L));
    }
View Full Code Here

   public void validate(UIFormInput uiInput) throws Exception
   {
      if (uiInput.getValue() == null || ((String)uiInput.getValue()).trim().length() == 0)
         return;
      String s = (String)uiInput.getValue();
      DateFormat stFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      UIFormDateTimeInput uiDateInput = (UIFormDateTimeInput)uiInput;
      SimpleDateFormat sdf = new SimpleDateFormat(uiDateInput.getDatePattern_().trim());

      UIForm uiForm = ((UIComponent)uiInput).getAncestorOfType(UIForm.class);
      String label;
      try
      {
        label = uiForm.getId() + ".label." + uiInput.getName();
      }
      catch (Exception e)
      {
         label = uiInput.getName();
      }
      Object[] args = {label, s};

      try
      {
         // Specify whether or not date/time parsing is to be lenient.
         sdf.setLenient(false);
         Date stDate = sdf.parse(s);
         s = stFormat.format(stDate);
      }
      catch (Exception e)
      {
         throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
View Full Code Here

            } else if (xtvdProgram.getOriginalAirDate() != null) {
              Calendar aircal = Calendar.getInstance();
              java.util.Date date = xtvdProgram.getOriginalAirDate().getDate();
              aircal.setTime(date);
              prog.setIntField(ProgramFieldType.PRODUCTION_YEAR_TYPE, aircal.get(Calendar.YEAR));
              String repetition = new SimpleDateFormat().format(date);
              if (repetition.endsWith("00:00")) {
                repetition = repetition.substring(0, repetition.length() - "00:00".length()).trim();
              }
              prog.setTextField(ProgramFieldType.REPETITION_OF_TYPE, repetition);
            }
View Full Code Here

TOP

Related Classes of java.text.SimpleDateFormat

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.