      *  Formats a Date into a String according to the <code>outputFormat</code> argument.
      *  The <code>outputFormat</code> argument contains a pattern in which
      *  the <code>value</code> String is formatted.
-     *  It can contain <code>"M"</code>,<code>"D"</code>,<code>"Y"</code>,
+     *  It can contain <code>"M"</code>,<code>"MM"</code>,<code>"D"</code>,
+	 *  <code>"DD"</code>,<code>"YY"</code>,<code>"YYYY"</code>
      *  and delimiter and punctuation characters.
      *
      *  @param value Date value to format.

     *  object corresponding to the String.
     *  The <code>inputFormat</code> argument contains the pattern
     *  in which the <code>valueString</code> String is formatted.
     *  It can contain <code>"M"</code>,<code>"D"</code>,<code>"Y"</code>,
     *  and delimiter and punctuation characters.
     *
     *  <p>The function does not check for the validity of the Date object.

     */
    public static function dateToString(value:Date, outputFormat:String):String
    {
		var maskChar:String;
		var maskParts:Array = [];
		var part:int = 0;
		var length:int = outputFormat.length;
		
		if (!value || isNaN(value.getTime()))
			return "";
		
		length = outputFormat.length;
		part = -1;

		var lastChar:String;
		
		for (var i:int = 0; i < length; i++)
		{
			maskChar = outputFormat.charAt(i);
			
			if (maskChar == "Y" || maskChar == "M" || maskChar == "D")
			{
				if (maskChar != lastChar)
				{
					part++;
					maskParts[part] = "";
				}
				maskParts[part] += maskChar;
			}
			else {
				part++;
				maskParts[part] = maskChar;
			}
			
			lastChar = maskChar;
		}
		
        var date:String = String(value.getDate());
        var month:String = String(value.getMonth() + 1);
        var year:String = String(value.getFullYear());

        var mask:String;
		var maskLength:int
		var output:String = "";

        length = maskParts.length;
        for (i = 0; i < length; i++)
        {
            mask = maskParts[i].charAt(0);
			maskLength = maskParts[i].length;
			
			if (mask == "D")
			{
				if (maskLength > 1 && date.length == 1)
					date = "0" + date;
				
				output += date;
			}
			else if (mask == "M")
			{
				if (maskLength > 1 && month.length == 1)
					month = "0" + month;
				
				output += month;
			}
			else if (mask == "Y")
			{
				if (maskLength == 2)
					output += year.substr(2,2);
				else
					output += year;
			}
            else
            {
                output += mask;
