Java::JCR::Calendar is a Perl module that contains utilities for converting dates.
# With DateTime
my $datetime = DateTime->now;
my $datetime = $property->get_date; # DateTime object
# With Class::Date
use Class::Date qw( now );
my $class_date = now;
my $class_date = $property->get_date('Class::Date'); # Class::Date
# With a custom date class
'My::Date::Class', &my_date_class_inflate, &my_date_class_deflate);
my $my_date = My::Date::Class->right_now;
my $my_date = $property->get_date('My::Date::Class');
# Or make it the default:
my $my_date = $property->get_date;
This class helps make the translation from java.lang.Calendar to a Perl date/time object as seamless as possible. Since Perl has a plethora of date/time classes and everyone seems to have their own favorite based upon functionality and performance characteristics, I've tried to make this configurable enough that if your favorite isn't supported, you may add it very easily.
Currently, this class ships with support for the following (if installed):
For each of the classes above, a date conversion will be registered if the class can be loaded (i.e., it's installed). The first date conversion registered will be made the default date class.
I've chosen these classes based upon my experience and knowledge of their development and developers. DateTime is the obvious first choice since it's the most actively developed and best supported module. If you would like to see an additional module supported in the Java::JCR distribution, please send patches to my email address (listed in "AUTHOR") and I will consider it for a future release.
If none of the above date classes is available and you haven't registered a date conversion for another class, you can't use JCR dates directly. The JCR will convert any date to or from an ISO 8601 string if you use the string accessor/mutators rather than the date accessor/mutators. Any fallback solution I could come up with would be redundant.