Package java.text

Examples of java.text.DateFormat


            log.error("Error while trying to load the object formatting properties!", e);
        }
    }

    public static Date convertToDateWithEnglishLocale(String buildDateString) {
        DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH);
        formatter.setLenient(false);
        Date date = null;
        try {
            date = formatter.parse(buildDateString.toString());
        } catch (ParseException e) {
            log.info("Could not parse : " + buildDateString + " : " + e, e);
        }
        return date;
    }
View Full Code Here


            return null;
        }
    }

    private static DateFormat createDateFormatter(String pattern) {
        DateFormat formatter = new SimpleDateFormat(pattern);
        formatter.setLenient(false);
        return formatter;
    }
View Full Code Here

            ret.append("less than a minute ago");
        return ret.toString();
    }

    public String getFormatDateSimple(Date date) {
        DateFormat df = new SimpleDateFormat("dd MMM");
        return df.format(date);
    }
View Full Code Here

         */
        return true;
    }

    private void recoverToCheckpoint(LogRecord cursorLogRecord) throws ChaiDBException {
        DateFormat df = DateFormat.getDateTimeInstance();
        Date date = new Date(((TxnCkpLogRecord) cursorLogRecord).getTimeStamp());

        System.err.println("Found a checkpoint at: " + df.format(date));
        int offset = cursorLsn.getOffset() + cursorLogRecord.getHeader().getLength();
        int fileId = cursorLsn.getFileId();
        if (offset >= LogManagerImpl.LOG_FILE_MAX_SIZE) {
            fileId++;
            offset = 0;
View Full Code Here

    @Required public final void setSupportedLocales(List<Locale> supportedLocales) {
        this.supportedLocales = supportedLocales;
    }

    private String getDateFormat(HttpServletResponse response) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, response.getLocale());
        String pattern = df instanceof SimpleDateFormat ? ((SimpleDateFormat) df).toPattern() : "dd/MM/yyyy";
        if ("MM/d/yy".equals(pattern)) pattern = "MM/dd/yyyy";
        if ("d/MM/yy".equals(pattern)) pattern = "dd/MM/yyyy";
        return pattern;
    }
View Full Code Here

     * @return  ISO-8601 format time stamp.
     */
    private String timestamp() {
        String timestamp = null;
        Calendar cal = Calendar.getInstance();
        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        dfm.setTimeZone(TimeZone.getTimeZone("GMT"));
        timestamp = dfm.format(cal.getTime());
        return timestamp;
    }
View Full Code Here

      if (localeUsed == null)
      {
        localeUsed = getResourceBundleFactory().getLocale();
      }

      final DateFormat format;
      if (dateFormat == null || ObjectUtilities.equal(localeUsed, lastLocale) == false)
      {
        final String formatString = getFormat();
        if (formatString == null || formatString.length() == 0)
        {
          format = DateFormat.getDateInstance(DateFormat.DEFAULT, localeUsed);
          dateFormat = format;
          lastLocale = localeUsed;
        }
        else
        {
          final SimpleDateFormat sformat = new SimpleDateFormat(formatString);
          if (locale != null)
          {
            sformat.setDateFormatSymbols(new DateFormatSymbols(locale));
          }
          else
          {
            final ResourceBundleFactory factory = getResourceBundleFactory();
            sformat.setDateFormatSymbols(new DateFormatSymbols(factory.getLocale()));
          }
          format = sformat;
          dateFormat = sformat;
          lastLocale = localeUsed;
        }
      }
      else
      {
        format = dateFormat;
      }
      if (ObjectUtilities.equal(timeZone, lastTimeZone) == false)
      {
        lastTimeZone = timeZone;
        format.setTimeZone(timeZone);
      }
      return format.parse(String.valueOf(o));
    }
    catch (ParseException e)
    {
      return null;
    }
View Full Code Here

   }
  
   @Transient
   public String getDescription()
   {
      DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
      return hotel==null ? null : hotel.getName() +
            ", " + df.format( getCheckinDate() ) +
            " to " + df.format( getCheckoutDate() );
   }
View Full Code Here

   }
  
   @Transient
   public String getDescription()
   {
      DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
      return hotel==null ? null : hotel.getName() +
            ", " + df.format( getCheckinDate() ) +
            " to " + df.format( getCheckoutDate() );
   }
View Full Code Here

            this.pool.update("DELETE from " + this.replPrefix + "items");
            // long time = System.currentTimeMillis();
            // Date date = new Date(time);
            // String txt = "YYYY-MM-DD HH24:MI:SS"
            String txt = "2005-11-05 23:04:31.345";
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
            long time = format.parse(txt).getTime();
            Date date = new Date(time);
            System.out.println("Date: '" + time + "' is '" + date.toString() + "' and again as millis: '" + date.getTime());
            PreparedStatement st1 = conn.prepareStatement("INSERT INTO " + this.tableName + " VALUES (?)");
            st1.setDate(1, date);
            st1.executeUpdate();
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.