Previous Up Next

Module JavaCalendar

module JavaCalendar: sig .. end
Utility functions for Java calendars.


Instance creation

type t = java'util'Calendar java_instance
The type of calendars.
val now : ?locale:JavaLocale.t -> ?zone:JavaTimeZone.t -> unit -> t
Returns a new java.util.Calendar instance for the current time, using the passed local and/or time zone.

Fields

type am_pm =
| AM (* The hour is between midnight (included) and noon (excluded). *)
| PM (* The hour is between noon (included) and midnight (excluded). *)
Whether the hour is before or after noon.
type month =
| January (* Constant for the month field. *)
| February (* Constant for the month field. *)
| March (* Constant for the month field. *)
| April (* Constant for the month field. *)
| May (* Constant for the month field. *)
| June (* Constant for the month field. *)
| July (* Constant for the month field. *)
| August (* Constant for the month field. *)
| September (* Constant for the month field. *)
| October (* Constant for the month field. *)
| November (* Constant for the month field. *)
| December (* Constant for the month field. *)
| Undecimber (* A special thirteen month (for non-gregorian calendars). *)
The different month values.
type day =
| Monday (* Constant for the day field. *)
| Tuesday (* Constant for the day field. *)
| Wednesday (* Constant for the day field. *)
| Thursday (* Constant for the day field. *)
| Friday (* Constant for the day field. *)
| Saturday (* Constant for the day field. *)
| Sunday (* Constant for the day field. *)
The different day values.
type '_ field =
| Era : java_int field (* BC/AD in gregorian calendar. *)
| Year : java_int field (* Year (including century). *)
| Month : month field (* Month. *)
| Week_of_month : java_int field (* Range: 0..6 (1 is the first full week). *)
| Week_of_year : java_int field (* Range: 1..53. *)
| Date : java_int field (* Synonym for Day_of_month. *)
| Day_of_month : java_int field (* Starts at 1. *)
| Day_of_week : day field (* Day. *)
| Day_of_week_in_month : java_int field (* Starts at 1. *)
| Day_of_year : java_int field (* Starts at 1. *)
| AM_PM : am_pm field (* Whether AM or PM. *)
| Hour : java_int field (* Range: 0..11. *)
| Hour_of_day : java_int field (* Range: 0..23. *)
| Minute : java_int field (* Range: 0..59. *)
| Second : java_int field (* Range: 0..59. *)
| Millisecond : java_int field (* Range: 0..999. *)
| Dst_offset : java_int field (* Raw offset of daylight saving in milliseconds. *)
| Zone_offset : java_int field (* Raw offset from GMT in milliseconds. *)
The different fields of a calendar.

Properties

val get_time : t -> java_long
get_time cal returns the time of the passed calendar, as the number of milliseconds since 1970年01月01日 00:00:00; see getTimeInMillis(...) .
val after : t -> t -> bool
after cal when returns true iff cal is strictly later than when; see after(...) .
val before : t -> t -> bool
before cal when returns true iff cal is strictly later than when; see before(...) .
val compare_to : t -> t -> int
Compares the passed calendars; see compareTo(...) .
val get : t -> 'a field -> 'a
get cal f returns the value for field f in calendar cal; see get(...) .
val get_time_zone : t -> JavaTimeZone.t
Returns the time zone for the passed calendar; see getTimeZone(...) .

Creation of new calendar values

val add : t -> 'a field -> java_int -> t
add cal f delta returns a new instance that is equal to cal, with the field f modified by adding delta; see add(...) .
val set : t -> 'a field -> 'a -> t
set cal f v returns a new instance that is equal to cal, with the field f changed to v; see set(...) .
val clear : t -> 'a field -> t
clear cal f returns a new instance that is equal to cal, with the field f cleared; see clear(...) .
val clear_all : t -> t
clear_all cal returns a new instance that is equal to cal, with the all fields cleared; see clear(...) .
val set_time_zone : t -> JavaTimeZone.t -> t
set_time_zone cal tz returns a new instance that is equal to cal, with the time zone set to tz; see setTimeZone(...) .

Conversions

val to_date : t -> JavaDate.t
Converts the passed calendar into a date.
val of_date : JavaDate.t -> t
Converts the passed date into a calendar.
val to_iso8601 : t -> JavaString.t
Converts the passed calendar into a string.
val of_iso8601 : JavaString.t -> t
Converts the passed string into a calendar.
Raises Java_exception if the passed string does not conform to the ISO8601 format

Null value

val null : t
The null value.
val is_null : t -> bool
is_null obj returns true iff obj is equal to null.
val is_not_null : t -> bool
is_not_null obj returns false iff obj is equal to null.

Miscellaneous

val wrap : t -> t option
wrap obj wraps the reference obj into an option type:
  • Some x if obj is not null;
  • None if obj is null.

val unwrap : t option -> t
unwrap obj unwraps the option obj into a bare reference:
  • Some x is mapped to x;
  • None is mapped to null.

AltStyle によって変換されたページ (->オリジナル) /