Top Description Fields Constructors Methods
org.jruby

public Class RubyTime

extends RubyObject
Class Inheritance
Annotations
@JRubyClass
name:Time
include:Comparable
Imports
jnr.posix.POSIX, .Timeval, org.jcodings.specific.USASCIIEncoding, org.joda.time.*, org.joda.time.format.DateTimeFormat, .DateTimeFormatter, org.joda.time.tz.FixedDateTimeZone, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.RaiseException, .TypeError, org.jruby.java.proxies.JavaProxy, org.jruby.runtime.Arity, .Block, .ClassIndex, .Helpers, .JavaSites.TimeSites, .ThreadContext, .Visibility, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.callsite.CachingCallSite, org.jruby.util.ByteList, .RubyDateFormatter, .RubyTimeParser, .Sprintf, org.jruby.util.time.TimeArgs, java.io.Serializable, java.math.BigDecimal, .BigInteger, .RoundingMode, java.time.*, .Instant, .LocalDateTime, java.util.Calendar, .Date, .GregorianCalendar, .Locale, java.util.regex.Matcher, .Pattern

The Time class.
Author
chadfowler, jpetersen

Field Summary

Modifier and TypeField and Description
private DateTime
private static final DateTimeFormatter
private boolean
private long
private static final BigDecimal
private static final DateTimeFormatter
private static final BigDecimal
private static final DateTime
private static final Pattern
public static final int
private static final DateTimeFormatter
private static final DateTimeFormatter
private static final DateTimeFormatter
private static final DateTimeFormatter
private static final Pattern
private static final ByteList
public static final String
private IRubyObject
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
public
RubyTime(Ruby runtime, RubyClass rubyClass)

public
RubyTime(Ruby runtime, RubyClass rubyClass, DateTime dt)

public
RubyTime(Ruby runtime, RubyClass rubyClass, DateTime dt, boolean tzRelative)

Method Summary

Modifier and TypeMethod and Description
private RubyTime
adjustTimeZone(ThreadContext context, final DateTimeZone zone, boolean isTzRelative)

private static RubyTime
public RubyString
public static IRubyObject
public static IRubyObject
at(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)

public static IRubyObject
public static IRubyObject
at(ThreadContext context, IRubyObject recv, IRubyObject[] args)

private static RubyTime
private static RubyTime
private static IRubyObject
public RubyTime
ceil(ThreadContext context, IRubyObject[] args)

private int
cmp(RubyTime other)

public static double
public static RubyClass
createTimeClass(ThreadContext context, RubyClass Object, RubyModule Comparable)

public RubyString
dump(final ThreadContext context)

public RubyString
dump(final ThreadContext context, final IRubyObject arg)

public RubyString
dump(IRubyObject[] args, Block unusedBlock)
Deprecated

public IRubyObject
private static long
private IRubyObject
public RubyTime
floor(ThreadContext context, IRubyObject[] args)

public RubyBoolean
public DateTime
public int

Returns:

day-of-month
getDay
()

public static String
getEnvTimeZone(Ruby runtime)
Deprecated since 10.0.

public static String
public RubyTime
public int

Returns:

hour-of-day (0..23)
getHour
()

private DateTime
public Class<?>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public Date

Returns:

a Java (legacy) Date instance
getJavaDate
()

public final RubyTime
public RubyTime
public RubyTime
public static DateTimeZone
getLocalTimeZone(Ruby runtime)
Deprecated since 10.0.

public static DateTimeZone
public int

Returns:

micro seconds (only)
getMicros
()

Return the micro-seconds of this time.

public int

Returns:

minute-of-hour
getMinute
()

public int

Returns:

month-of-year (1..12)
getMonth
()

public int

Returns:

nano seconds (only)
getNanos
()

Return the nano-seconds of this time.

public ClassIndex
getNativeClassIndex()

Overrides org.jruby.RubyObject.getNativeClassIndex.

Implements org.jruby.runtime.marshal.CoreObjectType.getNativeClassIndex.

