コード例 #1
0
        // tries to parse a string with the formats supported by SimpleDateFormat
        /// <exception cref="Sharpen.ParseException"></exception>
        private static DateTime Parse_simple(string dateStr, GitDateParser.ParseableSimpleDateFormat
                                             f)
        {
            SimpleDateFormat dateFormat = GetDateFormat(f);

            dateFormat.SetLenient(false);
            return(dateFormat.Parse(dateStr));
        }
コード例 #2
0
        // Gets an instance of a SimpleDateFormat. If there is not already an
        // appropriate instance in the (ThreadLocal) cache the create one and put in
        // into the cache
        private static SimpleDateFormat GetDateFormat(GitDateParser.ParseableSimpleDateFormat
                                                      f)
        {
            formatCache = formatCache ?? new Dictionary <GitDateParser.ParseableSimpleDateFormat
                                                         , SimpleDateFormat>();
            SimpleDateFormat dateFormat = formatCache.Get(f);

            if (dateFormat != null)
            {
                return(dateFormat);
            }
            SimpleDateFormat df = SystemReader.GetInstance().GetSimpleDateFormat(f.formatStr);

            formatCache.Put(f, df);
            return(df);
        }
コード例 #3
0
ファイル: GitDateParser.cs プロジェクト: TetradogOther/NGit
        // Gets an instance of a SimpleDateFormat. If there is not already an
        // appropriate instance in the (ThreadLocal) cache the create one and put in
        // into the cache
        private static SimpleDateFormat GetDateFormat(GitDateParser.ParseableSimpleDateFormat
                                                      f)
        {
            IDictionary <GitDateParser.ParseableSimpleDateFormat, SimpleDateFormat> map = formatCache
                                                                                          .Value;
            SimpleDateFormat dateFormat = map.Get(f);

            if (dateFormat != null)
            {
                return(dateFormat);
            }
            SimpleDateFormat df = SystemReader.GetInstance().GetSimpleDateFormat(f.formatStr);

            map.Put(f, df);
            return(df);
        }