Package java.text

Examples of java.text.DateFormat


            }
            catch (IllegalArgumentException e) {
               assertTrue("An exception should not occur when parsing '" + txt + "'", false);
            }

            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
            long time = format.parse(txt).getTime();
            Timestamp date = new Timestamp(time);
            date.setNanos(999);
            System.out.println("Date: '" + time + "' is '" + date.toString() + "' and again as millis: '" + date.getTime());
            PreparedStatement st1 = conn.prepareStatement("INSERT INTO " + this.tableName + " VALUES (?)");
            st1.setTimestamp(1, date);
View Full Code Here


    * @return the date parsed
    * @see http://www.faqs.org/rfcs/rfc2156.html
    * @throws IllegalArgumentException on ParseException
    */
   public static Date dateTime(String dateString) {
      DateFormat df = new MailDateFormat();
      try {
         return df.parse(dateString);
      } catch (java.text.ParseException e) {
         throw new IllegalArgumentException("Can't parse date-time string '" + dateString + "', please check email RFC 822: " + e.toString());
      }    
   }
View Full Code Here

   /**
    * @param date
    * @return The http://www.faqs.org/rfcs/rfc822.html "date-time" string
    */
   public static String dateTime(Date date) {
      DateFormat df = new MailDateFormat();
      return df.format(date);    
   }
View Full Code Here

         }
         toFront();
      }


      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
      String text = df.format(new java.util.Date());
      text += "[" + updateQos.getSender() +"]: ";
      text += msgContent;
      appendOutput(text +System.getProperty("line.separator"));
      log.info("CallBack\n");
View Full Code Here

        {
            // Stat the file
            System.out.println(file.getName());
            final FileContent content = file.getContent();
            System.out.println("Size: " + content.getSize() + " bytes.");
            final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
            final String lastMod = dateFormat.format(new Date(content.getLastModifiedTime()));
            System.out.println("Last modified: " + lastMod);
        }
    }
View Full Code Here

     * @exception ParseException If the string is not a valid timestamp.
     */
    static int[] parseLocalTimestamp( String str, LocaleFinder localeFinder, Calendar cal)
        throws StandardException, ParseException
    {
        DateFormat timestampFormat = null;
        if(localeFinder == null)
            timestampFormat = DateFormat.getDateTimeInstance();
        else if( cal == null)
            timestampFormat = localeFinder.getTimestampFormat();
        else
            timestampFormat = (DateFormat) localeFinder.getTimestampFormat().clone();
        if( cal == null)
            cal = new GregorianCalendar();
        else
            timestampFormat.setCalendar( cal);
        java.util.Date date = timestampFormat.parse( str);
           
        return new int[] { computeEncodedDate( date, cal), computeEncodedTime( date, cal)};
    } // end of parseLocalTimestamp
View Full Code Here

          throws RegainException {

    String value = hit.get("last-modified");

    if (value != null || value.length() > 0) {
      DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, request.getLocale());
      DateFormat formatter = new SimpleDateFormat("yyyyMMdd");

      try {
        response.print(dateFormatter.format((Date) formatter.parse(value)));

      } catch (ParseException ex) {
        throw new RegainException("Couldn't parse last-modified date.", ex);
      }
    }
View Full Code Here

/* Looks like:
Received: from iamhelo (wasabi.infohazard.org [209.237.247.14])
        by mx.google.com with SMTP id 32si2669129wfa.13.2009.05.27.18.27.31;
        Wed, 27 May 2009 18:27:48 -0700 (PDT)
*/
    DateFormat fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z (z)", Locale.US);
    String timestamp = fmt.format(new Date());

    StringBuilder header = new StringBuilder();
    header.append("Received: from " + heloHost + " (" + constructTcpInfo(host) + ")\r\n");
    header.append("        by " + whoami + " with SMTP");
    if (softwareName != null)
View Full Code Here

    int id4 = GnizrDaoUtil.createUserTagIfNotExist(tagDao, userDao, tag3, defaultUser);
    assertEquals(id3,id4);
  }
 
  public void testToDayStarts() throws Exception{
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Date date = df.parse("2007-01-11T12:13:93");
    Date dateStarts = GnizrDaoUtil.toDayBegins(date);
    Calendar c = Calendar.getInstance();
    c.setTime(dateStarts);
    assertEquals(2007,c.get(Calendar.YEAR));
    assertEquals(0,c.get(Calendar.MONTH));
View Full Code Here

    assertEquals(0,c.get(Calendar.MINUTE));
    assertEquals(0,c.get(Calendar.SECOND));
  }
 
  public void testToDayEnds() throws Exception{
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Date date = df.parse("2007-01-11T12:13:93");
    Date dateEnds = GnizrDaoUtil.toDayEnds(date);
    Calendar c = Calendar.getInstance();
    c.setTime(dateEnds);
    assertEquals(2007,c.get(Calendar.YEAR));
    assertEquals(0,c.get(Calendar.MONTH));
View Full Code Here

TOP

Related Classes of java.text.DateFormat

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.