Exemple #1
0
        // #endif

        public override StringBuilder FormatObject(Object obj0, StringBuilder toAppend,
                                                   ILOG.J2CsMapping.Text.FieldPosition pos)
        {
            if (obj0   is  Int64)
            {
                String res = FormatDurationFromNow(((Int64)obj0));
                return(toAppend.Append(res));
            }
            else if (obj0   is  DateTime)
            {
                String res_0 = FormatDurationFromNowTo(((DateTime)obj0));
                return(toAppend.Append(res_0));
            }
            // #if defined(FOUNDATION10) || defined(J2SE13) || defined(J2SE14)
            // #else
            if (checkXMLDuration)
            {
                try {
                    /*if (obj0   is  Javax.Xml.Datatype.Duration) {
                     *  String res_1 = FormatDuration(obj0);
                     *  return toAppend.Append(res_1);
                     * }*/
                    throw new NotImplementedException();
                } catch (ReflectionTypeLoadException ncdfe) {
                    System.Console.Error.WriteLine("Skipping XML capability");
                    checkXMLDuration = false;     // don't try again
                }
            }
            // #endif
            throw new ArgumentException(
                      "Cannot format given Object as a Duration");
        }
Exemple #2
0
        /*
         * (non-Javadoc)
         *
         * @see com.ibm.icu.text.DateFormat#format(com.ibm.icu.util.Calendar,
         * java.lang.StringBuffer, java.text.FieldPosition)
         */
        public override StringBuilder Format(Calendar cal, StringBuilder toAppendTo,
                                             ILOG.J2CsMapping.Text.FieldPosition fieldPosition)
        {
            // calculate the difference, in days, between 'cal' and now.
            int dayDiff = DayDifference(cal);

            // look up string
            String theString = GetStringForDay(dayDiff);

            if (theString == null)
            {
                // didn't find it. Fall through to the fDateFormat
                if (fDateFormat != null)
                {
                    return(fDateFormat.Format(cal, toAppendTo, fieldPosition));
                }
                else
                {
                    return(toAppendTo);    // no op
                }
            }
            else
            {
                // found a relative string
                return(toAppendTo.Append(theString));
            }
        }
 /// <summary>
 /// Format an arbitrary object. Defaults to a call to formatDurationFromNow()
 /// for either Long or Date objects.
 /// </summary>
 ///
 /// <param name="object">the object to format. Should be either a Long, Date, orjavax.xml.datatype.Duration object.</param>
 /// <param name="toAppend">the buffer to append to</param>
 /// <param name="pos">the field position, may contain additional error messages.</param>
 /// <returns>the toAppend buffer</returns>
 /// @draft ICU 3.8
 /// @provisional This API might change or be removed in a future release.
 public abstract override StringBuilder FormatObject(Object obj0, StringBuilder toAppend,
                                                     ILOG.J2CsMapping.Text.FieldPosition pos);