com.stimulsoft.base.system
Class StiDateTime

java.lang.Object
  extended by com.stimulsoft.base.system.StiDateTime
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<java.lang.Object>

public class StiDateTime
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable<java.lang.Object>


Field Summary
static java.lang.String DATE_FORMAT
           
static java.lang.String DATE_TIME_FORMAT
           
static java.lang.String EN_DATE_TIME_FORMAT
           
static StiDateTime MaxValue
           
static StiDateTime minValue
           
static StiDateTime MinValue
           
static java.lang.String TIME_FORMAT
           
static StiDateTime ZERO
           
 
Constructor Summary
StiDateTime()
           
StiDateTime(java.util.Calendar date)
           
StiDateTime(java.util.Date date)
           
StiDateTime(StiTimeSpan value)
           
 
Method Summary
 void add(int field, int amount)
           
 StiDateTime addDays(double value)
          Returns the DateTime resulting from adding a fractional number of days to this DateTime.
 StiDateTime addHours(double value)
          Returns the DateTime resulting from adding a fractional number of hours to this DateTime.
 StiDateTime addMilliseconds(double value)
          Returns the DateTime resulting from the given number of milliseconds to this DateTime.
 StiDateTime addMinutes(double value)
          Returns the DateTime resulting from adding a fractional number of minutes to this DateTime.
 StiDateTime addMonths(int months)
          Returns the DateTime resulting from adding the given number of months to this DateTime.
 StiDateTime addSeconds(double value)
          Returns the DateTime resulting from adding a fractional number of seconds to this DateTime.
 StiDateTime addTicks(long value)
          Returns the DateTime resulting from adding the given number of 100-nanosecond ticks to this DateTime.
 StiDateTime addYears(int value)
          Returns the DateTime resulting from adding the given number of years to this DateTime.
 java.util.Calendar calendar()
           
 StiDateTime clone()
           
 int compareTo(java.lang.Object o)
           
static StiDateTime currentDate()
           
static StiDateTime currentDateOnly()
           
 int day()
           
static int daysInMonth(long year, long month)
          Returns the number of days in the month given by the year and month arguments.
 boolean equals(java.lang.Object obj)
           
 java.lang.String format()
           
 java.lang.String format(java.text.DateFormat df)
           
 java.lang.String format(java.lang.String format)
           
 java.lang.String format(java.lang.String format, java.util.Locale locale)
           
 java.lang.String formatEN()
           
 java.lang.String formatEnDateTime()
           
static StiDateTime fromNetJsonString(java.lang.String jsonDate)
           
static StiDateTime fromString(java.lang.String strFrom)
           
 int get(int field)
           
 int getActualMaximum(int field)
           
 long getTicks()
           
 java.util.Date getTime()
           
 long getTimeInMillis()
           
 long getValue()
           
static boolean isLeapYear(long year)
          Checks whether a given year is a leap year.
 int month()
           
static StiDateTime Parse(java.lang.String from)
           
static java.util.Date parseISO8601(java.lang.String input)
           
 void set(int field, int value)
           
 void set(int year, int month, int date)
           
 void setTime(java.util.Calendar calendar)
           
 void setTime(java.util.Date date)
           
 void setTimeSpan(StiTimeSpan value)
           
 StiTimeSpan subtract(StiDateTime subtrahend)
           
 java.lang.String toNetJsonString()
           
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String format)
           
 java.lang.String toString(java.lang.String format, java.util.Locale locale)
           
static StiDateTime valueOf(java.lang.Object o)
           
 int year()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EN_DATE_TIME_FORMAT

public static final java.lang.String EN_DATE_TIME_FORMAT
See Also:
Constant Field Values

DATE_TIME_FORMAT

public static final java.lang.String DATE_TIME_FORMAT
See Also:
Constant Field Values

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
See Also:
Constant Field Values

TIME_FORMAT

public static final java.lang.String TIME_FORMAT
See Also:
Constant Field Values

ZERO

public static StiDateTime ZERO

minValue

public static StiDateTime minValue

MinValue

public static StiDateTime MinValue

MaxValue

public static StiDateTime MaxValue
Constructor Detail

StiDateTime

public StiDateTime()

StiDateTime

public StiDateTime(java.util.Calendar date)

StiDateTime

public StiDateTime(java.util.Date date)

StiDateTime

public StiDateTime(StiTimeSpan value)
Method Detail

currentDate

public static StiDateTime currentDate()

currentDateOnly

