Class Moment

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>, Codec, Compactable
    Direct Known Subclasses:
    Moment.MomentOf

    public class Moment
    extends java.util.Date
    implements Compactable
    A wrapper around seconds/timestamps. Internally the representation only has second precicion (aligning with Rust), so any numbers passed an/out are always per-second. For any encoding/decoding the 1000 multiplier would be applied to get it in line with JavaScript formats. It extends the base JS `Date` object and has all the methods available that are applicable to any `Date`
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Moment.MomentOf
      The Substrate MomentOf representation as a Moment.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BITLENGTH  
      protected java.util.Date raw  
    • Constructor Summary

      Constructors 
      Constructor Description
      Moment​(java.lang.Object value)  
    • Method Summary

      Modifier and Type Method Description
      int bitLength()
      Returns the number of bits in the value
      boolean eq​(java.lang.Object other)
      Compares the value of the input to see if there is a match
      int getEncodedLength()
      The length of the value when encoded as a Uint8Array
      boolean isEmpty()
      Checks if the value is an empty value
      java.math.BigInteger toBn()
      Returns the BN representation of the timestamp
      java.lang.String toHex()
      Returns a hex string representation of the value
      java.lang.Object toJson()
      Converts the Object to JSON, typically used for RPC transfers
      long toNumber()
      Returns the number representation for the timestamp
      java.lang.String toString()
      Returns the string representation of the value
      byte[] toU8a​(boolean isBare)  
      • Methods inherited from class java.util.Date

        after, before, clone, compareTo, equals, from, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, UTC
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.polkadot.types.Codec

        toU8a
    • Field Detail

      • raw

        protected java.util.Date raw
      • BITLENGTH

        public static int BITLENGTH
    • Constructor Detail

      • Moment

        public Moment​(java.lang.Object value)
    • Method Detail

      • getEncodedLength

        public int getEncodedLength()
        The length of the value when encoded as a Uint8Array
        Specified by:
        getEncodedLength in interface Codec
      • isEmpty

        public boolean isEmpty()
        Checks if the value is an empty value
        Specified by:
        isEmpty in interface Codec
      • eq

        public boolean eq​(java.lang.Object other)
        Compares the value of the input to see if there is a match
        Specified by:
        eq in interface Codec
      • bitLength

        public int bitLength()
        Returns the number of bits in the value
        Specified by:
        bitLength in interface Compactable
      • toBn

        public java.math.BigInteger toBn()
        Returns the BN representation of the timestamp
        Specified by:
        toBn in interface Compactable
      • toHex

        public java.lang.String toHex()
        Returns a hex string representation of the value
        Specified by:
        toHex in interface Codec
      • toJson

        public java.lang.Object toJson()
        Converts the Object to JSON, typically used for RPC transfers
        Specified by:
        toJson in interface Codec
      • toNumber

        public long toNumber()
        Returns the number representation for the timestamp
        Specified by:
        toNumber in interface Compactable
      • toString

        public java.lang.String toString()
        Returns the string representation of the value
        Overrides:
        toString in class java.util.Date
      • toU8a

        public byte[] toU8a​(boolean isBare)
        Specified by:
        toU8a in interface Codec
        Parameters:
        isBare - true when the value has none of the type-specific prefixes (internal) Encodes the value as a Uint8Array as per the parity-codec specifications