Class Clock

java.lang.Object
org.openpatch.scratch.Clock

public final class Clock extends Object
The date and time of the computer the program runs on, the same values Scratch's "current [year]" and "days since 2000" blocks report.

Example usage:


 this.setDirection(Clock.getSecond() * 6);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Returns the current day of the month, from 1 to 31.
    static int
    Returns the current day of the week, from 1 for Monday to 7 for Sunday.
    static int
    Returns the number of days that have passed since the first of January 2000.
    static int
    Returns the current hour, from 0 to 23.
    static int
    Returns the milliseconds of the current second, from 0 to 999.
    static int
    Returns the current minute, from 0 to 59.
    static int
    Returns the current month, from 1 for January to 12 for December.
    static int
    Returns the current second, from 0 to 59.
    static int
    Returns the current year, for example 2026.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getYear

      public static int getYear()
      Returns the current year, for example 2026.
      Returns:
      the year
      Scratch Block:
      (current [year v])
    • getMonth

      public static int getMonth()
      Returns the current month, from 1 for January to 12 for December.
      Returns:
      the month
      Scratch Block:
      (current [month v])
    • getDay

      public static int getDay()
      Returns the current day of the month, from 1 to 31.
      Returns:
      the day of the month
      Scratch Block:
      (current [date v])
    • getDayOfWeek

      public static int getDayOfWeek()
      Returns the current day of the week, from 1 for Monday to 7 for Sunday.
      Returns:
      the day of the week
      Scratch Block:
      (current [day of week v])
    • getHour

      public static int getHour()
      Returns the current hour, from 0 to 23.
      Returns:
      the hour
      Scratch Block:
      (current [hour v])
    • getMinute

      public static int getMinute()
      Returns the current minute, from 0 to 59.
      Returns:
      the minute
      Scratch Block:
      (current [minute v])
    • getSecond

      public static int getSecond()
      Returns the current second, from 0 to 59.
      Returns:
      the second
      Scratch Block:
      (current [second v])
    • getMillisecond

      public static int getMillisecond()
      Returns the milliseconds of the current second, from 0 to 999.
      Returns:
      the millisecond
    • getDaysSince2000

      public static int getDaysSince2000()
      Returns the number of days that have passed since the first of January 2000.
      Returns:
      the days since 2000
      Scratch Block:
      (days since 2000)