This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

private int
public long

Returns:

the nano second part (only) of time
getNSec
()

Get the nano-second (only) part of the time.

public static String

Returns:

""
getRubyTimeZoneName
(Ruby runtime, DateTime dt)
Deprecated since 10.0. Use RubyTime#getRubyTimeZoneName(ThreadContext, DateTime) instead.

public static String
public static String
public int

Returns:

second-of-minute
getSecond
()

public long

Returns:

the total time in microseconds
getTimeInMicros
()

public long

Returns:

millis since epoch this (date-time) value represents
getTimeInMillis
()

public static DateTimeZone
getTimeZone(Ruby runtime, long seconds)
Deprecated since 10.0.

public static DateTimeZone
getTimeZone(ThreadContext context, long seconds)

private static DateTimeZone
getTimeZoneFromHHMM(ThreadContext context, String name, boolean positive, String hours, String minutes, String seconds)

public static DateTimeZone
getTimeZoneFromString(Ruby runtime, String zone)
Deprecated

public static DateTimeZone
getTimeZoneFromTZString(Ruby runtime, String zone)
Deprecated since 10.0.

public static DateTimeZone
public static DateTimeZone
private RubyString
public static DateTimeZone
getTimeZoneWithOffset(Ruby runtime, String zoneName, int offset)
Deprecated since 10.0.

public static DateTimeZone
getTimeZoneWithOffset(ThreadContext context, String zoneName, int offset)

public long

Returns:

the micro-second only part of this time
getUSec
()

Get the micro-second (only) part of the time.

public int

Returns:

year
getYear
()

public String
getZoneName()
Deprecated since 10.0.

public RubyBoolean
gmt(ThreadContext context)

public RubyBoolean
gmt()
Deprecated

public RubyInteger
public RubyInteger
gmt_offset()
Deprecated since 9.4-.

public RubyTime
gmtime()
Deprecated since 10.0.

public RubyTime
public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

Will return the hash code of this object.

public int
hashCode()

Overrides org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public RubyInteger
public RubyInteger
hour()
Deprecated since 10.0.

private static boolean
public IRubyObject
public IRubyObject
private IRubyObject
public IRubyObject
public IRubyObject
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
original
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object.

private IRubyObject
public IRubyObject
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

public static RaiseException

Returns:

""
invalidUTCOffset
(Ruby runtime)
Deprecated since 10.0. Use RubyTime#invalidUTCOffset(ThreadContext) instead

public static RaiseException
public static RaiseException

Returns:

""
invalidUTCOffset
(Ruby runtime, IRubyObject value)
Deprecated since 10.0. Use RubyTime#invalidUTCOffset(ThreadContext) instead

public static RaiseException
public RubyBoolean
public RubyBoolean
isdst()
Deprecated

public boolean
public static RubyTime
load(IRubyObject recv, IRubyObject from, Block block)
Deprecated

public static RubyTime
public static RubyTime
local(ThreadContext context, IRubyObject recv, IRubyObject[] args)

public final RubyTime
public RubyTime
public RubyTime
private static boolean
public RubyInteger
public RubyInteger
mday()
Deprecated since 10.0.

public RubyObject
mdump()
Deprecated

private RubyString
public long
microseconds()
Deprecated since 9.4-. use getMicros() instead

public RubyInteger
min(ThreadContext context)

public RubyInteger
min()
Deprecated since 10.0.

public RubyBoolean
public RubyInteger
public RubyInteger
month()
Deprecated since 10.0.

public static IRubyObject
public static RubyTime
public static RubyTime
newTime(Ruby runtime, long milliseconds)

public static RubyTime
newTime(Ruby runtime, DateTime dt)

public static RubyTime

Returns:

the new Time
newTime
(Ruby
the runtime
runtime
,
DateTime
the integer part of time + the fraction part in milliseconds
dt
,
long
the nanos only party of the time (millis excluded)
nsec
)

Create new (Ruby) Time instance.

