Package java.text

Examples of java.text.DateFormatSymbols


      {
        this.formatString = String.valueOf(formatStringRaw);
        this.locale = locale;
        this.timeZone = timeZone;
        this.dateFormat = new SimpleDateFormat(formatString, locale);
        this.dateFormat.setDateFormatSymbols(new DateFormatSymbols(locale));
        this.dateFormat.setTimeZone(timeZone);
      }
      else
      {
        if (ObjectUtilities.equal(formatString, formatStringRaw) == false)
        {
          this.formatString = String.valueOf(formatStringRaw);
          this.dateFormat.applyPattern(formatString);
        }

        if (ObjectUtilities.equal(this.locale, locale) == false)
        {
          this.locale = locale;
          this.dateFormat.setDateFormatSymbols(new DateFormatSymbols(locale));
        }

        if (ObjectUtilities.equal(this.timeZone, timeZone) == false)
        {
          this.timeZone = timeZone;
View Full Code Here


        if (format == null) {
            if (locale == null) {
                locale = Locale.getDefault();
            }
            if (symbols == null) {
                symbols = new DateFormatSymbols(locale);
            }
            format = new FastDateFormat(pattern, timeZone, locale, symbols);
            cInstanceCache.put(key, format);
        }
        return format;
View Full Code Here

        mPattern = pattern;
        mTimeZone = timeZone;
        mLocale = locale;

        if (symbols == null) {
            symbols = new DateFormatSymbols(locale);
        }

        List rulesList = parse(pattern, timeZone, locale, symbols);
        mRules = (Rule[])rulesList.toArray(new Rule[rulesList.size()]);
View Full Code Here

  if (!checkDisplayNameParams(field, style, ALL_STYLES, LONG, locale,
            ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
      return null;
  }

  DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
  String[] strings = getFieldStrings(field, style, symbols);
  if (strings != null) {
      int fieldValue = get(field);
      if (fieldValue < strings.length) {
    return strings[fieldValue];
View Full Code Here

  // SHORT or LONG
  return getDisplayNamesImpl(field, style, locale);
    }

    private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
  DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
  String[] strings = getFieldStrings(field, style, symbols);
  if (strings != null) {
      Map<String,Integer> names = new HashMap<String,Integer>();
      for (int i = 0; i < strings.length; i++) {
    if (strings[i].length() == 0) {
View Full Code Here

      }
      case DateTime.AM_PM:       { // 'p' (am or pm)
    // Calendar.AM = 0, Calendar.PM = 1, LocaleElements defines upper
    String[] ampm = { "AM", "PM" };
    if (l != null && l != Locale.US) {
        DateFormatSymbols dfs = DateFormatSymbols.getInstance(l);
        ampm = dfs.getAmPmStrings();
    }
    String s = ampm[t.get(Calendar.AM_PM)];
    sb.append(s.toLowerCase(l != null ? l : Locale.US));
    break;
      }
      case DateTime.SECONDS_SINCE_EPOCH: { // 's' (0 - 99...?)
    long i = t.getTimeInMillis() / 1000;
    Flags flags = Flags.NONE;
    sb.append(localizedMagnitude(null, i, flags, width, l));
    break;
      }
      case DateTime.SECOND:      { // 'S' (00 - 60 - leap second)
    int i = t.get(Calendar.SECOND);
    Flags flags = Flags.ZERO_PAD;
    sb.append(localizedMagnitude(null, i, flags, 2, l));
    break;
      }
      case DateTime.ZONE_NUMERIC: { // 'z' ({-|+}####) - ls minus?
    int i = t.get(Calendar.ZONE_OFFSET);
    boolean neg = i < 0;
    sb.append(neg ? '-' : '+');
    if (neg)
        i = -i;
    int min = i / 60000;
    // combine minute and hour into a single integer
    int offset = (min / 60) * 100 + (min % 60);
    Flags flags = Flags.ZERO_PAD;

    sb.append(localizedMagnitude(null, offset, flags, 4, l));
    break;
      }
      case DateTime.ZONE:        { // 'Z' (symbol)
    TimeZone tz = t.getTimeZone();
    sb.append(tz.getDisplayName((t.get(Calendar.DST_OFFSET) != 0),
             TimeZone.SHORT,
             l));
    break;
      }

            // Date
      case DateTime.NAME_OF_DAY_ABBREV:     // 'a'
      case DateTime.NAME_OF_DAY:          { // 'A'
    int i = t.get(Calendar.DAY_OF_WEEK);
    Locale lt = ((l == null) ? Locale.US : l);
    DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
    if (c == DateTime.NAME_OF_DAY)
        sb.append(dfs.getWeekdays()[i]);
    else
        sb.append(dfs.getShortWeekdays()[i]);
    break;
      }
      case DateTime.NAME_OF_MONTH_ABBREV:   // 'b'
      case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b
      case DateTime.NAME_OF_MONTH:        { // 'B'
    int i = t.get(Calendar.MONTH);
    Locale lt = ((l == null) ? Locale.US : l);
    DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
    if (c == DateTime.NAME_OF_MONTH)
        sb.append(dfs.getMonths()[i]);
    else
        sb.append(dfs.getShortMonths()[i]);
    break;
      }
      case DateTime.CENTURY:                // 'C' (00 - 99)
      case DateTime.YEAR_2:                 // 'y' (00 - 99)
      case DateTime.YEAR_4:               { // 'Y' (0000 - 9999)
View Full Code Here

   * @param datedObjects
   * @param locale
   */
  YearNavigationModel(List<? extends Dated> datedObjects, Locale locale) {
    cal = Calendar.getInstance();
    symbols = new DateFormatSymbols(locale);
    initializeYears(datedObjects);
  }
View Full Code Here

  /// @synopsis string format(string format)
  public static final Object[] p_format = { null, "format" }
  public Any m_format(Context context, String format)
  {
    try {
      DateFormatSymbols dfsymbols = new DateFormatSymbols(context.getLocale());
      SimpleDateFormat df = new SimpleDateFormat(format, dfsymbols);
      return Any.create(df.format(_calendar.getTime()));
    } catch (IllegalArgumentException e) {
      throw context.BadParameter(e.getMessage());
    }
View Full Code Here

  /// @synopsis Calendar parseDate(string date, string format)
  public static final Object[] p_parseDate = { null, "date", "format" };
  public static Any parseDate(Context context, String date, String format)
  {
    try {
      DateFormatSymbols dfsymbols = new DateFormatSymbols(context.getLocale());
      SimpleDateFormat df = new SimpleDateFormat(format, dfsymbols);
      Calendar cal = Calendar.getInstance();
      cal.setTime(df.parse(date));
      return new AnyCalendar(cal);
View Full Code Here

        if (format == null) {
            if (locale == null) {
                locale = Locale.getDefault();
            }
            if (symbols == null) {
                symbols = new DateFormatSymbols(locale);
            }
            format = new FastDateFormat(pattern, timeZone, locale, symbols);
            cInstanceCache.put(key, format);
        }
        return format;
View Full Code Here

TOP

Related Classes of java.text.DateFormatSymbols

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.