Exemple #1
0
        public override string ToString()
        {
            var nanosPart = "";
            var nanos     = Nanoseconds;

            if (nanos > 0)
            {
                nanosPart = Utils.FillZeros(nanos, 9);

                var lastPosition = 0;
                for (var i = nanosPart.Length - 1; i > 0; i--)
                {
                    if (nanosPart[i] != '0')
                    {
                        break;
                    }
                    lastPosition = i;
                }
                if (lastPosition > 0)
                {
                    nanosPart = nanosPart.Substring(0, lastPosition);
                }
                nanosPart = "." + nanosPart;
            }
            return
                (Utils.FillZeros(Hour) + ":" +
                 Utils.FillZeros(Minute) + ":" +
                 Utils.FillZeros(Second) +
                 nanosPart);
        }
Exemple #2
0
        /// <summary>
        /// Returns the string representation of the LocalDate in yyyy-MM-dd format
        /// </summary>
        public override string ToString()
        {
            var yearString = Year.ToString();

            if (Year >= 0 && Year < 1000)
            {
                yearString = Utils.FillZeros(Year, 4);
            }
            return(yearString + "-" + Utils.FillZeros(Month) + "-" + Utils.FillZeros(Day));
        }