Provides support for converting dates to strings and vice-versa.
/// The strings are structured so that lexicographic sorting orders by date,
/// which makes them suitable for use as Field values and search terms.
///
///
/// Note that you do not have to use this class, you can just save your
/// dates as strings if lexicographic sorting orders them by date. This is
/// the case for example for dates like yyyy-mm-dd hh:mm:ss
/// (of course you can leave out the delimiter characters to save some space).
/// The advantage with using such a format is that you can easily save dates
/// with the required granularity, e.g. leaving out seconds. This saves memory
/// when searching with a RangeQuery or PrefixQuery, as Lucene
/// expands these queries to a BooleanQuery with potentially very many terms.
///
///
/// Note: dates before 1970 cannot be used, and therefore cannot be
/// indexed when using this class.
///
public class DateField
{
private DateField()
{
}
// make date strings long enough to last a millenium
private static int DATE_LEN = SupportClass.Number.ToString(
1000L * 365 * 24 * 60 * 60 * 1000, SupportClass.Number.MAX_RADIX).Length;
public static System.String MIN_DATE_STRING()
{
return TimeToString(0);
}
public static System.String MAX_DATE_STRING()
{
char[] buffer = new char[DATE_LEN];
char c = SupportClass.Character.ForDigit(36 - 1, SupportClass.Character.MAX_RADIX);
for (int i = 0; i < DATE_LEN; i++)
buffer[i] = c;
return new System.String(buffer);
}
///