public static RubyTime
newTimeFromNanoseconds(Ruby runtime, long nanoseconds)
Deprecated since 10.0.

public static RubyTime
newTimeFromNanoseconds(ThreadContext context, long nanoseconds)

public RubyInteger

Returns:

the (sec) fractional part of time (in nanos)
nsec
(ThreadContext context)

Get the fractional part of time in nanoseconds.

public RubyInteger
nsec()
Deprecated since 9.4-.

private static RubyNumeric
public IRubyObject
public IRubyObject
op_eqq(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyObject.op_eqq.

Implements org.jruby.runtime.builtin.IRubyObject.op_eqq.

rb_equal The Ruby "===" method is used by default in case/when statements.

public IRubyObject
op_equal(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects.

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
private RubyFloat
opMinus(ThreadContext context, RubyTime other)

private RubyTime
opMinus(ThreadContext context, double other)

private RubyTime
opPlusMillis(final Ruby runtime, double adjustMillis)

private static DateTimeZone
private static DateTimeZone
public RubyTime
round(ThreadContext context, IRubyObject[] args)

private static RubyTime
s_mload(ThreadContext context, final RubyTime time, IRubyObject from)

public static IRubyObject
private static int
safeCmp(ThreadContext context, RubyTime self, IRubyObject other)

public RubyBoolean
public RubyInteger
sec(ThreadContext context)

public RubyInteger
sec()
Deprecated since 10.0.

public void
private void
setIsTzRelative(boolean tzRelative)

public void
setMicros(int
the microseconds to be set
micros
)

Sets the microsecond part for this Time object.

public void
setMicroseconds(long micros)
Deprecated since 9.4-. use setMicros(int) instead

public void
setNanos(int
the nanoseconds to be set
nanos
)

Sets the nanosecond part for this Time object.

public void
setNSec(long
the nano second part only (4 to 9 decimal places) of time
nsec
)

Set the nano-second (only) part for this time.

public void
setUSec(long usec)

Set the micro-second (only) part of the time.

public void
private static JavaSites.TimeSites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

public RubyString
strftime(IRubyObject format)
Deprecated

public RubyString
public IRubyObject
subsec()
Deprecated

public RubyNumeric
subsec(final ThreadContext context)

public RubyBoolean
public RubyBoolean
private IRubyObject
public static RubyTime
private static DateTimeZone
timeZoneWithOffset(String zoneName, int offset)

public RubyArray<T extends IRubyObject>
public RubyFloat
to_f()

public RubyInteger
public RubyInteger
to_i()
Deprecated since 9.4-.

public long
public IRubyObject
public IRubyObject
public Instant

Returns:

an instant
toInstant
()

public <T> T
toJava(Class<T>
The target type to which the object should be converted.
target
)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

public LocalDateTime

Returns:

a date time
toLocalDateTime
()

public OffsetDateTime

Returns:

a date time
toOffsetDateTime
()

public String
toString()

Overrides org.jruby.RubyObject.toString.

The default toString method is just a wrapper that calls the Ruby "to_s" method.

public ZonedDateTime

Returns:

a date time
toZonedDateTime
()

public RubyBoolean
public void
updateCal(DateTime dt)
Deprecated

Use setDateTime(DateTime) instead.

public RubyInteger

Returns:

the (whole) microsecond part of time
usec
(ThreadContext context)

Get the microsecond part of this time value.

public RubyInteger
usec()
Deprecated

public static RubyTime
utc(ThreadContext context, IRubyObject recv, IRubyObject[] args)

public RubyInteger
public RubyInteger
wday()
Deprecated since 10.0.

public RubyBoolean
public RubyInteger
public RubyInteger
yday()
Deprecated since 10.0.

public RubyInteger
public RubyInteger
year()
Deprecated since 10.0.

public IRubyObject

Returns:

""
zone
()
Deprecated since 10.0. Use RubyTime#zone(ThreadContext) instead.

public IRubyObject
public static boolean
public static boolean
Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassinspectputsspecificEvaltoRubyString