Наследование: java.lang.Object
Пример #1
0
 public virtual StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
 {
   string str = String.instancehelper_toUpperCase(Long.toHexString(number));
   int num1 = this.m_numDigits - String.instancehelper_length(str);
   int num2 = 0 >= num1 ? 0 : num1;
   StringBuffer stringBuffer = new StringBuffer("0x");
   for (int index = 0; index < num2; ++index)
     stringBuffer.append(0);
   stringBuffer.append(str);
   return stringBuffer;
 }
Пример #2
0
        /// <summary>
        /// Returns pattern with formatted double. </summary>
        /// <param name="number"> number to be formatted and substituted. </param>
        /// <param name="toAppendTo"> where text is appended. </param>
        /// <param name="status"> ignore no useful status is returned. </param>
        public override StringBuffer Format(double number, StringBuffer toAppendTo, FieldPosition status)
        {
            // find the number
            int i;

            for (i = 0; i < ChoiceLimits.Length; ++i)
            {
                if (!(number >= ChoiceLimits[i]))
                {
                    // same as number < choiceLimits, except catchs NaN
                    break;
                }
            }
            --i;
            if (i < 0)
            {
                i = 0;
            }
            // return either a formatted number, or a string
            return(toAppendTo.Append(ChoiceFormats[i]));
        }
Пример #3
0
        // Overrides

        /// <summary>
        /// Specialization of format. This method really calls
        /// <code>format(double, StringBuffer, FieldPosition)</code>
        /// thus the range of longs that are supported is only equal to
        /// the range that can be stored by double. This will never be
        /// a practical limitation.
        /// </summary>
        public override StringBuffer Format(long number, StringBuffer toAppendTo, FieldPosition status)
        {
            return(Format((double)number, toAppendTo, status));
        }
Пример #4
0
 public virtual StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
 {
   return this.format(ByteCodeHelper.d2l(number), toAppendTo, pos);
 }
 /// <summary>
 /// Formats the given <code>Date</code> into a date/time string and appends the result to the given <code>StringBuffer</code>.
 /// </summary>
 public override StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
 {
     return default(StringBuffer);
 }
Пример #6
0
 /// <summary>
 /// Formats an object and appends the resulting text to a given string
 /// buffer.
 /// If the <code>pos</code> argument identifies a field used by the format,
 /// then its indices are set to the beginning and end of the first such
 /// field encountered.
 /// </summary>
 /// <param name="obj">    The object to format </param>
 /// <param name="toAppendTo">    where the text is to be appended </param>
 /// <param name="pos">    A <code>FieldPosition</code> identifying a field
 ///               in the formatted text </param>
 /// <returns>       the string buffer passed in as <code>toAppendTo</code>,
 ///               with formatted text appended </returns>
 /// <exception cref="NullPointerException"> if <code>toAppendTo</code> or
 ///            <code>pos</code> is null </exception>
 /// <exception cref="IllegalArgumentException"> if the Format cannot format the given
 ///            object </exception>
 public abstract StringBuffer Format(Object obj, StringBuffer toAppendTo, FieldPosition pos);
Пример #7
0
 /// <summary>
 /// Formats the given <code>Date</code> into a date/time string and appends the result to the given <code>StringBuffer</code>.
 /// </summary>
 public override StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
 {
     return(default(StringBuffer));
 }
Пример #8
0
 protected StringBuilder format(object o, StringBuilder stringBuilder, FieldPosition fieldPosition)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 /// <summary>
 /// Formats a Date into a date/time string.
 /// </summary>
 public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition);
Пример #10
0
 /// <summary>
 /// Overrides Format.
 /// Formats a time object into a time string. Examples of time objects
 /// are a time value expressed in milliseconds and a Date object. </summary>
 /// <param name="obj"> must be a Number or a Date. </param>
 /// <param name="toAppendTo"> the string buffer for the returning time string. </param>
 /// <returns> the string buffer passed in as toAppendTo, with formatted text appended. </returns>
 /// <param name="fieldPosition"> keeps track of the position of the field
 /// within the returned string.
 /// On input: an alignment field,
 /// if desired. On output: the offsets of the alignment field. For
 /// example, given a time text "1996.07.10 AD at 15:08:56 PDT",
 /// if the given fieldPosition is DateFormat.YEAR_FIELD, the
 /// begin index and end index of fieldPosition will be set to
 /// 0 and 4, respectively.
 /// Notice that if the same time field appears
 /// more than once in a pattern, the fieldPosition will be set for the first
 /// occurrence of that time field. For instance, formatting a Date to
 /// the time string "1 PM PDT (Pacific Daylight Time)" using the pattern
 /// "h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD,
 /// the begin index and end index of fieldPosition will be set to
 /// 5 and 8, respectively, for the first occurrence of the timezone
 /// pattern character 'z'. </param>
 /// <seealso cref= java.text.Format </seealso>
 public sealed override StringBuffer Format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
 {
     if (obj is DateTime)
     {
         return(Format((DateTime)obj, toAppendTo, fieldPosition));
     }
     else if (obj is Number)
     {
         return(Format(new DateTime(((Number)obj).LongValue()), toAppendTo, fieldPosition));
     }
     else
     {
         throw new IllegalArgumentException("Cannot format given Object as a Date");
     }
 }
Пример #11
0
 /// <summary>
 /// Overrides Format.
 /// </summary>
 public StringBuffer format(object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
 {
     return default(StringBuffer);
 }
Пример #12
0
 /// <summary>
 /// Formats a Date into a date/time string.
 /// </summary>
 public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition);
Пример #13
0
 public virtual StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
 {
   StringBuffer stringBuffer = new StringBuffer();
   if (this.showBase)
   {
     stringBuffer.append(this.baseLabel);
     stringBuffer.append("^");
   }
   stringBuffer.append(this.formatter.format(this.calculateLog((double) number)));
   return stringBuffer;
 }
Пример #14
0
 public virtual StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
 {
   long num1 = date.getTime() - this.baseMillis;
   string str;
   if (num1 < 0L)
   {
     num1 *= -1L;
     str = "-";
   }
   else
     str = this.positivePrefix;
   long num2 = num1;
   long num3 = RelativeDateFormat.MILLISECONDS_IN_ONE_DAY;
   long num4 = -1L;
   long num5 = num3 != num4 ? num2 / num3 : -num2;
   long num6 = num1 - num5 * RelativeDateFormat.MILLISECONDS_IN_ONE_DAY;
   long num7 = num6;
   long num8 = RelativeDateFormat.MILLISECONDS_IN_ONE_HOUR;
   long num9 = -1L;
   long num10 = num8 != num9 ? num7 / num8 : -num7;
   long num11 = num6 - num10 * RelativeDateFormat.MILLISECONDS_IN_ONE_HOUR;
   long num12 = num11 / 60000L;
   double num13 = (double) (num11 - num12 * 60000L) / 1000.0;
   toAppendTo.append(str);
   if (num5 != 0L || this.showZeroDays)
     toAppendTo.append(new StringBuffer().append(this.dayFormatter.format(num5)).append(this.getDaySuffix()).toString());
   if (num10 != 0L || this.showZeroHours)
     toAppendTo.append(new StringBuffer().append(this.hourFormatter.format(num10)).append(this.getHourSuffix()).toString());
   toAppendTo.append(new StringBuffer().append(this.minuteFormatter.format(num12)).append(this.getMinuteSuffix()).toString());
   toAppendTo.append(new StringBuffer().append(this.secondFormatter.format(num13)).append(this.getSecondSuffix()).toString());
   return toAppendTo;
 }
Пример #15
0
 /// <summary>
 /// Overrides Format.
 /// </summary>
 public StringBuffer format(object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
 {
     return(default(StringBuffer));
 }
Пример #16
0
 public virtual StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
 {
   ((Calendar) this.calendar).setTime(date);
   int index = ((Calendar) this.calendar).get(2);
   toAppendTo.append(this.months[index]);
   if (this.showYear[index])
     toAppendTo.append(this.yearFormatter.format(date));
   return toAppendTo;
 }
Пример #17
0
 public virtual StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
 {
   return toAppendTo.append(this.getDirectionCode((double) number));
 }