public DateTime parseDate(final YDate yDate) throws InvalidDateException { DateTime parsedDate; try { parsedDate = new DateTime(yDate.getYear(), yDate.getMonth() > 0 ? yDate.getMonth() : 1, yDate.getDay() > 0 ? yDate.getDay() : 1, 0, 0, DateTimeZone.UTC); } catch (IllegalFieldValueException e) { throw new InvalidDateException("Incorrect values in YDates.", e); } if (yDate.getDay() == 0) { parsedDate = parsedDate.dayOfMonth().withMinimumValue(); } if (yDate.getMonth() == 0) { parsedDate = parsedDate.dayOfYear().withMinimumValue(); } return parsedDate; }