Class Date

  • All Implemented Interfaces:
    ch.sahits.game.openpatrician.utilities.IInvalidatable

    @Component
    public class Date
    extends java.lang.Object
    implements ch.sahits.game.openpatrician.utilities.IInvalidatable
    Representation of the date within the game. This class is thread safe. The Date is implemented as a singleton. However there is no getInstance method to retrieve the once created instance, so it must be referenced elsewhere.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 16, 2011
    • Constructor Summary

      Constructors 
      Constructor Description
      Date()  
      Date​(int year)
      Initialize the date with start year.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.beans.binding.StringBinding dayDateBinding()
      Bind the representation of the day as a String.
      java.time.LocalDateTime getCurrentDate()
      Retrieve the immutable DateTime
      javafx.beans.property.ObjectProperty<java.time.LocalDateTime> getCurrentDateProperty()
      Retrieve the immutable DateTime
      void invalidate()  
      void resetStartYear​(int startYear)  
      void setStartYear​(int startYear)  
      void setTickUpdate​(int minutes)
      Set the tick update in number of minutes
      void updateTime​(java.time.LocalDateTime newTime)
      Change the time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_INVALID_START_YEAR

        public static final int DEFAULT_INVALID_START_YEAR
        See Also:
        Constant Field Values
    • Constructor Detail

      • Date

        public Date​(int year)
        Initialize the date with start year. The initial date is 13th July of the start year. The default tick update is 5 minutes.
      • Date

        public Date()
    • Method Detail

      • resetStartYear

        public void resetStartYear​(int startYear)
      • setStartYear

        public void setStartYear​(int startYear)
      • updateTime

        public void updateTime​(java.time.LocalDateTime newTime)
        Change the time.
        Parameters:
        newTime - new time
      • setTickUpdate

        public void setTickUpdate​(int minutes)
        Set the tick update in number of minutes
        Parameters:
        minutes - tick update
      • getCurrentDate

        public java.time.LocalDateTime getCurrentDate()
        Retrieve the immutable DateTime
        Returns:
        current date
      • getCurrentDateProperty

        public javafx.beans.property.ObjectProperty<java.time.LocalDateTime> getCurrentDateProperty()
        Retrieve the immutable DateTime
        Returns:
        observable of the current date,
      • invalidate

        public void invalidate()
        Specified by:
        invalidate in interface ch.sahits.game.openpatrician.utilities.IInvalidatable