Package java.text

Examples of java.text.SimpleDateFormat.applyPattern()


  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);
      return result;
    } catch (Exception e) {
      // Simple formatter not supported.
    }
View Full Code Here


    if (pString != null && !"".equals(pString)) {
      SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
      for (int i = 0; i < lDateFormats.length; i++) {
        String lFormat = lDateFormats[i];
        simpleFormatter.applyPattern(lFormat);
        try {
          lDate = simpleFormatter.parse(pString);
          break;
        } catch (ParseException pe) {
          // keep trying.
View Full Code Here

  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);
      return result;
    } catch (Exception e) {
      // Simple formatter not supported.
    }
View Full Code Here

  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);
      return result;
    } catch (Exception e) {
      // Simple formatter not supported.
    }
View Full Code Here

    {
      if (locPattern) {
        formatter.applyLocalizedPattern(pattern);
      }
      else {
        formatter.applyPattern(pattern);
      }
    }
    return formatter.parse((String) value);
  }
View Full Code Here

    return statisticResult;
  }

  private String getWeek(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("ww");
    return sdf.format(date);
  }

  private String getYear(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
View Full Code Here

    return sdf.format(date);
  }

  private String getYear(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy");
    return sdf.format(date);
  }

  /** fill any gaps in the column headers between the first and the last days **/
  private void fillGapsInColumnHeaders(StatisticResult statisticResult) {
View Full Code Here

        }

        SimpleDateFormat format = session.getSimpleDateFormatGMT();

        try {
            format.applyPattern(javaPattern);
        } catch (Exception e) {}

        Date date = (Date) convertSQLToJavaGMT(session, dateTime);

        return format.format(date);
View Full Code Here

                SimpleDateFormat format = session.getSimpleDateFormatGMT();
                String javaPattern =
                    HsqlDateTime.toJavaDatePattern((String) data[1]);

                try {
                    format.applyPattern(javaPattern);
                } catch (Exception e) {
                    throw Error.error(ErrorCode.X_22511);
                }

                Date date =
View Full Code Here

        try
        {
          SimpleDateFormat dateFormat = new SimpleDateFormat(formatsIn[i]);
          dateFormat.setLenient(false);
          Date dt = dateFormat.parse(in);         
          dateFormat.applyPattern(formatOut);
          return dateFormat.format(dt);
        }
        catch (ParseException pe)
        {
          // If ParseException occurred during input string, input is invalid.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.