/** * Sets the date. * * @param date a {@link DateTime} that contains only a date. See * {@link DateTime#setDateOnly}. */ public void setDate(DateTime date) { if (date != null && !date.isDateOnly()) { throw new IllegalStateException( "Object should be only a date, not a date and a time"); } this.date = date; }
/** * Sets the date. * * @param date a {@link DateTime} that contains only a date. See * {@link DateTime#setDateOnly}. */ public void setDate(DateTime date) { if (date != null && !date.isDateOnly()) { throw new IllegalStateException( "Object should be only a date, not a date and a time"); } this.date = date; }
@Override protected void validate() throws IllegalStateException { if (startTime == null) { throwExceptionForMissingAttribute(START_TIME); } if (endTime != null) { if (startTime.compareTo(endTime) > 0) { throw new IllegalStateException( "g:when/@startTime must be less than or equal to g:when/@endTime."); } if (startTime.isDateOnly() != endTime.isDateOnly()) { throw new IllegalStateException( (startTime.isDateOnly() ? "Date" : "Date/time") + " value expected."); } } }
@Override protected void validate() throws IllegalStateException { if (startTime == null) { throwExceptionForMissingAttribute(START_TIME); } if (endTime != null) { if (startTime.compareTo(endTime) > 0) { throw new IllegalStateException( "g:when/@startTime must be less than or equal to g:when/@endTime."); } if (startTime.isDateOnly() != endTime.isDateOnly()) { throw new IllegalStateException( (startTime.isDateOnly() ? "Date" : "Date/time") + " value expected."); } } }
@Override protected void validate() throws IllegalStateException { if (startTime == null) { throwExceptionForMissingAttribute(START_TIME); } if (endTime != null) { if (startTime.compareTo(endTime) > 0) { throw new IllegalStateException( "g:when/@startTime must be less than or equal to g:when/@endTime."); } if (startTime.isDateOnly() != endTime.isDateOnly()) { throw new IllegalStateException( (startTime.isDateOnly() ? "Date" : "Date/time") + " value expected."); } } }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#DATE}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param date attribute value * @return the attribute object that has been created and added to the item * @exception IllegalArgumentException if the attribute value is * not only a date, but a date and a time (see * {@link com.google.gdata.data.DateTime#isDateOnly()}) */ public GoogleBaseAttribute addDateAttribute(String name, DateTime date) { if (!date.isDateOnly()) { throw new IllegalArgumentException("DateTime should be only a date, " + "NOT a date and a time. Call addDateTimeAttribute() instead."); } return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.DATE, date.toString())); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#DATE}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param date attribute value * @return the attribute object that has been created and added to the item * @exception IllegalArgumentException if the attribute value is * not only a date, but a date and a time (see * {@link com.google.gdata.data.DateTime#isDateOnly()}) */ public GoogleBaseAttribute addDateAttribute(String name, DateTime date) { if (!date.isDateOnly()) { throw new IllegalArgumentException("DateTime should be only a date, " + "NOT a date and a time. Call addDateTimeAttribute() instead."); } return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.DATE, date.toString())); }