public static StiDateTime currentDateOnly()

toNetJsonString

public java.lang.String toNetJsonString()

fromNetJsonString

public static StiDateTime fromNetJsonString(java.lang.String jsonDate)

calendar

public java.util.Calendar calendar()

getValue

public long getValue()

getTicks

public long getTicks()

Parse

public static StiDateTime Parse(java.lang.String from)

fromString

public static StiDateTime fromString(java.lang.String strFrom)

parseISO8601

public static java.util.Date parseISO8601(java.lang.String input)
                                   throws java.text.ParseException
Throws:
java.text.ParseException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String format)

toString

public java.lang.String toString(java.lang.String format,
                                 java.util.Locale locale)

format

public java.lang.String format(java.lang.String format)

format

public java.lang.String format(java.lang.String format,
                               java.util.Locale locale)

format

public java.lang.String format(java.text.DateFormat df)

formatEN

public java.lang.String formatEN()

formatEnDateTime

public java.lang.String formatEnDateTime()

getTime

public java.util.Date getTime()

getTimeInMillis

public long getTimeInMillis()

set

public void set(int field,
                int value)

set

public void set(int year,
                int month,
                int date)

setTimeSpan

public void setTimeSpan(StiTimeSpan value)

setTime

public void setTime(java.util.Date date)

setTime

public void setTime(java.util.Calendar calendar)

add

public void add(int field,
                int amount)

addTicks

public StiDateTime addTicks(long value)
Returns the DateTime resulting from adding the given number of 100-nanosecond ticks to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addDays

public StiDateTime addDays(double value)
Returns the DateTime resulting from adding a fractional number of days to this DateTime. The result is computed by rounding the fractional number of days given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addHours

public StiDateTime addHours(double value)
Returns the DateTime resulting from adding a fractional number of hours to this DateTime. The result is computed by rounding the fractional number of hours given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addMilliseconds

public StiDateTime addMilliseconds(double value)
Returns the DateTime resulting from the given number of milliseconds to this DateTime. The result is computed by rounding the number of milliseconds given by value to the nearest integer, and adding that interval to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addMinutes

public StiDateTime addMinutes(double value)
Returns the DateTime resulting from adding a fractional number of minutes to this DateTime. The result is computed by rounding the fractional number of minutes given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addMonths

public StiDateTime addMonths(int months)
Returns the DateTime resulting from adding the given number of months to this DateTime. The result is computed by incrementing (or decrementing) the year and month parts of this DateTime by months months, and, if required, adjusting the day part of the resulting date downwards to the last day of the resulting month in the resulting year. The time-of-day part of the result is the same as the time-of-day part of this DateTime. In more precise terms, considering this DateTime to be of the form y / m / d + t, where y is the year, m is the month, d is the day, and t is the time-of-day, the result is y1 / m1 / d1 + t, where y1 and m1 are computed by adding months months to y and m, and d1 is the largest value less than or equal to d that denotes a valid day in month m1 of year y1.

Parameters:
months -
Returns:

addSeconds

public StiDateTime addSeconds(double value)
Returns the DateTime resulting from adding a fractional number of seconds to this DateTime. The result is computed by rounding the fractional number of seconds given by value to the nearest millisecond, and adding that interval to this DateTime. The value argument is permitted to be negative.

Parameters:
value -
Returns:

addYears

public StiDateTime addYears(int value)
Returns the DateTime resulting from adding the given number of years to this DateTime. The result is computed by incrementing (or decrementing) the year part of this DateTime by value years. If the month and day of this DateTime is 2/29, and if the resulting year is not a leap year, the month and day of the resulting DateTime becomes 2/28. Otherwise, the month, day, and time-of-day parts of the result are the same as those of this DateTime.

Parameters:
value -
Returns:

daysInMonth

public static int daysInMonth(long year,
                              long month)
Returns the number of days in the month given by the year and month arguments.

Parameters:
year -
month -
Returns:

isLeapYear

public static boolean isLeapYear(long year)
Checks whether a given year is a leap year. This method returns true if year is a leap year, or false if not.

Parameters:
year -
Returns:

get

public int get(int field)

getActualMaximum

public int getActualMaximum(int field)

clone

public StiDateTime clone()
Overrides:
clone in class java.lang.Object

format

public java.lang.String format()

subtract

public StiTimeSpan subtract(StiDateTime subtrahend)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>

valueOf

public static StiDateTime valueOf(java.lang.Object o)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

year

public int year()

month

public int month()

day

public int day()