List of usage examples for java.util GregorianCalendar set
public void set(int field, int value)
From source file:org.obm.icalendar.Ical4jHelper.java
private void appendRecurence(Event event, CalendarComponent component) { EventRecurrence er = new EventRecurrence(); RRule rrule = (RRule) component.getProperty(Property.RRULE); EnumSet<RecurrenceDay> recurrenceDays = EnumSet.noneOf(RecurrenceDay.class); if (rrule != null) { Recur recur = rrule.getRecur();/*from w w w . java 2s. c om*/ String frequency = recur.getFrequency(); if (Recur.WEEKLY.equals(frequency) || Recur.DAILY.equals(frequency)) { for (Object ob : recur.getDayList()) { recurrenceDays.add(weekDayToRecurrenceDay((WeekDay) ob)); } if (Recur.WEEKLY.equals(frequency) && recurrenceDays.isEmpty()) { GregorianCalendar cal = getEventStartCalendar(event); WeekDay eventStartWeekDay = WeekDay.getDay(cal.get(GregorianCalendar.DAY_OF_WEEK)); recurrenceDays.add(WEEK_DAY_TO_RECURRENCE_DAY.get(eventStartWeekDay)); } } er.setDays(new RecurrenceDays(recurrenceDays)); er.setEnd(recur.getUntil()); er.setFrequence(Math.max(recur.getInterval(), 1)); // getInterval() returns -1 if no interval is defined if (er.getDays().isEmpty()) { if (Recur.DAILY.equals(frequency)) { er.setKind(RecurrenceKind.daily); } else if (Recur.WEEKLY.equals(frequency)) { er.setKind(RecurrenceKind.weekly); } else if (Recur.MONTHLY.equals(frequency)) { WeekDayList wdl = recur.getDayList(); if (wdl.size() > 0) { WeekDay day = (WeekDay) wdl.get(0); GregorianCalendar cal = getEventStartCalendar(event); er.setKind(RecurrenceKind.monthlybyday); cal.set(GregorianCalendar.DAY_OF_WEEK, WeekDay.getCalendarDay(day)); cal.set(GregorianCalendar.DAY_OF_WEEK_IN_MONTH, day.getOffset()); event.setStartDate(cal.getTime()); } else { er.setKind(RecurrenceKind.monthlybydate); } } else if (Recur.YEARLY.equals(frequency)) { er.setKind(RecurrenceKind.yearly); } } else { er.setKind(RecurrenceKind.weekly); } } event.setRecurrence(er); appendNegativeExceptions(event, component.getProperties(Property.EXDATE)); }
From source file:org.openmrs.api.PatientServiceTest.java
/** * @see PatientService#mergePatients(Patient,Patient) * @verifies audit prior date of birth// w w w. ja va2s. c om */ @Test public void mergePatients_shouldAuditPriorDateOfBirth() throws Exception { //retrieve preferred patient and set a date of birth GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); //milliseconds are not serialized into the database. they will be ignored in the test cDate.set(Calendar.MILLISECOND, 0); Patient preferred = patientService.getPatient(999); preferred.setBirthdate(cDate.getTime()); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior date of birth was not audited", cDate.getTime(), audit.getPersonMergeLogData().getPriorDateOfBirth()); }
From source file:org.openmrs.api.PatientServiceTest.java
/** * @see PatientService#mergePatients(Patient,Patient) * @verifies audit prior date of death/* w w w . j a va 2 s . com*/ */ @Test public void mergePatients_shouldAuditPriorDateOfDeath() throws Exception { //retrieve preferred patient and set a date of birth GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); //milliseconds are not serialized into the database. they will be ignored in the test cDate.set(Calendar.MILLISECOND, 0); Patient preferred = patientService.getPatient(999); preferred.setDeathDate(cDate.getTime()); preferred.setDead(true); preferred.setCauseOfDeath(Context.getConceptService().getConcept(3)); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior date of death was not audited", cDate.getTime(), audit.getPersonMergeLogData().getPriorDateOfDeath()); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
private void buttonExportToCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExportToCSVActionPerformed final JFileChooser fc = new JFileChooser(); fc.setDialogTitle(getLocaleMessage("save.statictic")); fc.setFileFilter(new FileFilter() { @Override/* w w w. j av a2 s .com*/ public boolean accept(File f) { return !f.isFile() || f.getAbsolutePath().toLowerCase().endsWith(".csv"); } @Override public String getDescription() { return getLocaleMessage("files.type.csv"); } }); //fc.setCurrentDirectory(new File("config")); //fc.setSelectedFile(new File(configuration.getSystemName())); fc.setDialogType(JFileChooser.SAVE_DIALOG); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { final File file; //This is where a real application would open the file. if (!fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".csv")) { file = new File(fc.getSelectedFile().getAbsoluteFile() + ".csv"); } else { file = fc.getSelectedFile(); } Spring.getInstance().getHt().getSessionFactory().openSession().doWork((Connection connection) -> { final GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dateChooserStartCsv.getDate()); gc.set(GregorianCalendar.HOUR_OF_DAY, 0); gc.set(GregorianCalendar.MINUTE, 0); gc.set(GregorianCalendar.SECOND, 0); gc.set(GregorianCalendar.MILLISECOND, 0); final String std = Uses.format_for_rep.format(gc.getTime()); gc.setTime(dateChooserFinishCsv.getDate()); gc.set(GregorianCalendar.HOUR_OF_DAY, 0); gc.set(GregorianCalendar.MINUTE, 0); gc.set(GregorianCalendar.SECOND, 0); gc.set(GregorianCalendar.MILLISECOND, 0); gc.add(GregorianCalendar.HOUR, 24); final String find = Uses.format_for_rep.format(gc.getTime()); final String sql = " SELECT " + " s.client_id as id, " + " concat(c.service_prefix , c.number) as num, " + " c.input_data as inp, " + " DATE_FORMAT(s.client_stand_time, '%d.%m.%y %H:%i') as stnd, " + " sv.name as srv, " + " DATE_FORMAT(s.user_start_time, '%d.%m.%y %H:%i') as strt, " + " DATE_FORMAT(s.user_finish_time, '%d.%m.%y %H:%i') as fin, " + " u.name as usr, " + " s.client_wait_period as wt, " + " s.user_work_period as wrk, " + " IFNULL(r.name, '') as res " + " FROM statistic s left join results r on s.results_id=r.id, clients c, users u, services sv " + " WHERE s.client_id=c.id and s.user_id=u.id and s.service_id=sv.id " + " and s.client_stand_time>='" + std + "' and s.client_stand_time<='" + find + "'"; try (ResultSet set = connection.createStatement().executeQuery(sql)) { final Writer writer; try { writer = new OutputStreamWriter(new FileOutputStream(file), "cp1251").append(""); writer.append(""); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.number")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.data")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.stand_time")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.service_name")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.start_time")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.finish_time")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.user")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.wait")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.work")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(getLocaleMessage("csv.result")); writer.append('\n'); while (set.next()) { writer.append(set.getString("id")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("num")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("inp")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("stnd")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append( set.getString("srv").replace(cbSeparateCSV.getSelectedItem().toString(), " ")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("strt")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("fin")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("usr")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("wt")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("wrk")); writer.append(cbSeparateCSV.getSelectedItem().toString()); writer.append(set.getString("res")); writer.append('\n'); } //generate whatever data you want writer.flush(); writer.close(); } catch (IOException ex) { throw new ClientException(ex); } } JOptionPane.showMessageDialog(fc, getLocaleMessage("stat.saved"), getLocaleMessage("stat.saving"), JOptionPane.INFORMATION_MESSAGE); }); } }
From source file:com.flexive.core.storage.genericSQL.GenericHierarchicalStorage.java
/** * Set a properties data for inserts or updates * * @param insert perform insert or update? * @param prop current property * @param allData all data of the instance (might be needed to buld references, etc.) * @param con an open and valid connection * @param data current property data * @param ps prepared statement for the data table * @param ft fulltext indexer * @param upperColumnPos position of the uppercase column (if present, else <code>-1</code>) * @param includeFullText add fulltext entries? Will be skipped for position only changes * @throws SQLException on errors * @throws FxUpdateException on errors * @throws FxDbException on errors * @throws FxNoAccessException for FxNoAccess values *//* ww w . j a v a2 s.co m*/ private void setPropertyData(boolean insert, FxProperty prop, List<FxData> allData, Connection con, FxPropertyData data, PreparedStatement ps, FulltextIndexer ft, int upperColumnPos, boolean includeFullText) throws SQLException, FxUpdateException, FxDbException, FxNoAccessException { FxValue value = data.getValue(); if (value instanceof FxNoAccess) throw new FxNoAccessException("ex.content.value.noaccess"); if (value.isMultiLanguage() != ((FxPropertyAssignment) data.getAssignment()).isMultiLang()) { if (((FxPropertyAssignment) data.getAssignment()).isMultiLang()) throw new FxUpdateException("ex.content.value.invalid.multilanguage.ass.multi", data.getXPathFull()); else throw new FxUpdateException("ex.content.value.invalid.multilanguage.ass.single", data.getXPathFull()); } int pos_lang = insert ? INSERT_LANG_POS : UPDATE_ID_POS + 2; int pos_isdef_lang = insert ? INSERT_ISDEF_LANG_POS : UPDATE_MLDEF_POS; final FxEnvironment env = CacheAdmin.getEnvironment(); if (prop.getDataType().isSingleRowStorage()) { //Data types that just use one db row can be handled in a very similar way Object translatedValue; GregorianCalendar gc = null; final long[] translatedLanguages = value.getTranslatedLanguages(); for (long translatedLanguage : translatedLanguages) { translatedValue = value.getTranslation(translatedLanguage); if (translatedValue == null) { LOG.warn("Translation for " + data.getXPath() + " is null!"); } ps.setLong(pos_lang, translatedLanguage); if (!value.isMultiLanguage()) ps.setBoolean(pos_isdef_lang, true); else ps.setBoolean(pos_isdef_lang, value.isDefaultLanguage(translatedLanguage)); if (upperColumnPos != -1) { final Locale locale = value.isMultiLanguage() ? env.getLanguage(translatedLanguage).getLocale() : Locale.getDefault(); ps.setString(upperColumnPos, translatedValue.toString().toUpperCase(locale)); } int[] pos = insert ? getColumnPosInsert(prop) : getColumnPosUpdate(prop); switch (prop.getDataType()) { case Double: checkDataType(FxDouble.class, value, data.getXPathFull()); ps.setDouble(pos[0], (Double) translatedValue); break; case Float: checkDataType(FxFloat.class, value, data.getXPathFull()); ps.setFloat(pos[0], (Float) translatedValue); break; case LargeNumber: checkDataType(FxLargeNumber.class, value, data.getXPathFull()); ps.setLong(pos[0], (Long) translatedValue); break; case Number: checkDataType(FxNumber.class, value, data.getXPathFull()); ps.setInt(pos[0], (Integer) translatedValue); break; case HTML: checkDataType(FxHTML.class, value, data.getXPathFull()); boolean useTidy = ((FxHTML) value).isTidyHTML(); ps.setBoolean(pos[1], useTidy); final String extractorInput = doTidy(data.getXPathFull(), (String) translatedValue); if (useTidy) { translatedValue = extractorInput; } final HtmlExtractor result = new HtmlExtractor(extractorInput, true); setBigString(ps, pos[2], result.getText()); setBigString(ps, pos[0], (String) translatedValue); break; case String1024: case Text: checkDataType(FxString.class, value, data.getXPathFull()); setBigString(ps, pos[0], (String) translatedValue); break; case Boolean: checkDataType(FxBoolean.class, value, data.getXPathFull()); ps.setBoolean(pos[0], (Boolean) translatedValue); break; case Date: checkDataType(FxDate.class, value, data.getXPathFull()); if (gc == null) gc = new GregorianCalendar(); gc.setTime((Date) translatedValue); //strip all time information, this might not be necessary since ps.setDate() strips them //for most databases but won't hurt either ;) gc.set(GregorianCalendar.HOUR, 0); gc.set(GregorianCalendar.MINUTE, 0); gc.set(GregorianCalendar.SECOND, 0); gc.set(GregorianCalendar.MILLISECOND, 0); ps.setDate(pos[0], new java.sql.Date(gc.getTimeInMillis())); break; case DateTime: checkDataType(FxDateTime.class, value, data.getXPathFull()); if (gc == null) gc = new GregorianCalendar(); gc.setTime((Date) translatedValue); ps.setTimestamp(pos[0], new Timestamp(gc.getTimeInMillis())); break; case DateRange: checkDataType(FxDateRange.class, value, data.getXPathFull()); if (gc == null) gc = new GregorianCalendar(); gc.setTime(((DateRange) translatedValue).getLower()); gc.set(GregorianCalendar.HOUR, 0); gc.set(GregorianCalendar.MINUTE, 0); gc.set(GregorianCalendar.SECOND, 0); gc.set(GregorianCalendar.MILLISECOND, 0); ps.setDate(pos[0], new java.sql.Date(gc.getTimeInMillis())); gc.setTime(((DateRange) translatedValue).getUpper()); gc.set(GregorianCalendar.HOUR, 0); gc.set(GregorianCalendar.MINUTE, 0); gc.set(GregorianCalendar.SECOND, 0); gc.set(GregorianCalendar.MILLISECOND, 0); ps.setDate(pos[1], new java.sql.Date(gc.getTimeInMillis())); break; case DateTimeRange: checkDataType(FxDateTimeRange.class, value, data.getXPathFull()); if (gc == null) gc = new GregorianCalendar(); gc.setTime(((DateRange) translatedValue).getLower()); ps.setTimestamp(pos[0], new Timestamp(gc.getTimeInMillis())); gc.setTime(((DateRange) translatedValue).getUpper()); ps.setTimestamp(pos[1], new Timestamp(gc.getTimeInMillis())); break; case Binary: checkDataType(FxBinary.class, value, data.getXPathFull()); BinaryDescriptor binary = (BinaryDescriptor) translatedValue; if (!binary.isNewBinary()) { ps.setLong(pos[0], binary.getId()); } else { try { //transfer the binary from the transit table to the binary table BinaryDescriptor created = binaryStorage.binaryTransit(con, binary); ps.setLong(pos[0], created.getId()); //check all other properties if they contain the same handle //and replace with the data of the new binary for (FxData _curr : allData) { if (_curr instanceof FxPropertyData && !_curr.isEmpty() && ((FxPropertyData) _curr).getValue() instanceof FxBinary) { FxBinary _val = (FxBinary) ((FxPropertyData) _curr).getValue(); _val._replaceHandle(binary.getHandle(), created); } } } catch (FxApplicationException e) { throw new FxDbException(e); } } break; case SelectOne: checkDataType(FxSelectOne.class, value, data.getXPathFull()); ps.setLong(pos[0], ((FxSelectListItem) translatedValue).getId()); break; case SelectMany: checkDataType(FxSelectMany.class, value, data.getXPathFull()); SelectMany sm = (SelectMany) translatedValue; for (int i1 = 0; i1 < sm.getSelected().size(); i1++) { FxSelectListItem item = sm.getSelected().get(i1); if (i1 > 0) { if (batchContentDataChanges()) ps.addBatch(); else ps.executeUpdate(); } ps.setLong(pos[0], item.getId()); ps.setString(pos[1], sm.getSelectedIdsList()); ps.setLong(pos[2], sm.getSelectedIds().size()); } if (sm.getSelected().size() == 0) ps.setLong(pos[0], 0); //write the virtual item as a marker to have a valid row break; case Reference: //reference integrity check is done prior to saving ps.setLong(pos[0], ((FxPK) translatedValue).getId()); break; case InlineReference: default: throw new FxDbException(LOG, "ex.db.notImplemented.store", prop.getDataType().getName()); } int valueDataPos = insert ? getValueDataInsertPos(prop.getDataType()) : getValueDataUpdatePos(prop.getDataType()); if (value.hasValueData(translatedLanguage)) { ps.setInt(valueDataPos, value.getValueDataRaw(translatedLanguage)); } else ps.setNull(valueDataPos, Types.NUMERIC); if (batchContentDataChanges()) ps.addBatch(); else { try { ps.executeUpdate(); } catch (SQLException e) { LOG.error(prop.getName(), e); throw e; } } } } else { switch (prop.getDataType()) { //TODO: implement datatype specific insert default: throw new FxDbException(LOG, "ex.db.notImplemented.store", prop.getDataType().getName()); } } if (ft != null && prop.isFulltextIndexed() && includeFullText) ft.index(data); }
From source file:gov.noaa.pfel.coastwatch.Projects.java
/** * Processes one CalCOFI2012 tsv file into a .nc file. * // w w w . j a v a 2 s.com * <p>The var sequence of latitude, latitudeMinutes, latitudeLocation * will be converted to 1 latitude column (decimal degrees). * Similar with longitude. * * <p>If units are yyMM, var will be converted to yyyyMM and units="". * * <p>If units are yyMMdd, var will be converted to yyyyMMdd, then * to "seconds since 1970-01-01T00:00:00Z" (assuming Pacific time zone) * and sets attribute: time_precision=1970-01-01. * * <p>If units of variable after yyMMdd are HHmm, the date and time will * be combined into one "seconds since 1970-01-01T00:00:00Z" variable. * * <p>If variableName="timeZone", this checks to see if arriveDate value * timeZone offset is as expected. * * @param dir * @param tableName e.g., CC_TOWS * @param info with 4 strings (name, type, units, long_name) for each variable * @param towTypesDescription will be added as description=[towTypesDescrption] * when variableName=towTypeCode. * @return the table, as saved in the .nc file. */ public static Table processOneCalcofi2012(String dir, String tableName, String info[], String towTypesDescription) throws Exception { String rowName = "row"; int cutoffYear = 20; // fourDigitYear += twoDigitYear < cutoffYear? 2000 : 1900; /* make tsv into ERDDAP-style .json table //{ // "table": { // "columnNames": ["longitude", "latitude", "time", "sea_surface_temperature"], // "columnTypes": ["float", "float", "String", "float"], // "columnUnits": ["degrees_east", "degrees_north", "UTC", "degree_C"], // "rows": [ // [180.099, 0.032, "2007-10-04T12:00:00Z", 27.66], // [180.099, 0.032, null, null], // [189.971, -7.98, "2007-10-04T12:00:00Z", 29.08] // ] //} */ String inFile = dir + tableName + ".txt"; String2.log("\n* processOneCalcofi2012 " + inFile); StringArray names = new StringArray(); StringArray types = new StringArray(); StringArray units = new StringArray(); StringArray lNames = new StringArray(); Test.ensureEqual(info.length % 4, 0, "info.length=" + info.length); int nVars = info.length / 4; int n = 0; for (int v = 0; v < nVars; v++) { names.add(info[n++]); types.add(info[n++]); units.add(info[n++]); lNames.add(info[n++]); } String fromFile[] = String2.readFromFile(inFile); if (fromFile[0].length() > 0) throw new RuntimeException(fromFile[0]); String lines = String2.replaceAll(fromFile[1], "\t", ","); lines = String2.replaceAll(lines, "\n", "],\n["); lines = "{\n" + " \"table\": {\n" + " \"columnNames\": [" + names.toJsonCsvString() + "],\n" + " \"columnTypes\": [" + types.toJsonCsvString() + "],\n" + " \"columnUnits\": [" + units.toJsonCsvString() + "],\n" + " \"rows\": [\n" + "[" + lines.substring(0, lines.length() - 3) + "\n" + "]\n" + "}\n"; String2.log(lines.substring(0, Math.min(lines.length(), 1500))); Table table = new Table(); table.readJson(inFile, lines); String2.log("Before adjustments:\n" + String2.annotatedString(table.dataToString(5))); int nRows = table.nRows(); int nErrors = 0; //things where nColumns won't change for (int v = 0; v < table.nColumns(); v++) { PrimitiveArray pa = table.getColumn(v); String vName = table.getColumnName(v); Attributes atts = table.columnAttributes(v); //longNames atts.add("long_name", lNames.get(v)); //relies on original var lists //timeZone nErrors = 0; if ("timeZone".equals(vName)) { PrimitiveArray arrivePA = table.getColumn("arriveDate"); //still yyMMdd GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); Calendar2.clearSmallerFields(gc, Calendar2.DATE); for (int row = 0; row < nRows; row++) { String val = arrivePA.getString(row); if (val.matches("[0-9]{6}")) { int year = String2.parseInt(val.substring(0, 2)); gc.set(Calendar2.YEAR, year < cutoffYear ? 2000 : 1900); gc.set(Calendar2.MONTH, String2.parseInt(val.substring(2, 4)) - 1); //0.. gc.set(Calendar2.DATE, String2.parseInt(val.substring(4, 6))); int fileHas = pa.getInt(row); int calculated = -gc.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000) + //in hours -gc.get(Calendar.DST_OFFSET) / (60 * 60 * 1000); //in hours if (fileHas != calculated) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + vName + " row=" + row + " timeZone=" + fileHas + " != calculated(" + val + ")=" + calculated); } } } if (nErrors > 0) String2.pressEnterToContinue("Bob: check US daylight savings time rules. On/near these dates?\n" + "https://en.wikipedia.org/wiki/History_of_time_in_the_United_States\n" + "nErrors=" + nErrors); } } //things where nColumns may change for (int v = 0; v < table.nColumns(); v++) { PrimitiveArray pa = table.getColumn(v); String vName = table.getColumnName(v); Attributes atts = table.columnAttributes(v); String vUnits = atts.getString("units"); Attributes nextAtts = v < table.nColumns() - 1 ? table.columnAttributes(v + 1) : new Attributes(); //towTypeCode if ("towTypeCode".equals(vName)) atts.add("description", towTypesDescription); //latitude nErrors = 0; if ("latitude".equals(vName) && "latitudeMinutes".equals(table.getColumnName(v + 1)) && "latitudeLocation".equals(table.getColumnName(v + 2))) { FloatArray fa = new FloatArray(nRows, false); //float avoids, e.g., xx.33333333333333 PrimitiveArray pa1 = table.getColumn(v + 1); PrimitiveArray pa2 = table.getColumn(v + 2); for (int row = 0; row < nRows; row++) { String loc = pa2.getString(row); String combo = pa.getString(row) + " " + pa1.getString(row) + " " + loc; float f = //will be NaN if trouble (pa.getFloat(row) + (pa1.getFloat(row) / 60)) * (loc.equals("N") ? 1 : loc.equals("S") ? -1 : Float.NaN); fa.atInsert(row, f); if (combo.length() > 2 && //2 spaces (f < -90 || f > 90 || Float.isNaN(f))) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + vName + " row=" + row + " lat=" + combo + " -> " + f); } } table.setColumn(v, fa); table.removeColumn(v + 2); table.removeColumn(v + 1); } if (nErrors > 0) String2.pressEnterToContinue("nErrors=" + nErrors); //longitude nErrors = 0; if ("longitude".equals(vName) && "longitudeMinutes".equals(table.getColumnName(v + 1)) && "longitudeLocation".equals(table.getColumnName(v + 2))) { FloatArray fa = new FloatArray(nRows, false); //float avoids, e.g., xx.33333333333333 PrimitiveArray pa1 = table.getColumn(v + 1); PrimitiveArray pa2 = table.getColumn(v + 2); for (int row = 0; row < nRows; row++) { String loc = pa2.getString(row); String combo = pa.getString(row) + " " + pa1.getString(row) + " " + loc; float f = //will be NaN if trouble (pa.getFloat(row) + (pa1.getFloat(row) / 60)) * (loc.equals("E") ? 1 : loc.equals("W") ? -1 : Float.NaN); fa.atInsert(row, f); if (combo.length() > 2 && //2 spaces (f < -180 || f > 180 || Float.isNaN(f))) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + vName + " row=" + row + " lat=" + combo + " -> " + f); } } table.setColumn(v, fa); table.removeColumn(v + 2); table.removeColumn(v + 1); } if (nErrors > 0) String2.pressEnterToContinue("nErrors=" + nErrors); //yyMM add century to cruiseYYMM nErrors = 0; if ("yyMM".equals(vUnits)) { for (int row = 0; row < nRows; row++) { String val = pa.getString(row); if (val.matches("[0-9]{4}")) { int year = String2.parseInt(val.substring(0, 2)); pa.setString(row, (year < cutoffYear ? "20" : "19") + val); } else { if (val.length() != 0) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + vName + " row=" + row + " yyMM=" + val); } pa.setString(row, ""); //set to MV } } atts.set("units", ""); //leave it as a String identifier } if (nErrors > 0) String2.pressEnterToContinue("nErrors=" + nErrors); //yyMMdd nErrors = 0; if ("yyMMdd".equals(vUnits)) { String nextUnits = nextAtts.getString("units"); boolean nextHasMinutes = "HHmm".equals(nextUnits); if (nextHasMinutes) String2.log("combining yyMMdd and next column (HHmm)"); String nextVName = nextHasMinutes ? table.getColumnName(v + 1) : ""; DoubleArray datePA = new DoubleArray(nRows, false); PrimitiveArray minutesPA = nextHasMinutes ? table.getColumn(v + 1) : (PrimitiveArray) null; //??!! Use Zulu or local, or time_zone data (in one table only)? GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); Calendar2.clearSmallerFields(gc, Calendar2.DATE); for (int row = 0; row < nRows; row++) { String val = pa.getString(row); if (val.matches("[0-9]{6}")) { int year = String2.parseInt(val.substring(0, 2)); gc.set(Calendar2.YEAR, year < cutoffYear ? 2000 : 1900); gc.set(Calendar2.MONTH, String2.parseInt(val.substring(2, 4)) - 1); //0.. gc.set(Calendar2.DATE, String2.parseInt(val.substring(4, 6))); if (nextHasMinutes) { Calendar2.clearSmallerFields(gc, Calendar2.DATE); int HHmm = minutesPA.getInt(row); if (HHmm < 0 || HHmm > 2359) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + nextVName + " row=" + row + " HHmm=" + minutesPA.getString(row)); } else { gc.set(Calendar2.HOUR_OF_DAY, HHmm / 100); gc.set(Calendar2.MINUTE, HHmm % 100); } } datePA.add(Calendar2.gcToEpochSeconds(gc)); } else { if (val.length() != 0) { nErrors++; if (nErrors <= 5) String2.log("ERROR: col=" + vName + " row=" + row + " yyMMdd=" + val); } datePA.add(Double.NaN); } } table.setColumn(v, datePA); atts.set("units", Calendar2.SECONDS_SINCE_1970); atts.set("time_precision", //AKA EDV.TIME_PRECISION nextHasMinutes ? "1970-01-01T00:00" : "1970-01-01"); if (nextHasMinutes) table.removeColumn(v + 1); } if (nErrors > 0) String2.pressEnterToContinue("nErrors=" + nErrors); } //save as .nc String2.log("After adjustments:\n" + String2.annotatedString(table.dataToString(5))); table.saveAsFlatNc(dir + tableName + ".nc", rowName, false); return table; }
From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java
public List<Date> expandRecurrenceOverRange(ParsedDateTime dtStart, long rangeStart, long rangeEnd) throws ServiceException { List<Date> toRet = new LinkedList<Date>(); Date rangeStartDate = new Date(rangeStart); // subtract 1000ms (1sec) because the code in the method treats // end time as inclusive while the rangeEnd input argument is // exclusive value Date rangeEndDate = new Date(rangeEnd - 1000); Date dtStartDate = new Date(dtStart.getUtcTime()); Date earliestDate;/*w w w . jav a2 s .c o m*/ if (dtStartDate.after(rangeStartDate)) earliestDate = dtStartDate; else earliestDate = rangeStartDate; if (mUntil != null) { Date until = mUntil.getDateForRecurUntil(dtStart.getTimeZone()); if (until.before(rangeEndDate)) rangeEndDate = until; } // Set limit of expansion count. int maxInstancesFromConfig = sExpansionLimits.maxInstances; int maxInstancesExpanded; if (maxInstancesFromConfig <= 0) maxInstancesExpanded = mCount; else if (mCount <= 0) maxInstancesExpanded = maxInstancesFromConfig; else maxInstancesExpanded = Math.min(mCount, maxInstancesFromConfig); int numInstancesExpanded = 1; // initially 1 rather than 0 because DTSTART is always included // Set hard limit of expansion time range. (bug 21989) ParsedDateTime earliestDateTime = ParsedDateTime.fromUTCTime(earliestDate.getTime()); Date hardEndDate = getEstimatedEndTime(earliestDateTime); if (hardEndDate.before(rangeEndDate)) rangeEndDate = hardEndDate; if (rangeEndDate.before(earliestDate)) { ZimbraLog.calendar.debug( "Expanding recurrence over range where range end %s is before earliest date %s", DateUtil.formatDate(rangeEndDate), DateUtil.formatDate(earliestDate)); return toRet; } GregorianCalendar cur = dtStart.getCalendarCopy(); int baseMonthDay = cur.get(Calendar.DAY_OF_MONTH); boolean baseIsLeapDay = ((baseMonthDay == 29) && (cur.get(Calendar.MONTH) == Calendar.FEBRUARY)); // until we hit rangeEnd, or we've SAVED count entries: // // gather each set { // // // // curDate forward one INTERVAL // // } // check Set against BYSETPOS & ranges & count // int interval = mInterval; if (interval <= 0) interval = 1; // DTSTART is always part of the expansion, as long as it falls within // the range. if (!dtStartDate.before(earliestDate) && !dtStartDate.after(rangeEndDate)) toRet.add(dtStartDate); int numConsecutiveIterationsWithoutMatchingInstance = 0; boolean pastHardEndTime = false; long numIterations = 0; // track how many times we looped while (!pastHardEndTime && (maxInstancesExpanded <= 0 || numInstancesExpanded < maxInstancesExpanded)) { numIterations++; boolean curIsAtOrAfterEarliestDate = !cur.getTime().before(earliestDate); boolean curIsAfterEndDate = cur.getTime().after(rangeEndDate); List<Calendar> addList = new LinkedList<Calendar>(); switch (mFreq) { case HOURLY: /* * BYSECOND - for each listed second * BYMINUTE - for each listed minute in hour * BYHOUR - match iff in hour list * BYDAY - for each day listed * BYMONTHDAY - only those monthdays * BYYEARDAY - only those yeardays * BYMONTH - only those months */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; if (!checkDayList(cur)) continue; if (!checkHourList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.HOUR_OF_DAY, interval); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case DAILY: /* * BYSECOND - for each listed second in day * BYMINUTE - for each listed minute in day * BYHOUR - for each listed hour in day * BYDAY - no ordinal allowed, match iff in day list * BYMONTHDAY - only that day * BYYEARDAY - only that day * BYWEEKNO -- YEARLY ONLY * BYMONTH - only that month * * while (count check & until check & rangeEnd check) { * if (byMonth && !month matches) * curDay = set MONTH to matching month * * if (byYearDay && !yearday matches) * curDay = set DAY to next matching yearday * * if (byMonthday && !monthday matches) * curDay = skip to next matching monthday * * if (byDay && !day in list) * curDay = skip to next mathcing byDay * * if (!byHour or FOR EACH HOUR IN HOURLIST) * if (!byMinute or FOR EACH MINUTE IN MINLIST) * if (!bySecond or FOR EACH SECOND IN LIST) * ----add to list--- * * check against BYSETPOS * * curDay+=1 day * } * */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; if (!checkDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.DAY_OF_YEAR, interval); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case WEEKLY: /* * BYSECOND - for every listed second * BYMINUTE - for every listed minute * BYHOUR - for every listed hour * BYDAY - for every listed day * BYMONTHDAY - MAYBE once a month * BYYEARDAY - MAYBE once a year * BYMONTH - iff month matches * * for each (INTERVAL)WEEK{ * if (byMonth && !month matches) * curDay = set MONTH to DtStart in next matching month * * if (byYearDay && !yearday matches) * curDay = set date to next matching yearday * * if (byMonthDay && !monthday matches) * curDay = skip to next matching monthday * * if (!byDay or FOREACH day in list) * if (!byHour or FOREACH hour in list) * if (!byMinute or FOREACH minute in list) * if (!bySecond or FOREACH second in list) * ----add to list---- * * check against BYSETPOS * * curDay += 1 week * } while (count check & until check & rangeEnd check) * */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.WEEK_OF_YEAR, interval); addList = expandDayListForWeekly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case MONTHLY: if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.set(Calendar.DAY_OF_MONTH, 1); cur.add(Calendar.MONTH, interval); int daysInMonth = cur.getActualMaximum(Calendar.DAY_OF_MONTH); cur.set(Calendar.DAY_OF_MONTH, Math.min(baseMonthDay, daysInMonth)); addList = expandMonthDayList(addList); addList = expandDayListForMonthlyYearly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case YEARLY: /* * BYSECOND * BYMINUTE * BYHOUR * BYDAY * BYMONTHDAY * BYYEARDAY * BYWEEKNO - specified week * BYMONTH - once */ if (baseIsLeapDay) { // previously adding a year to a leap day will have rounded down to the 28th. // If this happened, we need to be sure that if we are back in a leap // year, it is back at 29th cur.set(Calendar.DAY_OF_MONTH, cur.getActualMaximum(Calendar.DAY_OF_MONTH)); } if (ignoreYearForRecurrenceExpansion(cur, baseIsLeapDay)) { cur.add(Calendar.YEAR, interval); break; } addList.add((Calendar) (cur.clone())); cur.add(Calendar.YEAR, interval); addList = expandMonthList(addList); addList = expandYearDayList(addList); addList = expandMonthDayList(addList); addList = expandDayListForMonthlyYearly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; default: // MINUTELY and SECONDLY are intentionally not supported for performance reasons. return toRet; } addList = handleSetPos(addList); boolean noInstanceFound = true; boolean foundInstancePastEndDate = false; // add all the ones that match! for (Calendar addCal : addList) { Date toAdd = addCal.getTime(); // We already counted DTSTART before the main loop, so don't // count it twice. if (toAdd.compareTo(dtStartDate) == 0) { noInstanceFound = false; continue; } // we still have expanded this instance, even if it isn't in our // current date window if (toAdd.after(dtStartDate)) numInstancesExpanded++; if (!toAdd.after(rangeEndDate)) { if (!toAdd.before(earliestDate)) { toRet.add(toAdd); noInstanceFound = false; } } else { foundInstancePastEndDate = true; break; } if (maxInstancesExpanded > 0 && numInstancesExpanded >= maxInstancesExpanded) break; } // Detect invalid rule. If the rule was invalid the current iteration, which is for the current // frequency interval, would have found no matching instance. The next iteration will also find // no matching instance, and there is no need to keep iterating until we go past the hard end // time or COUNT/UNTIL limit. // // However, we have to make an exception for leap year. An yearly rule looking for February 29th // will find no instance in up to 3 consecutive years before finding Feb 29th in the fourth year. // // So the invalid rule detection must look for at least 4 consecutive failed iterations. if (curIsAtOrAfterEarliestDate) { if (noInstanceFound) numConsecutiveIterationsWithoutMatchingInstance++; else numConsecutiveIterationsWithoutMatchingInstance = 0; if (numConsecutiveIterationsWithoutMatchingInstance >= 4) { ZimbraLog.calendar.warn("Invalid recurrence rule: " + toString()); return toRet; } } pastHardEndTime = foundInstancePastEndDate || (noInstanceFound && curIsAfterEndDate); } return toRet; }
From source file:gov.noaa.pfel.erddap.dataset.EDDTableFromNcFiles.java
/** *//*from ww w. jav a 2s . c o m*/ public static void testNow() throws Throwable { String2.log("\n*** EDDTableFromNcFiles.testNow"); EDDTable tedd = (EDDTable) oneFromDatasetsXml(null, "ndbcSosWaves"); //has very recent data //these query tests need a dataset that has recent data (or request is rejected) //these tests moved here 2014-01-23 GregorianCalendar gc = Calendar2.newGCalendarZulu(); gc.set(Calendar2.MILLISECOND, 0); gc.add(Calendar2.SECOND, 1); //now it is "now" long nowMillis = gc.getTimeInMillis(); String s; StringArray rv = new StringArray(); StringArray cv = new StringArray(); StringArray co = new StringArray(); StringArray cv2 = new StringArray(); gc = Calendar2.newGCalendarZulu(nowMillis); String2.log("now = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now", rv, cv, co, cv2, false); Test.ensureEqual(rv.toString(), "time", ""); Test.ensureEqual(cv.toString(), "time", ""); Test.ensureEqual(co.toString(), "=", ""); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.SECOND, -1); String2.log("now-1second = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-1second", rv, cv, co, cv2, false); Test.ensureEqual(rv.toString(), "time", ""); Test.ensureEqual(cv.toString(), "time", ""); Test.ensureEqual(co.toString(), "=", ""); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.SECOND, 2); String2.log("now+2seconds = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now%2B2seconds", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); //non-%encoded '+' will be decoded as ' ', so treat ' ' as equal to '+' gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.SECOND, 2); String2.log("now 2seconds = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now 2seconds", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.MINUTE, -3); String2.log("now-3minutes = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-3minutes", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.HOUR_OF_DAY, -4); String2.log("now-4hours = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-4hours", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.DATE, -5); String2.log("now-5days = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-5days", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.MONTH, -6); String2.log("now-6months = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-6months", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); gc = Calendar2.newGCalendarZulu(nowMillis); gc.add(Calendar2.YEAR, -2); String2.log("now-7years = " + Calendar2.formatAsISODateTimeT3(gc)); //non-regex EDVTimeStamp conValues will be ""+epochSeconds tedd.parseUserDapQuery("time&time=now-2years", rv, cv, co, cv2, false); Test.ensureEqual(cv2.toString(), "" + Calendar2.gcToEpochSeconds(gc), ""); //if (true) throw new RuntimeException("stop here"); }
From source file:com.aimluck.eip.schedule.util.ScheduleUtils.java
public static boolean isDuplicateFacilitySchedule(EipTSchedule schedule, List<Integer> facilityIdList, Integer _old_scheduleid, Date _old_viewDate) { /* *///from w w w. j ava 2 s .co m GregorianCalendar cald = new GregorianCalendar(); boolean result = false; { Date start_date; Date end_date; String repeat_pattern; String repeat_type; String repeat_week = null; boolean week_0; boolean week_1; boolean week_2; boolean week_3; boolean week_4; boolean week_5; boolean week_6; boolean day_of_week_in_month_1; boolean day_of_week_in_month_2; boolean day_of_week_in_month_3; boolean day_of_week_in_month_4; boolean day_of_week_in_month_5; boolean[] day_of_week_in_month_array = new boolean[5]; String limit_flag; int month_day = -1; int year_month = -1; int year_day = -1; Integer db_scheduleid = null; boolean[] week_array = new boolean[7]; boolean unlimited_repeat = false; try { start_date = schedule.getStartDate(); end_date = schedule.getEndDate(); repeat_pattern = schedule.getRepeatPattern(); repeat_type = repeat_pattern.substring(0, 1); day_of_week_in_month_1 = repeat_pattern.matches("W.......1.?"); day_of_week_in_month_2 = repeat_pattern.matches("W.......2.?"); day_of_week_in_month_3 = repeat_pattern.matches("W.......3.?"); day_of_week_in_month_4 = repeat_pattern.matches("W.......4.?"); day_of_week_in_month_5 = repeat_pattern.matches("W.......5.?"); if (repeat_type.equals("W")) { if (repeat_pattern.length() == 9) { repeat_week = "0"; day_of_week_in_month_1 = true; day_of_week_in_month_2 = true; day_of_week_in_month_3 = true; day_of_week_in_month_4 = true; day_of_week_in_month_5 = true; } else { repeat_week = repeat_pattern.substring(8, 9); } } limit_flag = repeat_pattern.substring(repeat_pattern.length() - 1); week_0 = repeat_pattern.matches("W1........?"); week_1 = repeat_pattern.matches("W.1.......?"); week_2 = repeat_pattern.matches("W..1......?"); week_3 = repeat_pattern.matches("W...1.....?"); week_4 = repeat_pattern.matches("W....1....?"); week_5 = repeat_pattern.matches("W.....1...?"); week_6 = repeat_pattern.matches("W......1..?"); if (repeat_pattern.startsWith("M")) { month_day = Integer.parseInt(repeat_pattern.substring(1, 3)); } if (repeat_pattern.startsWith("Y")) { year_month = Integer.parseInt(repeat_pattern.substring(1, 3)); year_day = Integer.parseInt(repeat_pattern.substring(3, 5)); } // ???1?????? if (repeat_pattern.startsWith("N")) { Calendar cal = Calendar.getInstance(); cal.setTime(start_date); int dow = cal.get(Calendar.DAY_OF_WEEK); week_0 = (dow == Calendar.SUNDAY); week_1 = (dow == Calendar.MONDAY); week_2 = (dow == Calendar.TUESDAY); week_3 = (dow == Calendar.WEDNESDAY); week_4 = (dow == Calendar.THURSDAY); week_5 = (dow == Calendar.FRIDAY); week_6 = (dow == Calendar.SATURDAY); month_day = cal.get(Calendar.DAY_OF_MONTH); int dowim = cal.get(Calendar.DAY_OF_WEEK_IN_MONTH); day_of_week_in_month_1 = (dowim == 1); day_of_week_in_month_2 = (dowim == 2); day_of_week_in_month_3 = (dowim == 3); day_of_week_in_month_4 = (dowim == 4); day_of_week_in_month_5 = (dowim == 5); year_month = cal.get(Calendar.MONTH) + 1; year_day = cal.get(Calendar.DAY_OF_MONTH); } else if (repeat_pattern.endsWith("N")) { unlimited_repeat = true; } week_array[0] = week_0; week_array[1] = week_1; week_array[2] = week_2; week_array[3] = week_3; week_array[4] = week_4; week_array[5] = week_5; week_array[6] = week_6; day_of_week_in_month_array[0] = day_of_week_in_month_1; day_of_week_in_month_array[1] = day_of_week_in_month_2; day_of_week_in_month_array[2] = day_of_week_in_month_3; day_of_week_in_month_array[3] = day_of_week_in_month_4; day_of_week_in_month_array[4] = day_of_week_in_month_5; } catch (RuntimeException e) { logger.error("schedule", e); return false; } catch (Exception e) { logger.error("schedule", e); return false; } if (repeat_type.equals("S")) { // ??0:00:00?????23:59:59?? Calendar cal = Calendar.getInstance(); cal.setTime(end_date); cal.add(Calendar.DATE, 1); cal.add(Calendar.MINUTE, -1); end_date = cal.getTime(); } // ??? if (facilityIdList.size() > 0) {// List<Integer> fids = facilityIdList; SelectQuery<EipTScheduleMap> fquery = Database.query(EipTScheduleMap.class); Expression fexp1 = ExpressionFactory.inExp(EipTScheduleMap.USER_ID_PROPERTY, fids); fquery.setQualifier(fexp1); Expression fexp2 = ExpressionFactory.matchExp(EipTScheduleMap.TYPE_PROPERTY, ScheduleUtils.SCHEDULEMAP_TYPE_FACILITY); fquery.andQualifier(fexp2); Expression oneexp = null;// 1 Expression spanexp = null;// Expression rdexp = null;// Expression rwexp = null;// Expression rwexp2 = null; // Expression rwlexp = null; Expression rmexp = null;// Expression ryexp = null; { // ? Expression exp100 = ExpressionFactory.matchExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "N"); try { if (!unlimited_repeat) { Expression exp101 = ExpressionFactory.lessOrEqualExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.START_DATE_PROPERTY, end_date);// EipTSchedule.START_DATE_PROPERTY <= end_date Expression exp102 = ExpressionFactory.greaterExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.END_DATE_PROPERTY, start_date);// EipTSchedule.END_DATE_PROPERTY > start_date oneexp = exp100.andExp(exp101.andExp(exp102)); } else { oneexp = exp100; } } catch (Exception e) { } } { // ? Expression exp200 = ExpressionFactory.matchExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "S"); try { if (!unlimited_repeat) { // ??00:00?????? Calendar cal_end = Calendar.getInstance(); cal_end.setTime(end_date); cal_end = DateUtils.truncate(cal_end, Calendar.DAY_OF_MONTH); Expression exp201 = ExpressionFactory.lessOrEqualExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.START_DATE_PROPERTY, cal_end.getTime()); // EipTSchedule.START_DATE_PROPERTY <= end_date Calendar cal_start = Calendar.getInstance(); cal_start.setTime(start_date); cal_start = DateUtils.truncate(cal_start, Calendar.DAY_OF_MONTH); Expression exp202 = ExpressionFactory.greaterOrEqualExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.END_DATE_PROPERTY, cal_start.getTime()); // EipTSchedule.END_DATE_PROPERTY >= start_date spanexp = exp200.andExp(exp201.andExp(exp202)); } else { spanexp = exp200; } } catch (Exception e) { } } { // ?? // char lim = 'N'; if ("ON".equals(limit_flag)) { // lim = 'L'; } { // "D".equals(repeat_type.getValue()) Expression dexp01 = ExpressionFactory.likeExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "D_"); rdexp = dexp01; } { // "W".equals(repeat_type.getValue()) Expression wexp = null; List<Expression> wexps = new ArrayList<Expression>(); if (week_0 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W1_______"); wexps.add(wexp); } if (week_1 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_1______"); wexps.add(wexp); } if (week_2 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W__1_____"); wexps.add(wexp); } if (week_3 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W___1____"); wexps.add(wexp); } if (week_4 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W____1___"); wexps.add(wexp); } if (week_5 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_____1__"); wexps.add(wexp); } if (week_6 == true) { wexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W______1_"); wexps.add(wexp); } if (wexps.size() > 0) { rwexp = wexps.get(0); int wexpssize = wexps.size(); for (int k = 1; k < wexpssize; k++) { rwexp = rwexp.orExp(wexps.get(k)); } } else { rwexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W________"); } } { Expression wexp2 = null; List<Expression> wexps2 = new ArrayList<Expression>(); Expression wnexp = null; List<Expression> wnexp2 = new ArrayList<Expression>(); if (week_0 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W1________"); wexps2.add(wexp2); } if (week_1 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_1_______"); wexps2.add(wexp2); } if (week_2 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W__1______"); wexps2.add(wexp2); } if (week_3 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W___1_____"); wexps2.add(wexp2); } if (week_4 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W____1____"); wexps2.add(wexp2); } if (week_5 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_____1___"); wexps2.add(wexp2); } if (week_6 == true) { wexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W______1__"); wexps2.add(wexp2); } if (repeat_week != null && repeat_week.equals("1") || day_of_week_in_month_1) { wnexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_______1_"); wnexp2.add(wnexp); } if (repeat_week != null && repeat_week.equals("2") || day_of_week_in_month_2) { wnexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_______2_"); wnexp2.add(wnexp); } if (repeat_week != null && repeat_week.equals("3") || day_of_week_in_month_3) { wnexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_______3_"); wnexp2.add(wnexp); } if (repeat_week != null && repeat_week.equals("4") || day_of_week_in_month_4) { wnexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_______4_"); wnexp2.add(wnexp); } if (repeat_week != null && repeat_week.equals("5") || day_of_week_in_month_5) { wnexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_______5_"); wnexp2.add(wnexp); } if (wexps2.size() > 0 && wnexp2.size() > 0) { for (int k = 0; k < wexps2.size(); k++) { for (int l = 0; l < wnexp2.size(); l++) { if (k == 0 && l == 0) { rwexp2 = wexps2.get(k).andExp(wnexp2.get(l)); } else { rwexp2 = rwexp2.orExp(wexps2.get(k).andExp(wnexp2.get(l))); } } } } else { rwexp2 = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "W_________"); } } { // "M".equals(repeat_type.getValue()) if (month_day > 0) { // ???????? DecimalFormat exF = new DecimalFormat("00"); String md_str = exF.format(month_day); rmexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "M" + md_str + "_"); } else if (year_day > 0 && year_month > 0) { // ?? DecimalFormat exG = new DecimalFormat("00"); String yd_str = exG.format(year_day); rmexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "M" + yd_str + "_"); } else { rmexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "M___"); } } { // "Y".equals(repeat_type.getValue()) if (year_day > 0 && year_month > 0) { // ???????? DecimalFormat exG = new DecimalFormat("00"); String ym_str = exG.format(year_month); String yd_str = exG.format(year_day); ryexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "Y" + ym_str + yd_str + "_"); } else if (month_day > 0) { // ?? DecimalFormat exF = new DecimalFormat("00"); String md_str = exF.format(month_day); ryexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "Y__" + md_str + "_"); } else { ryexp = ExpressionFactory.likeExp(EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.REPEAT_PATTERN_PROPERTY, "Y_____"); } } Expression repeatexp = oneexp; if (rdexp != null) { repeatexp = repeatexp.orExp(rdexp); } if (rwexp != null) { repeatexp = repeatexp.orExp(rwexp); } if (rwexp2 != null) { repeatexp = repeatexp.orExp(rwexp2); } if (rmexp != null) { repeatexp = repeatexp.orExp(rmexp); } if (spanexp != null) { repeatexp = repeatexp.orExp(spanexp); } if (ryexp != null) { repeatexp = repeatexp.orExp(ryexp); } fquery.andQualifier(repeatexp); } db_scheduleid = schedule.getScheduleId(); if (db_scheduleid != null && db_scheduleid >= 0) { Expression exp00 = ExpressionFactory.noMatchDbExp( EipTScheduleMap.EIP_TSCHEDULE_PROPERTY + "." + EipTSchedule.SCHEDULE_ID_PK_COLUMN, db_scheduleid); fquery.andQualifier(exp00); } fquery.distinct(true); List<EipTScheduleMap> f_list = fquery.fetchList(); if (f_list != null && f_list.size() > 0) { // ????? boolean existFacility = false; int f_list_size = f_list.size(); for (int i = 0; i < f_list_size; i++) { EipTScheduleMap map = f_list.get(i); Date dbStartDate = map.getEipTSchedule().getStartDate(); Date dbEndDate = map.getEipTSchedule().getEndDate(); boolean containtsRs = false; // ?????? String ptn = map.getEipTSchedule().getRepeatPattern(); if (ptn.charAt(0) == 'S') { // try { // ??0:00:00?????23:59:59?? Calendar cal = Calendar.getInstance(); cal.setTime(dbEndDate); cal.add(Calendar.DATE, 1); cal.add(Calendar.MINUTE, -1); dbEndDate = cal.getTime(); if ((end_date.after(dbStartDate) && start_date.before(dbEndDate)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else if (ptn.charAt(0) == 'N') { // ? if ("D".equals(repeat_type) || "N".equals(repeat_type)) { // or // ? try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } } else if (ptn.charAt(0) == 'D') {// if (ptn.charAt(1) == 'L') { try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { containtsRs = true; } } else if (ptn.charAt(0) == 'W') { if (ptn.length() == 9) { if (ptn.charAt(8) == 'L') { try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { containtsRs = true; } } else if (ptn.length() == 10) { if (ptn.charAt(9) == 'L') { try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { containtsRs = true; } } } else if (ptn.charAt(0) == 'M') { if (ptn.charAt(3) == 'L') { try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { containtsRs = true; } } else if (ptn.charAt(0) == 'Y') { if (ptn.charAt(5) == 'L') { try { if ((dbStartDate.before(end_date) && dbEndDate.after(start_date)) || unlimited_repeat) { containtsRs = true; } } catch (Exception e) { containtsRs = false; } } else { containtsRs = true; } } else { containtsRs = true; } if (containtsRs) { /* ?????? */ int ss_flg = ScheduleUtils.compareTime(start_date, dbEndDate); int se_flg = ScheduleUtils.compareTime(end_date, dbStartDate); if (ss_flg > 0 && se_flg < 0) { /* ???????????? */ if (!"N".equals(ptn) && ptn.endsWith("N") && unlimited_repeat) {// ?(?????&&???)&&???? existFacility = true; } else { Date _start_date = null; Date _end_date = null; if (!"N".equals(ptn) && ptn.endsWith("N") && !unlimited_repeat) {// ?(??&&???)&&??? _start_date = (Date) start_date.clone(); _end_date = (Date) end_date.clone(); } else if (("N".equals(ptn) || !ptn.endsWith("N")) && unlimited_repeat) {// ?(?||??)&&???? _start_date = (Date) dbStartDate.clone(); _end_date = (Date) dbEndDate.clone(); } else if (("N".equals(ptn) || !ptn.endsWith("N")) && !unlimited_repeat) {// ?(?||??)&&??? if (dbStartDate.after(start_date)) { _start_date = (Date) dbStartDate.clone(); } else { _start_date = (Date) start_date.clone(); } if (dbEndDate.before(end_date)) { _end_date = (Date) dbEndDate.clone(); } else { _end_date = (Date) end_date.clone(); } } if ((_start_date == null) || (_end_date == null)) { continue; } /* ??? */ Expression dexp1 = ExpressionFactory.matchExp(EipTSchedule.NAME_PROPERTY, "dummy");// Expression dexp2 = ExpressionFactory.matchExp(EipTSchedule.PARENT_ID_PROPERTY, map.getScheduleId()); if (db_scheduleid != null) { Expression dexp21 = ExpressionFactory .matchExp(EipTSchedule.PARENT_ID_PROPERTY, db_scheduleid); dexp2 = dexp2.orExp(dexp21); } Expression dexp3 = null; cald.setTime(_start_date); cald.set(Calendar.MILLISECOND, 0); cald.set(Calendar.SECOND, 0); cald.set(Calendar.MINUTE, 0); cald.set(Calendar.HOUR_OF_DAY, 0); Date ddate = cald.getTime();// _start_date? List<EipTSchedule> temp = null; if ("N".equals(repeat_pattern)) { /* ?????????????? */ if ((_old_scheduleid != null) && (_old_viewDate != null)) { if ((_old_scheduleid.intValue() == map.getScheduleId().intValue()) && compareToDate(_start_date, _old_viewDate) == 0) { continue; } } try { dexp3 = ExpressionFactory.matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database .query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)) .fetchList(); if (temp == null || temp.size() <= 0) { existFacility = true; break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } } else if (repeat_pattern.startsWith("D")) { while (!ddate.after(_end_date)) { if (matchDay(cald, ptn)) { try { dexp3 = ExpressionFactory .matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database.query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)).fetchList(); if (temp == null || temp.size() <= 0) { existFacility = true; break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } } cald.add(Calendar.DATE, 1); ddate = cald.getTime(); } } else if (repeat_pattern.startsWith("S")) { while (!ddate.after(_end_date)) { try { dexp3 = ExpressionFactory.matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database.query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)).fetchList(); if (temp == null || temp.size() <= 0) { existFacility = true; break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } cald.add(Calendar.DATE, 1); ddate = cald.getTime(); } } else if (repeat_pattern.startsWith("W")) { /* ? */ int wlen = week_array.length; int wlen2 = day_of_week_in_month_array.length; if (wlen < 1 || wlen2 < 1) { continue; } int k; int l; while (!ddate.after(_end_date)) { k = (cald.get(Calendar.DAY_OF_WEEK) - 1) % wlen; l = (cald.get(Calendar.DAY_OF_WEEK_IN_MONTH) - 1) % wlen2; if ((week_array[k] == true) && (day_of_week_in_month_array[l] == true) && matchDay(cald, ptn)) { try { dexp3 = ExpressionFactory .matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database.query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)).fetchList();// SQL if (temp == null || temp.size() <= 0) { existFacility = true;// true???? break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } } cald.add(Calendar.DATE, 1); ddate = cald.getTime(); } } else if (repeat_pattern.startsWith("M")) { /* ?? */ cald.setTime(dbStartDate); cald.set(Calendar.MILLISECOND, 0); cald.set(Calendar.SECOND, 0); cald.set(Calendar.MINUTE, 0); cald.set(Calendar.HOUR_OF_DAY, 0); if (month_day > 0) { cald.set(Calendar.DAY_OF_MONTH, month_day); } else { continue; } Date tmp_date = cald.getTime(); while (tmp_date.before(ddate)) { cald.add(Calendar.MONTH, 1); /* ???????????????? */ while (month_day > cald.getActualMaximum(Calendar.DAY_OF_MONTH)) { cald.add(Calendar.MONTH, 1); cald.set(Calendar.DAY_OF_MONTH, month_day); if (tmp_date.before(tmp_date)) { break; } } tmp_date = cald.getTime(); } ddate = tmp_date; /* */ while (!ddate.after(_end_date)) { if (matchDay(cald, ptn)) { try { dexp3 = ExpressionFactory .matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database.query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)).fetchList(); if (temp == null || temp.size() <= 0) { existFacility = true; break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } } cald.add(Calendar.MONTH, 1); /* ???????????????? */ while (month_day > cald.getActualMaximum(Calendar.DAY_OF_MONTH)) { cald.add(Calendar.MONTH, 1); cald.set(Calendar.DAY_OF_MONTH, month_day); if (!ddate.after(_end_date)) { break; } } ddate = cald.getTime(); } } else if (repeat_pattern.startsWith("Y")) { /* ?? */ cald.setTime(dbStartDate); cald.set(Calendar.MILLISECOND, 0); cald.set(Calendar.SECOND, 0); cald.set(Calendar.MINUTE, 0); cald.set(Calendar.HOUR_OF_DAY, 0); if (year_month > 0 && year_day > 0) { cald.set(Calendar.MONTH, year_month - 1); cald.set(Calendar.DAY_OF_MONTH, year_day); } else { continue; } Date tmp_date = cald.getTime(); while (tmp_date.before(ddate)) { cald.add(Calendar.MONTH, 1); /* ???????????????? */ while (year_day > cald.getActualMaximum(Calendar.DAY_OF_MONTH)) { cald.add(Calendar.MONTH, 1); cald.set(Calendar.DAY_OF_MONTH, year_day); if (tmp_date.before(tmp_date)) { break; } } tmp_date = cald.getTime(); } ddate = tmp_date; /* */ while (!ddate.after(_end_date)) { if (matchDay(cald, ptn)) { try { dexp3 = ExpressionFactory .matchExp(EipTSchedule.START_DATE_PROPERTY, ddate); temp = Database.query(EipTSchedule.class, dexp1.andExp(dexp2).andExp(dexp3)).fetchList(); if (temp == null || temp.size() <= 0) { existFacility = true; break; } } catch (Exception e) { logger.error("[DuplicateFacilityCheck]: ", e); existFacility = true; break; } } cald.add(Calendar.MONTH, 1); /* ???????????????? */ while (year_day > cald.getActualMaximum(Calendar.DAY_OF_MONTH)) { cald.add(Calendar.MONTH, 1); cald.set(Calendar.DAY_OF_MONTH, year_day); if (!ddate.after(_end_date)) { break; } } ddate = cald.getTime(); } } else { continue; } } } } if (existFacility) { break; } } if (existFacility) { return existFacility; } } } } return result; }