Package java.text

Examples of java.text.DateFormat


   * @return String The formatted date, with pattern: EEE, d MMM yyyy kk:mm:ss
   *         z
   *
   */
  public static String formatDate(Date date) {
    DateFormat formatter = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
    try {
      SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
      simpleFormatter.applyPattern("EEE, d MMM yyyy kk:mm:ss z");
      String result = simpleFormatter.format(date);
View Full Code Here


   *
   * @return String The formatted date, "yy-MM-dd"
   *
   */
  public static String formatSmartDate(Date date) {
    DateFormat formatter = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
    try {
      SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
      simpleFormatter.applyPattern("yy-MM-dd");
      String result = simpleFormatter.format(date);
View Full Code Here

   *            The patern of the date
   * @return String The formatted date/
   *
   */
  public static String formatDate(Date date, String pPatern) {
    DateFormat formatter = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
    try {
      SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
      simpleFormatter.applyPattern(pPatern);
      String result = simpleFormatter.format(date);
View Full Code Here

    /* Check if Cached already */
    if (DATE_COL_WIDTH > 0)
      return DATE_COL_WIDTH;

    /* Calculate and Cache */
    DateFormat dF = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    Calendar cal = Calendar.getInstance();
    cal.set(2006, Calendar.DECEMBER, 12, 12, 12, 12);
    String sampleDate = dF.format(cal.getTime());

    DATE_COL_WIDTH = OwlUI.getTextSize(fCustomTree.getControl(), OwlUI.getBold(JFaceResources.DEFAULT_FONT), sampleDate).x;
    DATE_COL_WIDTH += 30; // Bounds of TableColumn requires more space

    return DATE_COL_WIDTH;
View Full Code Here

    /* Check if Cached already */
    if (DATE_COL_WIDTH > 0)
      return DATE_COL_WIDTH;

    /* Calculate and Cache */
    DateFormat dF = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    Calendar cal = Calendar.getInstance();
    cal.set(2006, Calendar.DECEMBER, 12, 12, 12, 12);
    String sampleDate = dF.format(cal.getTime());

    DATE_COL_WIDTH = OwlUI.getTextSize(fViewer.getTable(), OwlUI.getBold(JFaceResources.DEFAULT_FONT), sampleDate).x;
    DATE_COL_WIDTH += 30; // Bounds of TableColumn requires more space

    return DATE_COL_WIDTH;
View Full Code Here

        System.out.println( "Stopping server..." );
        server.stop();

        long duration = end.getTime() - start.getTime();
        DateFormat df = new SimpleDateFormat( dFormat );
        BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                .setScale( 2, BigDecimal.ROUND_HALF_UP );
        DecimalFormat dcf = new DecimalFormat( "###.##" );

        try
        {
            System.out.println( "Writing report to file " + outFile );
            boolean append = new File( outFile ).exists();
            BufferedWriter out = new BufferedWriter( new FileWriter( outFile, append ) );
            if ( !append ) out.write( header );
            out.write( "\r\n" );
            out.write( loops + ";" + df.format( start ) + ';' + df.format( end ) + ';' + duration + ";"
                    + dcf.format( resultF ) );
            out.close();
        }
        catch ( IOException e )
        {
View Full Code Here

                    client.close();
                }

                Date end = new Date();
                long duration = end.getTime() - start.getTime();
                DateFormat df = new SimpleDateFormat( dFormat );
                BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                        .setScale( 2, BigDecimal.ROUND_HALF_UP );
                DecimalFormat dcf = new DecimalFormat( "###.##" );

                msgs[0] = adapters[i].getClass().getName() + ';' + df.format( start ) + ';' + df.format( end ) + ';'
                        + duration + ";" + dcf.format( resultF );
                msgs[1] = "-1";

                if ( result == null || !(result instanceof ObjectBean)
                        || !((ObjectBean) result).getTheString().equals( "Accepted" ) )
View Full Code Here

  /*
   * @see
   * org.rssowl.core.interpreter.ITypeImporter#importFrom(org.jdom.Document)
   */
  public List<? extends IEntity> importFrom(Document document) {
    DateFormat dateFormat = DateFormat.getDateInstance();
    Element root = document.getRootElement();

    /* Interpret Children */
    List<?> feedChildren = root.getChildren();
    for (Iterator<?> iter = feedChildren.iterator(); iter.hasNext();) {
View Full Code Here

      }
    }

    /* For each Field Group */
    Set<Entry<String, List<ISearchCondition>>> entries = mapFieldNameToConditions.entrySet();
    DateFormat dateFormat = DateFormat.getDateInstance();
    for (Entry<String, List<ISearchCondition>> entry : entries) {
      String prevSpecName = null;
      String fieldName = entry.getKey();
      List<ISearchCondition> fieldConditions = entry.getValue();
      StringBuilder fieldExpression = new StringBuilder();

      /* Append Field Name */
      fieldExpression.append(fieldName).append(" "); //$NON-NLS-1$

      /* For each Field Condition */
      for (ISearchCondition fieldCondition : fieldConditions) {
        String condValue = fieldCondition.getValue().toString();
        String specName = fieldCondition.getSpecifier().getName();
        int typeId = fieldCondition.getField().getSearchValueType().getId();
        int fieldId = fieldCondition.getField().getId();

        /* Condition Value provided */
        if (condValue.length() > 0) {

          /* Append specifier if not identical with previous */
          if (prevSpecName == null || !prevSpecName.equals(specName)) {
            fieldExpression.append(specName).append(" "); //$NON-NLS-1$
            prevSpecName = specName;
          }

          /* Specially Treat Age */
          if (fieldId == INews.AGE_IN_DAYS || fieldId == INews.AGE_IN_MINUTES) {
            Integer value = Integer.valueOf(condValue);
            if (value >= 0)
              fieldExpression.append(value == 1 ? NLS.bind(Messages.CoreUtils_N_DAY, value) : NLS.bind(Messages.CoreUtils_N_DAYS, value));
            else if (value % 60 == 0)
              fieldExpression.append(value == -60 ? NLS.bind(Messages.CoreUtils_N_HOUR, Math.abs(value) / 60) : NLS.bind(Messages.CoreUtils_N_HOURS, Math.abs(value) / 60));
            else
              fieldExpression.append(value == -1 ? NLS.bind(Messages.CoreUtils_N_MINUTE, Math.abs(value)) : NLS.bind(Messages.CoreUtils_N_MINUTES, Math.abs(value)));
          }

          /* Append Condition Value based on Type */
          else {
            switch (typeId) {
              case ISearchValueType.STRING:
                fieldExpression.append("'").append(condValue).append("'"); //$NON-NLS-1$ //$NON-NLS-2$
                break;
              case ISearchValueType.LINK:
                fieldExpression.append("'").append(condValue).append("'"); //$NON-NLS-1$ //$NON-NLS-2$
                break;
              case ISearchValueType.ENUM:
                condValue = condValue.toLowerCase();
                condValue = condValue.replace("[", ""); //$NON-NLS-1$ //$NON-NLS-2$
                condValue = condValue.replace("]", ""); //$NON-NLS-1$ //$NON-NLS-2$

                fieldExpression.append(condValue.toLowerCase());

                break;
              case ISearchValueType.DATE:
                fieldExpression.append(dateFormat.format(fieldCondition.getValue()));
                break;
              case ISearchValueType.TIME:
                fieldExpression.append(dateFormat.format(fieldCondition.getValue()));
                break;
              case ISearchValueType.DATETIME:
                fieldExpression.append(dateFormat.format(fieldCondition.getValue()));
                break;

              default:
                fieldExpression.append(condValue);
            }
View Full Code Here

   */
  public void exportTo(File destination, Collection<? extends IFolderChild> elements, Set<Options> options) throws InterpreterException {
    Format format = Format.getPrettyFormat();
    format.setEncoding(UTF_8);
    XMLOutputter output = new XMLOutputter(format);
    DateFormat dateFormat = DateFormat.getDateInstance();

    Document document = new Document();
    Element root = new Element(Tag.OPML.get());
    root.setAttribute(Attributes.VERSION.get(), "1.1"); //$NON-NLS-1$
    root.addNamespaceDeclaration(RSSOWL_NS);
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.