Java::JCR::Calendar is a Perl module that contains utilities for converting dates.
SYNOPSIS
# With DateTime
use DateTime;
# Set
my $datetime = DateTime->now;
$node->set_property('date', $datetime);
# Get
my $datetime = $property->get_date; # DateTime object
# With Class::Date
use Class::Date qw( now );
# Set
my $class_date = now;
$node->set_property('date', $class_date);
# Get
my $class_date = $property->get_date('Class::Date'); # Class::Date
# With a custom date class
Java::JCR::Calendar->register_date_conversion(
'My::Date::Class', &my_date_class_inflate, &my_date_class_deflate);
# Set
my $my_date = My::Date::Class->right_now;
$property->set_date('date', $my_date);
# Get
my $my_date = $property->get_date('My::Date::Class');
# Or make it the default:
Java::JCR::Calendar->default_date_class('My::Date::Class');
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):
DateTime
Class::Date
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.
Product's homepage
Requirements:
· Perl