static void Main(string[] args) { while(true) { var corn = Console.ReadLine(); var s=getCronSchdule(corn, 10, DateTimeOffset.Now); Console.WriteLine(s); } } /// <summary> /// Corn表达式的运行时间 /// </summary> /// <param name="cron">表达式</param> /// <param name="times">计算次数</param> /// <param name="startTime">开始时间</param> /// <returns></returns> public static String getCronSchdule(String cron, int times, DateTimeOffset startTime) { String timeSchdule = ""; if (!CronExpression.IsValidExpression(cron)) { return "Cron is Illegal!"; } try { ITrigger trigger1 = TriggerBuilder.Create().WithCronSchedule(cron)//.StartAt(DateTimeOffset.UtcNow) .Build(); DateTimeOffset? LastTime = startTime; //Console.WriteLine(LastTime.ToString()); for (int i = 0; i < times; i++) { DateTimeOffset? s = trigger1.GetFireTimeAfter(LastTime); LastTime = s; Console.WriteLine(((DateTimeOffset)s).AddHours(8).ToString()); } } catch (Exception e) { timeSchdule = "unKnow Time!"; } return timeSchdule; }