List of usage examples for java.util GregorianCalendar getTimeInMillis
public long getTimeInMillis()
From source file:org.openhab.binding.powermax.internal.message.PowermaxCommManager.java
/** * Send a message to set the alarm time and date using the system time and date * * @return true if the message was sent or false if not *///from w w w. java2 s.c om public boolean sendSetTime() { logger.debug("sendSetTime()"); boolean done = false; if (autoSyncTime) { GregorianCalendar cal = new GregorianCalendar(); if (cal.get(Calendar.YEAR) >= 2000) { logger.debug("sendSetTime(): sync time {}", String.format("%02d/%02d/%04d %02d:%02d:%02d", cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND))); byte[] dynPart = new byte[6]; dynPart[0] = (byte) cal.get(Calendar.SECOND); dynPart[1] = (byte) cal.get(Calendar.MINUTE); dynPart[2] = (byte) cal.get(Calendar.HOUR_OF_DAY); dynPart[3] = (byte) cal.get(Calendar.DAY_OF_MONTH); dynPart[4] = (byte) (cal.get(Calendar.MONTH) + 1); dynPart[5] = (byte) (cal.get(Calendar.YEAR) - 2000); done = sendMessage(new PowermaxBaseMessage(PowermaxSendType.SETTIME, dynPart), false, 0); cal.set(Calendar.MILLISECOND, 0); syncTimeCheck = cal.getTimeInMillis(); } else { logger.info( "Powermax alarm binding: time not synchronized; please correct the date/time of your openHAB server"); syncTimeCheck = null; } } else { syncTimeCheck = null; } return done; }
From source file:org.apache.hadoop.hive.service.HSSessionItem.java
private String getQueryTime(GregorianCalendar stime, GregorianCalendar etime) { long diff = (etime.getTimeInMillis() - stime.getTimeInMillis()) / 1000; if (diff < 60) { return String.format("%1$02d%2$02d%3$02d%4$02d", 0, 0, 0, diff); } else if (diff >= 60 && diff < 3600) { return String.format("%1$02d%2$02d%3$02d%4$02d", 0, 0, diff / 60, diff % 60); } else if (diff >= 3600 && diff < (24 * 3600)) { return String.format("%1$02d%2$02d%3$02d%4$02d", 0, diff % (24 * 3600) / 3600, diff % 3600 / 60, diff % 60);/*w ww. j a v a2 s .c om*/ } else { int day = (int) (diff / (24 * 3600)); int hour = (int) (diff % (24 * 3600) / 3600); int minute = (int) (diff % 3600 / 60); int second = (int) (diff % 60); return String.format("%1$02d%2$02d%3$02d%4$02d", day, hour, minute, second); } }
From source file:org.nuxeo.ecm.core.opencmis.impl.CmisSuiteSession.java
@Test public void testLastModifiedServiceWrapper() throws Exception { if (!(isAtomPub || isBrowser)) { // test only makes sense in the context of REST HTTP return;/* www. ja v a2 s . c o m*/ } cmisFeatureSession.tearDownCmisSession(); Thread.sleep(1000); // otherwise sometimes fails to set up again // deploy the LastModifiedServiceWrapper harness.deployContrib("org.nuxeo.ecm.core.opencmis.tests.tests", "OSGI-INF/test-servicefactorymanager-contrib.xml"); session = cmisFeatureSession.setUpCmisSession(coreSession.getRepositoryName()); GregorianCalendar lastModifiedCalendar = Helper.getCalendar(2007, 4, 11, 12, 0, 0); // in GMT-02 Folder folder = (Folder) session.getObjectByPath("/testfolder1"); Map<String, Serializable> properties = new HashMap<>(); properties.put("dc:description", "my description"); properties.put("dc:modified", lastModifiedCalendar); folder.updateProperties(properties, true); // TODO XXX fix timezone issues with H2 / SQL Server StorageConfiguration storageConfiguration = coreFeature.getStorageConfiguration(); if (!(storageConfiguration.isVCSH2() || storageConfiguration.isVCSSQLServer())) { assertEquals(lastModifiedCalendar.getTimeInMillis(), ((GregorianCalendar) folder.getPropertyValue("dc:modified")).getTimeInMillis()); } // check Last-Modified Cache Response Header RepositoryInfo ri = session.getRepositoryInfo(); String uri = ri.getThinClientUri() + ri.getId() + "/"; uri += isAtomPub ? "children?id=" : "root?objectId="; uri += folder.getId(); String lastModified = DateUtil.formatDate(lastModifiedCalendar.getTime()); String encoding = Base64.encodeBytes(new String(USERNAME + ":" + PASSWORD).getBytes()); DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(uri); HttpResponse response = null; request.setHeader("Authorization", "Basic " + encoding); try { response = client.execute(request); assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); // TODO XXX fix timezone issues with H2 / SQL Server if (!(storageConfiguration.isVCSH2() || storageConfiguration.isVCSSQLServer())) { assertEquals(lastModified, response.getLastHeader("Last-Modified").getValue()); } } finally { client.getConnectionManager().shutdown(); } }
From source file:org.gluu.oxeleven.PKCS11RestServiceTest.java
@BeforeSuite public void init() { GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); calendar.add(GregorianCalendar.MINUTE, 5); expirationTime = calendar.getTimeInMillis(); }
From source file:com.bt.heliniumstudentapp.ScheduleFragment.java
@SuppressWarnings("ConstantConditions") @Override/*from w ww . j av a2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) { mainContext = (AppCompatActivity) getActivity(); scheduleLayout = inflater.inflate(R.layout.fragment_schedule, viewGroup, false); MainActivity.setToolbarTitle(mainContext, getResources().getString(R.string.schedule), null); weekDaysLV = (ListView) scheduleLayout.findViewById(R.id.lv_weekDays_fs); final boolean restart = PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("forced_restart", false); if (restart) PreferenceManager.getDefaultSharedPreferences(mainContext).edit().putBoolean("forced_restart", false) .apply(); if (restart) { //TODO Database check? MainActivity.setStatusBar(mainContext); scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null); if (MainActivity.isOnline()) parseData(HeliniumStudentApp.ACTION_ONLINE); else parseData(HeliniumStudentApp.ACTION_OFFLINE); } else if (scheduleJson == null) { final boolean online = MainActivity.isOnline(); scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); if (online && PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("pref_updates_auto_update", true)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) new UpdateClass(mainContext, false).execute(); else new UpdateClass(mainContext, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } if (online && (PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("pref_schedule_init", true) || PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null) == null)) { getSchedule(HeliniumStudentApp.DIREC_CURRENT, HeliniumStudentApp.ACTION_INIT_IN); } else if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { MainActivity.setStatusBar(mainContext); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null); if (online) parseData(HeliniumStudentApp.ACTION_ONLINE); else parseData(HeliniumStudentApp.ACTION_OFFLINE); } } ((SwipeRefreshLayout) scheduleLayout).setColorSchemeResources(MainActivity.accentSecondaryColor, MainActivity.accentPrimaryColor, MainActivity.primaryColor); ((SwipeRefreshLayout) scheduleLayout).setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); MainActivity.prevIV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { scheduleFocus--; getSchedule(HeliniumStudentApp.DIREC_BACK, HeliniumStudentApp.ACTION_REFRESH_IN); } else { final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE) .get(Calendar.WEEK_OF_YEAR); if (scheduleFocus > currentWeek + 1) { scheduleFocus = currentWeek + 1; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_1", null); } else { scheduleFocus = currentWeek; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); } parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); MainActivity.historyIV.setOnClickListener(new OnClickListener() { //FIXME Huge mess private int year; private int monthOfYear; private int dayOfMonth; @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { MainActivity.setUI(HeliniumStudentApp.VIEW_SCHEDULE, HeliniumStudentApp.ACTION_ONLINE); final AlertDialog.Builder weekpickerDialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(mainContext, MainActivity.themeDialog)); final View view = View.inflate(mainContext, R.layout.dialog_schedule, null); weekpickerDialogBuilder.setView(view); final DatePicker datePicker = (DatePicker) view.findViewById(R.id.np_weekpicker_dw); year = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.YEAR); monthOfYear = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.MONTH); dayOfMonth = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.DAY_OF_MONTH); weekpickerDialogBuilder.setTitle(getString(R.string.go_to)); weekpickerDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final GregorianCalendar date = new GregorianCalendar( HeliniumStudentApp.LOCALE); final GregorianCalendar today = new GregorianCalendar( HeliniumStudentApp.LOCALE); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, monthOfYear); date.set(Calendar.DAY_OF_MONTH, dayOfMonth); date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); today.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); scheduleFocus = (today.get(Calendar.WEEK_OF_YEAR)) - ((int) ((today.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7)) - (date.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7)))); getSchedule(HeliniumStudentApp.DIREC_OTHER, HeliniumStudentApp.ACTION_REFRESH_IN); } }); weekpickerDialogBuilder.setNegativeButton(getString(android.R.string.cancel), null); final AlertDialog weekPickerDialog = weekpickerDialogBuilder.create(); final GregorianCalendar minDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); minDate.set(Calendar.YEAR, 2000); minDate.set(Calendar.WEEK_OF_YEAR, 1); final GregorianCalendar maxDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); maxDate.set(Calendar.YEAR, 2038); maxDate.set(Calendar.WEEK_OF_YEAR, 1); datePicker.init(year, monthOfYear, dayOfMonth, new DatePicker.OnDateChangedListener() { final GregorianCalendar newDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); @Override public void onDateChanged(DatePicker view, int dialogYear, int dialogMonthOfYear, int dialogDayOfMonth) { newDate.set(year, monthOfYear, dayOfMonth); year = dialogYear; monthOfYear = dialogMonthOfYear; dayOfMonth = dialogDayOfMonth; if (minDate != null && minDate.after(newDate)) view.init(minDate.get(Calendar.YEAR), minDate.get(Calendar.MONTH), minDate.get(Calendar.DAY_OF_MONTH), this); else if (maxDate != null && maxDate.before(newDate)) view.init(maxDate.get(Calendar.YEAR), maxDate.get(Calendar.MONTH), maxDate.get(Calendar.DAY_OF_MONTH), this); else view.init(year, monthOfYear, dayOfMonth, this); } }); weekPickerDialog.setCanceledOnTouchOutside(true); weekPickerDialog.show(); weekPickerDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor)); weekPickerDialog.getButton(AlertDialog.BUTTON_NEGATIVE) .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor)); } else { scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); MainActivity.nextIV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { scheduleFocus++; getSchedule(HeliniumStudentApp.DIREC_NEXT, HeliniumStudentApp.ACTION_REFRESH_IN); } else { final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE) .get(Calendar.WEEK_OF_YEAR); if (PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_1", null) != null && scheduleFocus >= currentWeek) { scheduleFocus = currentWeek + 1; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_1", null); } else { scheduleFocus = currentWeek; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); } parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); return scheduleLayout; }
From source file:com.autentia.tnt.bean.activity.ActivityBean.java
/** * retrieves the duration of the external activity, calculated as the difference between start time and end time * @return/*from w w w.j av a2s .co m*/ */ public int getExternalActivityDuration() { GregorianCalendar startCal = new GregorianCalendar(); GregorianCalendar endCal = new GregorianCalendar(); startCal.setTime(getExternalActivityStartDate()); endCal.setTime(getExternalActivityEndDate()); int duration = (int) (endCal.getTimeInMillis() - startCal.getTimeInMillis()) / (60 * 1000); return duration; }
From source file:biz.wolschon.finance.jgnucash.panels.TaxReportPanel.java
/** * @param aFile the file to write to/*from w w w .j a va 2 s . co m*/ * @param aGran the granularity */ private void exportCSV(final File aFile, final ExportGranularities aGran) { //TODO: implement CSV-export FileWriter fw = null; try { fw = new FileWriter(aFile); // write headers List<TransactionSum> sums = mySums; fw.write("day"); for (TransactionSum transactionSum : sums) { fw.write(","); fw.write(transactionSum.getName()); } fw.write("\n"); // write data GregorianCalendar cal = new GregorianCalendar(); int add = aGran.getCalendarConstant(); DateFormat dateFormat = DateFormat.getDateInstance(); //NumberFormat numberFormat = NumberFormat.getInstance(); // we do NOT use getCurrencyInstance because it // contains a locale-specific currency-symbol for (int i = 0; i < 100; i++) { Date maxDate = cal.getTime(); fw.write(dateFormat.format(maxDate)); int transactionsCounted = 0; for (TransactionSum transactionSum : sums) { fw.write(","); try { transactionSum.setMaxDate(maxDate); FixedPointNumber value = transactionSum.getValue(); if (value != null) { //fw.write(numberFormat.format(value)); fw.write(value.toString()); } transactionsCounted += transactionSum.getTransactionsCounted(); } catch (JAXBException e) { LOGGER.error("Error calculating one of the TransactionSums", e); fw.write("ERROR"); } } fw.write("\n"); if (transactionsCounted == 0) { break; // we are walking back in time, // when there are no matching transactions, // all future runs will we a waste of time. // This happens often when add==YEAR } long old = cal.getTimeInMillis(); if (add == GregorianCalendar.MONTH) { cal.set(GregorianCalendar.DAY_OF_MONTH, 1); } if (add == GregorianCalendar.YEAR) { cal.set(GregorianCalendar.DAY_OF_MONTH, 1); cal.set(GregorianCalendar.MONTH, 1); } // usually we are in the middle of a month, // so do not skip the first day of the current // month if (i != 0 || old == cal.getTimeInMillis() || add == GregorianCalendar.DAY_OF_MONTH) { cal.add(add, -1); } } fw.close(); fw = null; } catch (IOException e) { LOGGER.error("cannot write csv-file", e); JOptionPane.showMessageDialog(this, "Cannot write CSV-file\n" + e.getMessage()); } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { LOGGER.error("cannot close csv-file", e); } } for (TransactionSum transactionSum : mySums) { try { transactionSum.setMaxDate(null); } catch (JAXBException e) { LOGGER.error("cannot set maxDate back to it's original value", e); } } } }
From source file:org.nuxeo.ecm.core.opencmis.impl.CmisSuiteSession.java
@Test public void testContentStream() throws Exception { Document file = (Document) session.getObjectByPath("/testfolder1/testfile1"); // check Cache Response Headers (eTag and Last-Modified) if (isAtomPub || isBrowser) { RepositoryInfo ri = session.getRepositoryInfo(); String uri = ri.getThinClientUri() + ri.getId() + "/"; uri += isAtomPub ? "content?id=" : "root?objectId="; uri += file.getId();/*from w w w. j a v a 2 s . c o m*/ String eTag = file.getPropertyValue("nuxeo:contentStreamDigest"); GregorianCalendar lastModifiedCalendar = file.getPropertyValue("dc:modified"); String lastModified = DateUtil.formatDate(lastModifiedCalendar.getTime()); String encoding = Base64.encodeBytes(new String(USERNAME + ":" + PASSWORD).getBytes()); DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(uri); HttpResponse response = null; request.setHeader("Authorization", "Basic " + encoding); try { request.setHeader("If-None-Match", eTag); response = client.execute(request); assertEquals(HttpServletResponse.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode()); request.removeHeaders("If-None-Match"); request.setHeader("If-Modified-Since", lastModified); response = client.execute(request); String debug = "lastModified=" + lastModifiedCalendar.getTimeInMillis() + " If-Modified-Since=" + lastModified + " NuxeoContentStream last=" + NuxeoContentStream.LAST_MODIFIED; // TODO NXP-16198 there are still timezone issues here // @Ignore // assertEquals(debug, HttpServletResponse.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode()); } finally { client.getConnectionManager().shutdown(); } } // get stream ContentStream cs = file.getContentStream(); assertNotNull(cs); assertEquals("text/plain", cs.getMimeType()); assertEquals("testfile.txt", cs.getFileName()); if (!(isAtomPub || isBrowser)) { // TODO fix AtomPub/Browser case where the length is unknown // (streaming) assertEquals(Helper.FILE1_CONTENT.length(), cs.getLength()); } assertEquals(Helper.FILE1_CONTENT, Helper.read(cs.getStream(), "UTF-8")); // set stream // TODO convenience constructors for ContentStreamImpl byte[] streamBytes = STREAM_CONTENT.getBytes("UTF-8"); ByteArrayInputStream stream = new ByteArrayInputStream(streamBytes); cs = new ContentStreamImpl("foo.txt", BigInteger.valueOf(streamBytes.length), "text/plain; charset=UTF-8", stream); file.setContentStream(cs, true); // refetch stream file = (Document) session.getObject(file); cs = file.getContentStream(); assertNotNull(cs); // AtomPub lowercases charset -> TODO proper mime type comparison String mimeType = cs.getMimeType().toLowerCase().replace(" ", ""); assertEquals("text/plain;charset=utf-8", mimeType); // TODO fix AtomPub case where the filename is null assertEquals("foo.txt", cs.getFileName()); if (!(isAtomPub || isBrowser)) { // TODO fix AtomPub/Browser case where the length is unknown // (streaming) assertEquals(streamBytes.length, cs.getLength()); } assertEquals(STREAM_CONTENT, Helper.read(cs.getStream(), "UTF-8")); // delete file.deleteContentStream(); file.refresh(); assertEquals(null, file.getContentStream()); }
From source file:org.eevolution.form.CRP.java
/** * Create Category Dataset based on date start and resource * @param start//from www.j a v a 2 s. co m * @param resource * @return CategoryDataset */ protected CategoryDataset createDataset(Timestamp start, MResource resource) { 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); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); MResourceType t = MResourceType.get(Env.getCtx(), resource.getS_ResourceType_ID()); int days = 1; long hours = t.getTimeSlotHours(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", resource.getS_Resource_ID()); MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID); if (!uom.isHour()) { return dataset; } long summary = 0; while (days < 32) { String day = new String(new Integer(date.getDate()).toString()); long HoursLoad = getLoad(resource, date).longValue(); Long Hours = new Long(hours); switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } } } return dataset; }
From source file:org.ecocean.MarkedIndividual.java
public boolean wasSightedInPeriod(int m_startYear, int m_startMonth, int m_endYear, int m_endMonth) { int endYear = m_endYear; int endMonth = m_endMonth; int startYear = m_startYear; int startMonth = m_startMonth; GregorianCalendar gcMin = new GregorianCalendar(startYear, startMonth, 1); GregorianCalendar gcMax = new GregorianCalendar(endYear, endMonth, 31); for (int c = 0; c < encounters.size(); c++) { Encounter temp = (Encounter) encounters.get(c); if ((temp.getDateInMilliseconds() != null) && (temp.getDateInMilliseconds() >= gcMin.getTimeInMillis()) && (temp.getDateInMilliseconds() <= gcMax.getTimeInMillis())) { return true; }//from w w w.ja v a 2s. c o m } return false; }