Most likely you will have to encode this from scratch. There may be a Java library that you can convert, but it seems that this type of functionality is now the subject of academic research, and not what happens in different places. In the end, you can use something academic, but you may have to program your own based on your needs.
To provide maximum flexibility, I would save each part of the date in separate fields with a null value with a value indicating the uncertainty of the first null field.
class UncertainDate { public byte? Millennium { get; set; } public byte? Century { get; set; } public byte? Decade { get; set; } public byte? Year { get; set; } public byte? Month { get; set; } public byte? Day { get; set; }
As an example, the “first quarter of 2000” will be presented as:
var d = new UncertainDate() { Millennium = 2, Century = 0, Decade = 0, Year = 0, Uncertainty = 0.25m };
This gives you a long route to move to line input and output string output, but simplifies the comparison (compare each field in order, the first or lowest uncertainty is lost).
You can also use an enumeration for uncertainty, maybe values ​​like FirstQuarter, FirstHalf, Early, Late, ThirdQuarter , etc. A decimal makes relative comparisons easy, but is it harder to get back to things like the “second half” (ie, will 0.75 be “second half” or “third quarter”?)
For reference, similar questions were asked.
drharris
source share