The IntervalYM constructors

The default constructor is defined as follows:
public IntervalYM() throws SQLException
Use this second version of the constructor to display localized error messages if an exception is thrown:
public IntervalYM(Connection conn) throws SQLException
Use the following constructors to create year-month intervals from specific input values:
  • Two time stamps, returning the IntervalYM value that equals Timestamp1 - Timestamp2:
    public IntervalYM(Timestamp t1, Timestamp t2) throws
       SQLException
    public IntervalYM (Timestamp t1, Timestamp t2, Connection
       conn) throws SQLException

    The second version allows you to support localized error messages.

  • Year and month values (large month values are converted to year):
    public IntervalYM(int years, int months) throws
       SQLException
    
    public IntervalYM(int years, int months,
       Connection conn) throws SQLException

    The second version allows you to support localized error messages.

  • A month value and the encoded qualifier:
    public IntervalYM(int months, short qualifier, 
       Connection conn) throws SQLException

    To specify the qualifier, you can use the getQualifier() method described in Interval methods. This constructor supports localized error messages.

  • A string:
    public IntervalYM(String string) throws SQLException
    public IntervalYM(String string, Connection conn) throws
       SQLException

    The second version allows you to support localized error messages.

  • A string and qualifier:
    public IntervalYM(String string, short qualifier,
       Connection conn) throws SQLException

    To specify the qualifier, you can use the getQualifier() method described in Interval methods. This constructor supports localized error messages.

  • A string and qualifier information:
    public IntervalYM(String string, int length, 
       byte startCode, byte endCode) throws SQLException
    
    public IntervalYM(String string, int length, 
       byte startCode, byte endCode, Connection conn) throws
       SQLException

    The second version allows you to support localized error messages.