Tabnine Logo
Date
Code IndexAdd Tabnine to your IDE (free)

How to use
Date
in
org.stjs.javascript

Best Java code snippets using org.stjs.javascript.Date (Showing top 20 results out of 315)

origin: org.st-js/shared

/**
 * Computes the date from the given arguments interpreting them as UTC and 
 * returns the corresponding time value.
 * 
 * <p>The <tt>UTC</tt> function differs from the <tt>Date</tt> constructor 
 * in two ways: it returns a time value as a <tt>Number</tt>, rather than 
 * creating a <tt>Date</tt> object, and it interprets the arguments in UTC
 * rather than as local time.
 * 
 * @param year the year (in UTC time zone)
 * @param month the month of the year (in UTC time zone)
 * @param day the day of the month (in UTC time zone)
 * @param hours the hour of the day (in UTC time zone)
 * @param minutes the minute of the hour (in UTC time zone)
 * @param seconds the second of the minute (in UTC time zone)
 * @param ms the milliseconds of the second (in UTC time zone)
 * @return the UTC time value corresponding to the given arguments
 */
public static double UTC(int year, int month, int day, int hours, int minutes, int seconds, int ms) {
  return new Date(year, month, day, hours, minutes, seconds, ms).getTime();
}
 
origin: org.st-js/shared

/**
 * Computes the date from the given arguments interpreting them as UTC with
 * the <tt>hours</tt>, <tt>minutes</tt>, <tt>seconds</tt> and 
 * <tt>milliseconds</tt> fields set to 0 and returns the corresponding time 
 * value.
 * 
 * <p>The <tt>UTC</tt> function differs from the <tt>Date</tt> constructor 
 * in two ways: it returns a time value as a <tt>Number</tt>, rather than 
 * creating a <tt>Date</tt> object, and it interprets the arguments in UTC
 * rather than as local time.
 * 
 * @param year the year (in UTC time zone)
 * @param month the month of the year (in UTC time zone)
 * @param day the day of the month (in UTC time zone)
 * @return the UTC time value corresponding to the given arguments
 */
public static double UTC(int year, int month, int day) {
  return UTC(year, month, day, 0);
}
origin: org.st-js/shared

/**
 * Returns the minutes of the hour corresponding to this <tt>Date</tt>'s time 
 * value, in the local time zone. 
 * 
 * @return the minutes of the hour corresponding to this <tt>Date</tt>'s time value, in the local time zone.
 */
public double getMinutes() {
  return getField(getCalendar(false), Calendar.MINUTE);
}
origin: org.st-js/shared

/**
 * Sets the month of year field of this <tt>Date</tt> interpreted in the 
 * local time zone. Month numbers are 0 indexed, with January being 0 
 * and December being 11.
 * 
 * @param month the new month
 */
public void setMonth(int month) {
  setMonth(month, (int)getDay());
}
 
origin: org.st-js/shared

/**
 * Sets the month of year and day of month fields of this <tt>Date</tt> 
 * interpreted in the local time zone. Month numbers are 0 indexed, with 
 * January being 0 and December being 11.
 * 
 * @param month the new month
 * @param day the new day of month
 */
public void setMonth(int month, int day) {
  setField(getCalendar(true), Calendar.MONTH, month);
  setDate(day);
}
origin: org.st-js/shared

public static String Date() {
  return new Date().toString();
}
origin: org.st-js/server

@Override
public Date deserialize(JsonElement elem, Type typeOfT, JsonDeserializationContext context)
    throws JsonParseException {
  if (elem == null) {
    return null;
  }
  return new Date(elem.getAsString());
}
origin: org.st-js/shared

  /**
   * Returns the time value associated to this <tt>Date</tt>
   * 
   * @return the time value associated to this <tt>Date</tt>
   */
  public double valueOf() {
    return getTime();
  }
}
origin: org.st-js/shared

/**
 * Sets the minutes, seconds and milliseconds field of this <tt>Date</tt> 
 * interpreted in the local time zone.
 * 
 * @param min the new minutes
 * @param sec the new seconds
 * @param ms the new milliseconds
 */
