19 using Lucene.Net.Search;
20 using Lucene.Net.Support;
62 [Obsolete(
"If you build a new index, use DateTools or NumericField instead.This class is included for use with existing indices and will be removed in a future release (possibly Lucene 4.0).")]
73 public static System.String MIN_DATE_STRING()
75 return TimeToString(0);
78 public static System.String MAX_DATE_STRING()
80 char[] buffer =
new char[DATE_LEN];
82 for (
int i = 0; i < DATE_LEN; i++)
84 return new System.String(buffer);
91 public static System.String DateToString(System.DateTime date)
93 TimeSpan ts = date.Subtract(
new DateTime(1970, 1, 1));
94 ts = ts.Subtract(TimeZone.CurrentTimeZone.GetUtcOffset(date));
95 return TimeToString(ts.Ticks / TimeSpan.TicksPerMillisecond);
101 public static System.String TimeToString(
long time)
104 throw new System.SystemException(
"time '" + time +
"' is too early, must be >= 0");
108 if (s.Length > DATE_LEN)
109 throw new System.SystemException(
"time '" + time +
"' is too late, length of string " +
"representation must be <= " + DATE_LEN);
112 if (s.Length < DATE_LEN)
114 System.Text.StringBuilder sb =
new System.Text.StringBuilder(s);
115 while (sb.Length < DATE_LEN)
124 public static long StringToTime(System.String s)
129 public static System.DateTime StringToDate(System.String s)
131 long ticks = StringToTime(s) * TimeSpan.TicksPerMillisecond;
132 System.DateTime date =
new System.DateTime(1970, 1, 1);
133 date = date.AddTicks(ticks);
134 date = date.Add(TimeZone.CurrentTimeZone.GetUtcOffset(date));