ConvertYYYYMMDDtoXmlDate

We had a case where many maps need to convert YYYYMMDD date format to a standard XML date.

<pre>

        /// <summary>
        /// Convert date in format YYYYMMDD to the standard XML Date format
        /// </summary>
        /// <param name="inDate"></param>
        /// <returns></returns>
        public static string ConvertYYYYMMDDtoXmlDate(string inDate)
        {
            try
            {
                return inDate.Substring(0, 4) + "-" +
                        inDate.Substring(4, 2) + "-" +
                        inDate.Substring(6, 2);
            }
            catch
            {
                return "invalid-YYYYMMDD-conversion from value=" + inDate + "'";
            }
        }

</pre>

Uncategorized  

Leave a Reply