public void setMinutes(int min, int sec, int ms) {
  setField(getCalendar(true), Calendar.MINUTE, min);
  setSeconds(sec, ms);
}
origin: org.st-js/shared

/**
 * Sets the seconds and milliseconds fields of this <tt>Date</tt> 
 * interpreted in the local time zone.
 * 
 * @param sec the new seconds
 * @param ms the new milliseconds
 */
public void setSeconds(int sec, int ms) {
  setField(getCalendar(true), Calendar.SECOND, sec);
  setMilliseconds(ms);
}
 
origin: org.st-js/shared

/**
 * Sets the year, month and day of month fields of this <tt>Date</tt> 
 * interpreted in the local time zone.
 * 
 * @param year the new year
 * @param month the new month
 * @param day the new day of month
 */
public void setFullYear(int year, int month, int day) {
  setField(getCalendar(true), Calendar.YEAR, year);
  setMonth(month, day);
}
origin: org.st-js/shared

/**
 * Sets the hours, minutes, seconds and milliseconds field of this 
 * <tt>Date</tt> interpreted in the local time zone.
 * 
 * @param hour the new hour
 * @param min the new minutes
 * @param sec the new seconds
 * @param ms the new milliseconds
 */
public void setHours(int hour, int min, int sec, int ms) {
  setField(getCalendar(true), Calendar.HOUR_OF_DAY, hour);
  setMinutes(min, sec, ms);
}
origin: org.st-js/shared

/**
 * Sets the time value of this <tt>Date</tt> directly
 *  
 * @param time the new time value for this <tt>Date</tt>
 */
public void setTime(long time) {
  getCalendar(true).setTimeInMillis(time);
}
origin: org.st-js/shared

/**
 * Sets the day of month field of this <tt>Date</tt> interpreted in the 
 * local time zone.
 * 
 * @param day the new day of month
 */
public void setDate(int day) {
  setField(getCalendar(true), Calendar.DAY_OF_WEEK, day);
}
origin: org.st-js/shared

/**
 * Sets the year and month fields of this <tt>Date</tt> 
 * interpreted in the local time zone.
 * 
 * @param year the new year
 * @param month the new month
 */
public void setFullYear(int year, int month) {
  setFullYear(year, month, (int)getDate());
}
origin: org.st-js/server

@Override
public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
  return new Date(jp.getText());
}
origin: org.st-js/server

public static String toNormalizedString(Date d) {
  // TODO - improve perf here
  return new SimpleDateFormat(DEFAULT_DATE_PATTERN).format(new java.util.Date((long) d.getTime()));
}
origin: org.st-js/shared

/**
 * Returns the time value associated to this <tt>Date</tt>
 * 
 * @return the time value associated to this <tt>Date</tt>
 */
public double getTime() {
  if (getCalendar(false) != null) {
    return calendar.getTimeInMillis();
  }
  return Double.NaN;
}
origin: org.st-js/shared

/**
 * Sets the milliseconds field of this <tt>Date</tt> interpreted in the local time zone.
 * 
 * @param ms the new milliseconds
 */
public void setMilliseconds(int ms) {
  setField(getCalendar(true), Calendar.MILLISECOND, ms);
}
origin: com.eduworks/org.cassproject.schema.general

/**
 * Updates the ID timestamp of the object, for versioning purposes.
 *
 * @method updateTimestamp
 */
public void updateTimestamp() {
  String rawId = id.substring(0, id.lastIndexOf("/"));
  if (rawId.endsWith("/") == false)
    rawId += "/";
  rawId += new Date().getTime();
  id = rawId;
}
org.stjs.javascriptDate

Javadoc

this date is implemented using a java Calendar. the aim of this class is to offer a similar behavior to the Javascript date.

Time Values and Time Range

