/** * Creates a elapsed time formatter. * * @param pattern The pattern to Parse. */ public CellElapsedFormatter(String pattern) : base(pattern) { specs = new List <TimeSpec>(); StringBuilder desc = CellFormatPart.ParseFormat(pattern, CellFormatType.ELAPSED, new ElapsedPartHandler(this)); //ListIterator<TimeSpec> it = specs.ListIterator(specs.Count); //while (it.HasPrevious()) for (int i = specs.Count - 1; i >= 0; i--) { //TimeSpec spec = it.Previous(); TimeSpec spec = specs[i]; //desc.Replace(spec.pos, spec.pos + spec.len, "%0" + spec.len + "d"); desc.Remove(spec.pos, spec.len); desc.Insert(spec.pos, "D" + spec.len); if (spec.type != topmost.type) { spec.modBy = modFor(spec.type, spec.len); } } printfFmt = desc.ToString(); }
/** * Creates a new date formatter with the given specification. * * @param format The format. */ public CellDateFormatter(String format) : base(format) { ; DatePartHandler partHandler = new DatePartHandler(this); StringBuilder descBuf = CellFormatPart.ParseFormat(format, CellFormatType.DATE, partHandler); partHandler.Finish(descBuf); dateFmt = new SimpleDateFormat(descBuf.ToString()); }
public CellTextFormatter(String format) : base(format) { ; int[] numPlaces = new int[1]; PartHandler handler = new PartHandler(numPlaces[0]); desc = CellFormatPart.ParseFormat(format, CellFormatType.TEXT, handler).ToString(); // Remember the "@" positions in last-to-first order (to make insertion easier) textPos = new int[handler.NumPlace]; int pos = desc.Length - 1; for (int i = 0; i < textPos.Length; i++) { textPos[i] = desc.LastIndexOf("\u0000", pos); pos = textPos[i] - 1; } }