// 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)); }
// 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); }
// 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); }