List of usage examples for java.util GregorianCalendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:net.urlgrey.mythpodcaster.transcode.IndividualFeedTranscodeTaskImpl.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from w ww . j a v a2 s . c o m*/ public void run() { if (subscription.isActive()) { // identify series recordings not represented in the RSS Feed (transcode) final List entries = feed.getEntries(); final RecordedSeries series; if (ScopeEnum.MOST_RECENT.equals(subscription.getScope())) { series = recordingsDao.findRecordedSeries(subscription.getSeriesId(), subscription.getNumberOfMostRecentToKeep()); } else { series = recordingsDao.findRecordedSeries(subscription.getSeriesId()); } if (series == null) { // if not occurrences of the recorded series are found, then continue LOGGER.debug("No recordings found for recordId[" + subscription.getSeriesId() + "]"); } if (series != null) { for (RecordedProgram program : series.getRecordedPrograms()) { if (program.getEndTime() == null) { LOGGER.debug("Skipping program, end-time is not set (possibly still recording): programId[" + program.getProgramId() + "]"); continue; } // We should determine whether the program is finished. // This can be determine by comparing the program end-time with the current time (the // comparison must use the same timezone for both dates) // See http://code.google.com/p/mythpodcaster/issues/detail?id=65 final GregorianCalendar programCal = new GregorianCalendar(); programCal.setTimeInMillis(program.getEndTime().getTime()); final GregorianCalendar localTimeCal = new GregorianCalendar(); if (programCal.after(localTimeCal)) { LOGGER.debug( "Skipping recorded program, end-time is in future (still recording): programId[" + program.getProgramId() + "]"); continue; } if (ScopeEnum.SPECIFIC_RECORDINGS.equals(this.subscription.getScope()) && (false == this.subscription.getRecordedProgramKeys().contains(program.getKey()))) { LOGGER.debug( "Skipping recorded program, not specified as a recording to transcode for this subscription: key[" + program.getKey() + "]"); continue; } boolean found = false; LOGGER.debug("Locating program in existing feed entries: programId[" + program.getProgramId() + "], key[" + program.getKey() + "]"); if (entries != null && entries.size() > 0) { final Iterator it = entries.iterator(); while (it.hasNext()) { final SyndEntry entry = (SyndEntry) it.next(); if (entry.getUri() == null) { continue; } String entryKey = entry.getUri(); if (program.getKey().equalsIgnoreCase(entryKey)) { found = true; break; } } } if (found) { LOGGER.debug("Program was found in feed, continuing"); } else { status.setTranscodingProfileName(transcodingProfilesDao.findAllProfiles() .get(subscription.getTranscodeProfile()).getDisplayName()); status.setTranscodingProgramEpisodeName(program.getKey()); status.setTranscodingSeriesTitle(series.getTitle()); status.setTranscodingProgramName(program.getProgramTitle()); status.setCurrentTranscodeStart(new Date()); final Channel channel = this.recordingsDao .findChannel(program.getRecordedProgramKey().getChannelId()); feedFileAccessor.addProgramToFeed(series, program, channel, feed, subscription.getTranscodeProfile()); writeFeedFile(entries); status.setCurrentTranscodeStart(null); } } } // identify RSS Feed entries no longer in the database (delete) if (entries != null && entries.size() > 0) { LOGGER.debug("Identifying series recordings no longer in database but still in feed, recordId[" + subscription.getSeriesId() + "]"); final Map<String, TranscodingProfile> transcodingProfiles = transcodingProfilesDao .findAllProfiles(); Set<SyndEntry> entryRemovalSet = new HashSet<SyndEntry>(); final Iterator it = entries.iterator(); while (it.hasNext()) { final SyndEntry entry = (SyndEntry) it.next(); if (entry.getUri() == null) { entryRemovalSet.add(entry); LOGGER.debug("Feed entry has null URI (GUID), removing because it cannot be identified"); continue; } // locate the feed entry in the list of recorded programs String episodeKey = entry.getUri(); boolean found = false; if (series != null) { for (RecordedProgram program : series.getRecordedPrograms()) { if (program.getKey().equalsIgnoreCase(episodeKey)) { found = true; break; } } } // for a feed using specific recordings, delete those entries that are no longer required if (ScopeEnum.SPECIFIC_RECORDINGS.equals(subscription.getScope()) && false == subscription.getRecordedProgramKeys().contains(episodeKey)) { found = false; } // if the feed entry is no longer in the list of recorded programs, then remove if (found) { LOGGER.debug("Feed entry is current, continuing: uid[" + entry.getUri() + "]"); } else { LOGGER.debug("Feed entry will be deleted: uid[" + entry.getUri() + "]"); entryRemovalSet.add(entry); final List enclosures = entry.getEnclosures(); if (enclosures.size() > 0) { final SyndEnclosure enclosure = (SyndEnclosure) enclosures.get(0); final TranscodingProfile transcodingProfile = transcodingProfiles .get(subscription.getTranscodeProfile()); transcodingProfile.deleteEncoding(this.feedFilePath, enclosure.getUrl(), entry.getUri()); } else { LOGGER.info("No enclosures specified in the entry, removing from feed and continuing"); } } } // remove all of the entries flagged for removal entries.removeAll(entryRemovalSet); writeFeedFile(entries); } } }
From source file:org.geotools.gce.imagemosaic.ImageMosaicPostgisIndexTest.java
/** * Complex test for Postgis indexing on db. * /*from w w w .j av a 2s .c o m*/ * @throws Exception */ @Test public void testSortingAndLimiting() throws Exception { final File workDir = new File(TestData.file(this, "."), "watertemp4"); assertTrue(workDir.mkdir()); FileUtils.copyFile(TestData.file(this, "watertemp.zip"), new File(workDir, "watertemp.zip")); TestData.unzipFile(this, "watertemp4/watertemp.zip"); final URL timeElevURL = TestData.url(this, "watertemp4"); //place datastore.properties file in the dir for the indexing FileWriter out = null; try { out = new FileWriter(new File(TestData.file(this, "."), "/watertemp4/datastore.properties")); final Set<Object> keyset = fixture.keySet(); for (Object key : keyset) { final String key_ = (String) key; final String value = fixture.getProperty(key_); out.write(key_.replace(" ", "\\ ") + "=" + value.replace(" ", "\\ ") + "\n"); } out.flush(); } finally { if (out != null) { IOUtils.closeQuietly(out); } } // now start the test final AbstractGridFormat format = TestUtils.getFormat(timeElevURL); assertNotNull(format); ImageMosaicReader reader = TestUtils.getReader(timeElevURL, format); assertNotNull(reader); final String[] metadataNames = reader.getMetadataNames(); assertNotNull(metadataNames); assertEquals(metadataNames.length, 10); assertEquals("true", reader.getMetadataValue("HAS_TIME_DOMAIN")); assertEquals("true", reader.getMetadataValue("HAS_ELEVATION_DOMAIN")); // dispose and create new reader reader.dispose(); final MyImageMosaicReader reader1 = new MyImageMosaicReader(timeElevURL); final RasterManager rm = reader1.getRasterManager(); // query final SimpleFeatureType type = rm.granuleCatalog.getType(); Query query = null; if (type != null) { // creating query query = new Query(rm.granuleCatalog.getType().getTypeName()); // sorting and limiting // max number of elements query.setMaxFeatures(1); // sorting final SortBy[] clauses = new SortBy[] { new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property("ingestion"), SortOrder.DESCENDING), new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property("elevation"), SortOrder.ASCENDING), }; query.setSortBy(clauses); } // checking that we get a single feature and that feature is correct Collection<GranuleDescriptor> features = rm.getGranules(query); assertEquals(features.size(), 1); GranuleDescriptor granule = features.iterator().next(); SimpleFeature sf = granule.getOriginator(); assertNotNull(sf); Object ingestion = sf.getAttribute("ingestion"); assertTrue(ingestion instanceof Timestamp); final GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT")); gc.setTimeInMillis(1225497600000l); assertEquals(0, (((Timestamp) ingestion).compareTo(gc.getTime()))); Object elevation = sf.getAttribute("elevation"); assertTrue(elevation instanceof Integer); assertEquals(((Integer) elevation).intValue(), 0); // Reverting order (the previous timestamp shouldn't match anymore) final SortBy[] clauses = new SortBy[] { new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property("ingestion"), SortOrder.ASCENDING), new SortByImpl(FeatureUtilities.DEFAULT_FILTER_FACTORY.property("elevation"), SortOrder.DESCENDING), }; query.setSortBy(clauses); // checking that we get a single feature and that feature is correct features = rm.getGranules(query); assertEquals(features.size(), 1); granule = features.iterator().next(); sf = granule.getOriginator(); assertNotNull(sf); ingestion = sf.getAttribute("ingestion"); assertTrue(ingestion instanceof Timestamp); assertNotSame(0, (((Timestamp) ingestion).compareTo(gc.getTime()))); elevation = sf.getAttribute("elevation"); assertTrue(elevation instanceof Integer); assertNotSame(((Integer) elevation).intValue(), 0); }
From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java
@Test public void InvalidTransferTokenEmptyNullAuthToken() { Assume.assumeTrue(TckPublisher.isEnabled()); String keyJoeBiz = null;//from w w w. j a v a 2s . c o m try { DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal); BusinessEntity myBusEntity = new BusinessEntity(); Name myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("InvalidTransferTokenEmptyNullAuthToken UDDI's Business" + " " + xcal.toString()); myBusEntity.getName().add(myBusName); myBusEntity.setBusinessServices(new BusinessServices()); myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI")); SaveBusiness sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(authInfoJoe); BusinessDetail bd = publishJoe.saveBusiness(sb); keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey(); //transfers from Joe to Sam KeyBag kb = new KeyBag(); kb.getKey().add(keyJoeBiz); Holder<String> nodeidOUT = new Holder<String>(); Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>(); Holder<byte[]> tokenOUT = new Holder<byte[]>(); custodyTransferPortTypeJoe.getTransferToken(null, kb, nodeidOUT, expiresOUT, tokenOUT); Assert.fail(); } catch (Exception ex) { logger.info("Expected exception: " + ex.getMessage()); } finally { TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe); } }
From source file:de.ribeiro.android.gso.core.UntisProvider.java
/** * Ldt die Selectoren(wochen/elemente/typen) von der GSO Seite und parsed * diese in den StupidCore//from w ww. j av a 2s .c o m * * @param logger * @param htmlResponse * @param getProfil () * @throws Exception * @author Tobias Janssen */ public static void syncTypeList(HtmlResponse htmlResponse, Profil mProfil) throws Exception { JSONArray clsarray = null; JSONArray teacherarray = null; JSONArray roomarray = null; GregorianCalendar date = new GregorianCalendar(); // session erzeugen und cookies abholen //TODO: Remove hardcoded URL String url = "https://webuntis.stadt-koeln.de/WebUntis/Timetable.do?request.preventCache=" + date.getTimeInMillis() + "&school=K175055"; HttpSession session = new HttpSession(url + 1); //5 Wochen in die Zukunft schauen for (int i = 0; i < 5; i++) { try { if (clsarray == null && (clsarray = RequestUrl(session, url, "1")) == null) { date.setTimeInMillis(date.getTimeInMillis() + (1000 * 60 * 60 * 24 * 7)); session.SetStupidServerDate(date, i + 1); continue; } if (teacherarray == null && (teacherarray = RequestUrl(session, url, "2")) == null) { date.setTimeInMillis(date.getTimeInMillis() + (1000 * 60 * 60 * 24 * 7)); session.SetStupidServerDate(date, i + 1); continue; } if (roomarray == null && (roomarray = RequestUrl(session, url, "4")) == null) { date.setTimeInMillis(date.getTimeInMillis() + (1000 * 60 * 60 * 24 * 7)); session.SetStupidServerDate(date, i + 1); continue; } session.Close(); _logger.Info("new Elements downloaded!"); mProfil.types.htmlModDate = htmlResponse.lastModified; break; } catch (Exception e) { throw new SyncFailedException(e.getMessage()); } } Type type = new Type(); type.elementList = ConvertJSonArray(clsarray); type.typeName = "Klassen"; type.type = "1"; AddTypeToProfil(mProfil, type); type = new Type(); type.elementList = ConvertJSonArray(teacherarray); type.typeName = "Lehrer"; type.type = "2"; AddTypeToProfil(mProfil, type); type = new Type(); type.elementList = ConvertJSonArray(roomarray); type.typeName = "Rume"; type.type = "4"; AddTypeToProfil(mProfil, type); mProfil.isDirty = true; }
From source file:org.apache.juddi.subscription.SubscriptionNotifier.java
protected GetSubscriptionResults buildGetSubscriptionResults(Subscription subscription, Date endPoint) throws DispositionReportFaultMessage, DatatypeConfigurationException { GetSubscriptionResults getSubscriptionResults = null; Duration duration = TypeConvertor.convertStringToDuration(subscription.getNotificationInterval()); Date startPoint = subscription.getLastNotified(); Date nextDesiredNotificationDate = null; if (startPoint == null) startPoint = subscription.getCreateDate(); nextDesiredNotificationDate = new Date(startPoint.getTime()); duration.addTo(nextDesiredNotificationDate); //nextDesiredNotificationDate = lastTime + the Interval Duration, which should be: //AFTER the lastNotified time and BEFORE the endTime (current time). If it is //after the endTime, then the user does not want a notification yet, so we accumulate. if (subscription.getLastNotified() == null || nextDesiredNotificationDate.after(startPoint) && nextDesiredNotificationDate.before(endPoint)) { getSubscriptionResults = new GetSubscriptionResults(); CoveragePeriod period = new CoveragePeriod(); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(startPoint.getTime()); period.setStartPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar)); calendar.setTimeInMillis(endPoint.getTime()); period.setEndPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar)); if (log.isDebugEnabled()) log.debug("Period " + period.getStartPoint() + " " + period.getEndPoint()); getSubscriptionResults.setCoveragePeriod(period); } else {//from w w w .ja v a 2 s . com log.debug("Client does not yet want a notification. The next desidered notification Date " + nextDesiredNotificationDate + ". The current interval [" + startPoint + " , " + endPoint + "] therefore skipping this notification cycle."); if (desiredDate == null || nextDesiredNotificationDate.getTime() < desiredDate.getTime()) { desiredDate = nextDesiredNotificationDate; } } return getSubscriptionResults; }
From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java
/** * a valid transfer token issued, then modified out of band, this should * fail//from w w w .j a v a 2 s. co m */ @Test public void InvalidTransferTokenModified() { Assume.assumeTrue(TckPublisher.isEnabled()); String keySamBiz = null; String keyJoeBiz = null; try { DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal); BusinessEntity myBusEntity = new BusinessEntity(); Name myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("InvalidTransferTokenModified UDDI's Business" + " " + xcal.toString()); myBusEntity.getName().add(myBusName); myBusEntity.setBusinessServices(new BusinessServices()); myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI")); SaveBusiness sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(authInfoJoe); BusinessDetail bd = publishJoe.saveBusiness(sb); keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey(); myBusEntity = new BusinessEntity(); myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("Root's Business" + " " + xcal.toString()); myBusEntity.getName().add(myBusName); myBusEntity.setBusinessServices(new BusinessServices()); myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("root")); sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(authInfoSam); bd = publishSam.saveBusiness(sb); keySamBiz = bd.getBusinessEntity().get(0).getBusinessKey(); //String keySamBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey(); //transfers from Joe to Sam KeyBag kb = new KeyBag(); kb.getKey().add(keyJoeBiz); Holder<String> nodeidOUT = new Holder<String>(); Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>(); Holder<byte[]> tokenOUT = new Holder<byte[]>(); custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT); //sam accepts TransferEntities te = new TransferEntities(); te.setAuthInfo(authInfoSam); te.setKeyBag(kb); te.getKeyBag().getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString()); TransferToken tt = new TransferToken(); tt.setExpirationTime(expiresOUT.value); tt.setNodeID(nodeidOUT.value); tt.setOpaqueToken(tokenOUT.value); te.setTransferToken(tt); custodyTransferPortTypeSam.transferEntities(te); Assert.fail(); } catch (Exception ex) { // HandleException(ex); logger.info("Expected exception: " + ex.getMessage()); } finally { TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe); TckCommon.DeleteBusiness(keySamBiz, authInfoSam, publishSam); } }
From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java
/** * tests a user to user transfer on the same node * * @throws Exception/* w ww.j a v a 2 s .c o m*/ */ @Test public void ValidTransfer() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("ValidTransfer"); DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal); BusinessEntity myBusEntity = new BusinessEntity(); Name myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("ValidTransfer UDDI's Business" + " " + xcal.toString()); myBusEntity.getName().add(myBusName); myBusEntity.setBusinessServices(new BusinessServices()); myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI")); SaveBusiness sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(authInfoJoe); BusinessDetail bd = publishJoe.saveBusiness(sb); String keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey(); //String keyJoeBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey(); myBusEntity = new BusinessEntity(); myBusName = new Name(); myBusName.setLang("en"); myBusName.setValue("ValidTransfer Root's Business" + " " + xcal.toString()); myBusEntity.getName().add(myBusName); myBusEntity.setBusinessServices(new BusinessServices()); myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("root")); sb = new SaveBusiness(); sb.getBusinessEntity().add(myBusEntity); sb.setAuthInfo(authInfoSam); bd = publishSam.saveBusiness(sb); String keySamBiz = bd.getBusinessEntity().get(0).getBusinessKey(); //String keySamBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey(); //transfers from Joe to Sam KeyBag kb = new KeyBag(); kb.getKey().add(keyJoeBiz); Holder<String> nodeidOUT = new Holder<String>(); Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>(); Holder<byte[]> tokenOUT = new Holder<byte[]>(); custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT); //sam accepts TransferEntities te = new TransferEntities(); te.setAuthInfo(authInfoSam); te.setKeyBag(kb); TransferToken tt = new TransferToken(); tt.setExpirationTime(expiresOUT.value); tt.setNodeID(nodeidOUT.value); tt.setOpaqueToken(tokenOUT.value); te.setTransferToken(tt); custodyTransferPortTypeSam.transferEntities(te); //confirm the transfer GetOperationalInfo go = new GetOperationalInfo(); go.setAuthInfo(authInfoSam); go.getEntityKey().add(keySamBiz); go.getEntityKey().add(keyJoeBiz); OperationalInfos operationalInfo = inquirySam.getOperationalInfo(go); for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) { if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(keyJoeBiz)) { Assert.assertEquals(operationalInfo.getOperationalInfo().get(i).getAuthorizedName(), (TckPublisher.getSamPublisherId())); } } System.out.println("Business Entity transfered successfull"); //note, we transfered ownership here so sam has to delete both of them TckCommon.DeleteBusiness(keyJoeBiz, authInfoSam, publishSam); TckCommon.DeleteBusiness(keySamBiz, authInfoSam, publishSam); }
From source file:org.energy_home.jemma.osgi.ah.hap.client.HapCoreService.java
public void _t(CommandInterpreter ci) { long t = getLastSuccessfulBatchRequestTimestamp(); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(t); ci.println("Last successful upload time: " + DateTimeConverter.printDateTime(gc)); }
From source file:org.eevolution.form.CRP.java
/** * Create Category Dataset based on Weight , date start and resource * @param start//from w ww .j ava 2 s . c o m * @param resource * @return CategoryDataset */ protected CategoryDataset createWeightDataset(Timestamp start, MResource rosource) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND); gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = MResourceType.get(Env.getCtx(), rosource.getS_ResourceType_ID()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "SELECT SUM( (mo.qtyordered-mo.qtydelivered)*(SELECT mp.weight FROM M_Product mp WHERE mo.m_product_id=mp.m_product_id )) FROM PP_Order mo WHERE AD_Client_ID=?", rosource.getAD_Client_ID()); double dailyCapacity = rosource.getDailyCapacity().doubleValue(); double utilization = rosource.getPercentUtilization().doubleValue(); double summary = 0; int day = 0; while (day < 32) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
From source file:TimePeriod.java
/** * Krzt den zeitraum, so das nur ganze Monate brig bleiben *//*w w w. j a va2s . com*/ public void setOnlyCompleteMonth() { // Auf den Beginn des nchsten monats setzen if (from.get(Calendar.DAY_OF_MONTH) != 1) { while (from.get(Calendar.DAY_OF_MONTH) != 1) { from.setTimeInMillis(from.getTimeInMillis() + ONE_DAY); } setMidnight(from); } // Auf das Ende des Vorherigen Monats setzen GregorianCalendar temp = new GregorianCalendar(); temp.setTimeInMillis(to.getTimeInMillis() + ONE_DAY); if (temp.get(Calendar.MONTH) == to.get(Calendar.MONTH)) { while (to.get(Calendar.MONTH) == temp.get(Calendar.MONTH)) { to.setTimeInMillis(to.getTimeInMillis() - ONE_DAY); } set2359(to); } }