A Date object contains a Number indicating a particular instant in time to within a millisecond. Such a Number is called a time value. A time value may also be NaN, indicating that the Date object does not represent a specific instant of time.

Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day. ECMAScript Number values can represent all integers from –9,007,199,254,740,992 to 9,007,199,254,740,992; this range suffices to measure times to millisecond precision for any instant that is within approximately 285,616 years, either forward or backward, from 01 January, 1970 UTC.

The actual range of times supported by ECMAScript Date objects is slightly smaller: exactly –100,000,000 days to 100,000,000 days measured relative to midnight at the beginning of 01 January, 1970 UTC. This gives a range of 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC.

The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the value +0.

Date Time String Format

ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 Extended Format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ

Where the fields are as follows:

  • YYYY is the decimal digits of the year 0000 to 9999 in the Gregorian calendar.
  • - “-” (hyphen) appears literally twice in the string.
  • MM is the month of the year from 01 (January) to 12 (December).
  • DD is the day of the month from 01 to 31.
  • T “T” appears literally in the string, to indicate the beginning of the time element.
  • HH is the number of complete hours that have passed since midnight as two decimal digits from 00 to 24.
  • : “:” (colon) appears literally twice in the string.
  • mm is the number of complete minutes since the start of the hour as two decimal digits from 00 to 59.
  • ss is the number of complete seconds since the start of the minute as two decimal digits from 00 to 59.
  • . “.” (dot) appears literally in the string.
  • sss is the number of complete milliseconds since the start of the second as three decimal digits.
  • Z is the time zone offset specified as “Z” (for UTC) or either “+” or “-” followed by a time expression HH:mm

This format includes date-only forms:

  • YYYY
  • YYYY-MM
  • YYYY-MM-DD

It also includes “date-time” forms that consist of one of the above date-only forms immediately followed by one of the following time forms with an optional time zone offset appended:

  • THH:mm
  • THH:mm:ss
  • THH:mm:ss.sss

All numbers must be base 10. If the MM or DD fields are absent “01” is used as the value. If the HH, mm, or ss fields are absent “00” is used as the value and the value of an absent sss field is “000”. The value of an absent time zone offset is “Z”.

Illegal values (out-of-bounds as well as syntax errors) in a format string means that the format string is not a valid instance of this format.

NOTE 1: As every day both starts and ends with midnight, the two notations 00:00 and 24:00 are available to distinguish the two midnights that can be associated with one date. This means that the following two notations refer to exactly the same point in time: 1995-02-04T24:00 and 1995-02-05T00:00

NOTE 2: There exists no international standard that specifies abbreviations for civil time zones like CET, EST, etc. and sometimes the same abbreviation is even used for two very different time zones. For this reason, ISO 8601 and this format specifies numeric representations of date and time. The documentation of this class is mostly adapted from the ECMAScript 5.1 Specification: http://www.ecma-international.org/ecma-262/5.1/ Browser compatibility information comes from: http://kangax.github.io/es5-compat-table

Most used methods

  • <init>
    Constructs a new Date object by parsing its string representation, and setting it's value to the res
  • getTime
    Returns the time value associated to this Date
  • UTC
    Computes the date from the given arguments interpreting them as UTC and returns the corresponding ti
  • getCalendar
  • getDate
    Returns the day of the month corresponding to this Date's time value, in the local time zone.
  • getDay
    Returns the day of the week corresponding to this Date's time value, in the local time zone. A weekd
  • getField
  • getFullYear
    Returns the year corresponding to this Date's time value, in the local time zone.
  • getMilliseconds
    Returns the milliseconds of the second corresponding to this Date's time value, in the local time zo
  • getMinutes
    Returns the minutes of the hour corresponding to this Date's time value, in the local time zone.
  • getMonth
    Returns the month number corresponding to this Date's time value, in the local time zone. Month numb
  • getSeconds
    Returns the seconds of the minute corresponding to this Date's time value, in the local time zone.
  • getMonth,
  • getSeconds,
  • getUTC,
  • getUTCDate,
  • getUTCDay,
  • getUTCMilliseconds,
  • getUTCMinutes,
  • getUTCMonth,
  • getUTCSeconds,
  • setDate

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now