List of usage examples for java.util Date setTime
public void setTime(long time)
From source file:com.bigdata.dastor.tools.DastorAdminCli.java
public void printColumnFamilyStats(PrintStream outs, String tableName, ColumnFamilyStoreMBean cfstore) { String cfName = cfstore.getColumnFamilyName(); outs.println("\t\tBucket Name: " + cfName); outs.println("\t\tSSTable count: " + cfstore.getLiveSSTableCount()); outs.println("\t\tStorage used (live): " + cfstore.getLiveDiskSpaceUsed()); outs.println("\t\tStorage used (gross): " + cfstore.getTotalDiskSpaceUsed()); outs.println("\t\tMemtable cells count: " + cfstore.getMemtableColumnsCount()); outs.println("\t\tMemtable data size: " + cfstore.getMemtableDataSize()); outs.println("\t\tMemtable flush count: " + cfstore.getMemtableSwitchCount()); outs.println("\t\tTotal Read count: " + cfstore.getReadCount()); outs.println("\t\tRecent Read latency(ms): " + String.format("%01.3f", cfstore.getRecentReadLatencyMicros() / 1000)); outs.println("\t\tRecent Read throughput(ops/s): " + cfstore.getRecentReadThroughput()); outs.println("\t\tTotal Write count: " + cfstore.getWriteCount()); outs.println("\t\tRecent Write latency(ms): " + String.format("%01.3f", cfstore.getRecentWriteLatencyMicros() / 1000)); outs.println("\t\tRecent Write throughput(ops/s): " + cfstore.getRecentWriteThroughput()); outs.println("\t\tPending tasks: " + cfstore.getPendingTasks()); JMXInstrumentedCacheMBean keyCacheMBean = probe.getKeyCacheMBean(tableName, cfName); if (keyCacheMBean.getCapacity() > 0) { outs.println("\t\tKey cache capacity: " + keyCacheMBean.getCapacity()); outs.println("\t\tKey cache size: " + keyCacheMBean.getSize()); outs.println("\t\tKey cache hit rate: " + keyCacheMBean.getRecentHitRate()); } else {/*w w w. j a v a2s .c o m*/ outs.println("\t\tKey cache: disabled"); } JMXInstrumentedCacheMBean rowCacheMBean = probe.getRowCacheMBean(tableName, cfName); if (rowCacheMBean.getCapacity() > 0) { outs.println("\t\tRow cache capacity: " + rowCacheMBean.getCapacity()); outs.println("\t\tRow cache size: " + rowCacheMBean.getSize()); outs.println("\t\tRow cache hit rate: " + rowCacheMBean.getRecentHitRate()); } else { outs.println("\t\tRow cache: disabled"); } outs.println("\t\tCompacted row minimum size: " + cfstore.getMinRowCompactedSize()); outs.println("\t\tCompacted row maximum size: " + cfstore.getMaxRowCompactedSize()); outs.println("\t\tCompacted row mean size: " + cfstore.getMeanRowCompactedSize()); outs.println("\t\tStatus: " + cfstore.getStatusString()); Date cfStatusTimestamp = new Date(); cfStatusTimestamp.setTime(cfstore.getStatusTimestamp()); outs.println("\t\tStatus timestamp: " + cfStatusTimestamp.getTime() + ", " + cfStatusTimestamp); outs.println(""); }
From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java
/** * Called to have the fragment instantiate its user interface view. This is optional, * and non-graphical fragments can return null (which is the default implementation). T * his will be called between onCreate(Bundle) and onActivityCreated(Bundle). * * If you return a View from here, you will later be called in onDestroyView * when the view is being released./* w w w.ja v a2 s .co m*/ * * @param inflater Inflater used to create the widgets. * @param container ViewGroup parent of this view. * @param savedInstanceState Bundle that contains all the information for this activity. * @return View that will be used to present the information. */ @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_add_amount, container, false); // Recover the values to restore the edit values. if (savedInstanceState != null) { mCurrentAmount = savedInstanceState.getDouble(AMOUNT_KEY); mSelectedAccount = savedInstanceState.getInt(ACCOUNT_KEY); mCurrentDate = savedInstanceState.getLong(DATE_KEY); mCurrentNotes = savedInstanceState.getString(NOTES_KEY); hideDialog = true; } customizeAmountButton(rootView, mCurrentAmount); if (!hideDialog) { displayInputMoneyDialog(mCurrentAmount); } // Get adapter this will be filled by the loader. mAccountsSpinner = (Spinner) rootView.findViewById(R.id.accounts_spinner); mAccountsSpinner.postInvalidate(); mAccountsSpinner.setAdapter(mAdapter); // Set the current date as a formattedString. final Date currentDate = new Date(); mDateText = (TextView) rootView.findViewById(R.id.current_date); if (mCurrentDate != 0) { currentDate.setTime(mCurrentDate); } // Set the date on the current label. setCurrentDateText(currentDate); createDateTimeDialog(); mNotes = (EditText) rootView.findViewById(R.id.notesText); if (mCurrentNotes != null) { mNotes.setText(mCurrentNotes); } createActionBar(inflater); mFragmentTitle = (TextView) rootView.findViewById(R.id.title_amount); createAddCashInstance(getArguments().getBoolean(MainActivity.SUBSTRACT_MOVEMENT)); return rootView; }
From source file:org.apache.openjpa.persistence.kernel.TestProxies2.java
public void testDate() { OpenJPAEntityManager pm = getPM(true, true); startTx(pm);/*from w w w . j a v a 2s.co m*/ ProxiesPC pc = pm.find(ProxiesPC.class, _oid); Date date = pc.getDate(); assertNotNull(date); // dates can lose precision, but make sure same day assertEquals(_date.getYear(), date.getYear()); assertEquals(_date.getMonth(), date.getMonth()); assertEquals(_date.getDate(), date.getDate()); // make sure proxied assertTrue(!pm.isDirty(pc)); date.setTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24); assertTrue(pm.isDirty(pc)); endTx(pm); assertEquals(date, pc.getDate()); endEm(pm); }
From source file:org.apache.openjpa.persistence.kernel.TestProxies2.java
public void testSQLDate() { OpenJPAEntityManager pm = getPM(true, true); startTx(pm);/*from ww w . ja v a 2s . co m*/ ProxiesPC pc = pm.find(ProxiesPC.class, _oid); java.sql.Date date = pc.getSQLDate(); assertNotNull(date); // dates can lose precision, but make sure same day assertEquals(_sqlDate.getYear(), date.getYear()); assertEquals(_sqlDate.getMonth(), date.getMonth()); assertEquals(_sqlDate.getDate(), date.getDate()); // make sure proxied assertTrue(!pm.isDirty(pc)); date.setTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24); assertTrue(pm.isDirty(pc)); endTx(pm); assertEquals(date, pc.getSQLDate()); endEm(pm); }
From source file:com.nextgis.firereporter.GetFiresService.java
protected void GetUserData(boolean bShowProgress) { Location currentLocation = null; String sLat = null, sLon = null; if (mLocManager != null) { currentLocation = mLocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (currentLocation == null) { currentLocation = mLocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); }/* w w w . j a va2s. c om*/ if (currentLocation == null) { SendError(getString(R.string.noLocation)); return; } else { sLat = Double.toString(currentLocation.getLatitude()); sLon = Double.toString(currentLocation.getLongitude()); } } SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS); String sURL = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER, getResources().getString(R.string.stDefaultServer)); String sLogin = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER_USER, "firereporter"); String sPass = prefs.getString(SettingsActivity.KEY_PREF_SRV_USER_PASS, "8QdA4"); int nDayInterval = prefs.getInt(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL + "_int", 5); int fetchRows = prefs.getInt(SettingsActivity.KEY_PREF_ROW_COUNT + "_int", 15); int searchRadius = prefs.getInt(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS + "_int", 5) * 1000;//meters boolean searchByDate = prefs.getBoolean("search_current_date", false); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); long diff = 86400000L * nDayInterval;//1000 * 60 * 60 * 24 * 5;// 5 days date.setTime(date.getTime() - diff); String dt = dateFormat.format(date); String sFullURL = sURL + "?function=get_rows_user&user=" + sLogin + "&pass=" + sPass + "&limit=" + fetchRows + "&radius=" + searchRadius;// if (searchByDate) { sFullURL += "&date=" + dt; } if (sLat.length() > 0 && sLon.length() > 0) { sFullURL += "&lat=" + sLat + "&lon=" + sLon; } //SELECT * FROM (SELECT id, report_date, latitude, longitude, round(ST_Distance_Sphere(ST_PointFromText('POINT(37.506247479468584 55.536129316315055)', 4326), fires.geom)) AS dist FROM fires WHERE ST_Intersects(fires.geom, ST_GeomFromText('POLYGON((32.5062474795 60.5361293163, 42.5062474795 60.5361293163, 42.5062474795 50.5361293163, 32.5062474795 50.5361293163, 32.5062474795 60.5361293163))', 4326) ) AND CAST(report_date as date) >= '2013-09-27')t WHERE dist <= 5000 LIMIT 15 //String sRemoteData = "http://gis-lab.info/data/zp-gis/soft/fires.php?function=get_rows_nasa&user=fire_usr&pass=J59DY&limit=5"; new HttpGetter(this, 1, getResources().getString(R.string.stDownLoading), mFillDataHandler, bShowProgress) .execute(sFullURL); }
From source file:com.nextgis.firereporter.GetFiresService.java
protected void GetNasaData(boolean bShowProgress) { Location currentLocation = null; String sLat = null, sLon = null; if (mLocManager != null) { currentLocation = mLocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (currentLocation == null) { currentLocation = mLocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); }/*from www .j a v a 2 s . c o m*/ if (currentLocation == null) { SendError(getString(R.string.noLocation)); return; } else { sLat = Double.toString(currentLocation.getLatitude()); sLon = Double.toString(currentLocation.getLongitude()); } } SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS); String sURL = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA, getResources().getString(R.string.stDefaultServer)); String sLogin = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA_USER, "fire_usr"); String sPass = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA_PASS, "J59DY"); int nDayInterval = prefs.getInt(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL + "_int", 5); int fetchRows = prefs.getInt(SettingsActivity.KEY_PREF_ROW_COUNT + "_int", 15); int searchRadius = prefs.getInt(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS + "_int", 5) * 1000;//meters boolean searchByDate = prefs.getBoolean(SettingsActivity.KEY_PREF_SEARCH_CURR_DAY, false); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); long diff = 86400000L * nDayInterval;//1000 * 60 * 60 * 24 * 5;// 5 days date.setTime(date.getTime() - diff); String dt = dateFormat.format(date); String sFullURL = sURL + "?function=get_rows_nasa&user=" + sLogin + "&pass=" + sPass + "&limit=" + fetchRows + "&radius=" + searchRadius;// if (searchByDate) { sFullURL += "&date=" + dt; } if (sLat.length() > 0 && sLon.length() > 0) { sFullURL += "&lat=" + sLat + "&lon=" + sLon; } //String sRemoteData = "http://gis-lab.info/data/zp-gis/soft/fires.php?function=get_rows_nasa&user=fire_usr&pass=J59DY&limit=5"; //if(!oNasa.getStatus().equals(AsyncTask.Status.RUNNING) && !oNasa.getStatus().equals(AsyncTask.Status.PENDING)) new HttpGetter(this, 2, getResources().getString(R.string.stDownLoading), mFillDataHandler, bShowProgress) .execute(sFullURL); }
From source file:org.apache.metron.dataloads.bulk.ElasticsearchDataPrunerTest.java
@Test public void testFilter() throws Exception { ObjectObjectHashMap<String, IndexMetaData> indexNames = new ObjectObjectHashMap(); SimpleDateFormat dateChecker = new SimpleDateFormat("yyyyMMdd"); int numDays = 5; String[] expectedIndices = new String[24]; Date indexDate = new Date(); indexDate.setTime(testDate.getTime() - TimeUnit.DAYS.toMillis(numDays)); for (int i = 0, j = 0; i < numDays * 24; i++) { String indexName = "sensor_index_" + dateFormat.format(indexDate); //Delete 20160330 if (dateChecker.format(indexDate).equals("20160330")) { expectedIndices[j++] = indexName; }//from w ww . ja v a2 s. com indexNames.put(indexName, null); indexDate.setTime(indexDate.getTime() + TimeUnit.HOURS.toMillis(1)); } ImmutableOpenMap<String, IndexMetaData> testIndices = ImmutableOpenMap.copyOf(indexNames); ElasticsearchDataPruner pruner = new ElasticsearchDataPruner(testDate, 1, configuration, indexClient, "sensor_index_"); pruner.indexClient = indexClient; Iterable<String> filteredIndices = pruner.getFilteredIndices(testIndices); Object[] indexArray = IteratorUtils.toArray(filteredIndices.iterator()); Arrays.sort(indexArray); Arrays.sort(expectedIndices); assertArrayEquals(expectedIndices, indexArray); }
From source file:com.fitforbusiness.nafc.dashboard.DashBoardFragment.java
private void loadSessions(String date) { Calendar calendar = Calendar.getInstance(); date = String.format("%d-%02d-%02d", calendar.get(Calendar.YEAR), (calendar.get(Calendar.MONTH) + 1), calendar.get(Calendar.DAY_OF_MONTH)); Date stDate = null; Date edDate = null;/* ww w. j ava 2 s . co m*/ try { stDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); stDate.setTime(stDate.getTime() - 1000); edDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); edDate.setTime(edDate.getTime() + (24 * 60 * 60 * 1000)); edDate.setTime(edDate.getTime() - 1000); } catch (Exception e) { e.printStackTrace(); return; } ArrayList<HashMap<String, Object>> mapArrayList = new ArrayList<>(); SQLiteDatabase sqlDB; try { sqlDB = DatabaseHelper.instance().getReadableDatabase(); String query = "select " + Table.Sessions.ID + " , " + Table.Sessions.START_DATE + " , " + Table.Sessions.START_TIME + " , " + Table.Sessions.SESSION_STATUS + " , " + Table.Sessions.GROUP_ID + " , " + Table.Sessions.IS_NATIVE + " , " + Table.Sessions.RECURRENCE_RULE + " , " + Table.Sessions.TITLE + " , " + Table.Sessions.SESSION_TYPE + " " + " from " + Table.Sessions.TABLE_NAME + " where " + Table.DELETED + " = 0 " + " and ( " + Table.Sessions.START_DATE + " = datetime(\'" + date + "\') " + " OR " + Table.Sessions.RECURRENCE_RULE + " IS NOT NULL " + " OR " + Table.Sessions.RECURRENCE_RULE + " != '' ) "; Log.d("query is ", query); assert sqlDB != null; Cursor cursor = sqlDB.rawQuery(query, null); Log.d("Calendar", "Month Count = " + cursor.getCount()); LinkedHashMap<String, Object> row; while (cursor.moveToNext()) { if (cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)) == null || cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)).equals("")) { row = new LinkedHashMap<String, Object>(); long groupSessionId = cursor.getInt(cursor.getColumnIndex(Table.Sessions.GROUP_ID)); int session_type = cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_TYPE)); rowData = getImageName(groupSessionId + "", session_type); row.put("_id", cursor.getString(cursor.getColumnIndex(Table.Sessions.ID))); row.put("name", Utils.dateConversionForRow( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_DATE))) + " " + Utils.timeFormatAMPM( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_TIME)))); row.put("rowId", groupSessionId); row.put("type", session_type); if (cursor.getInt(cursor.getColumnIndex(Table.Sessions.IS_NATIVE)) == 1) { row.put("secondLabel", cursor.getString(cursor.getColumnIndex(Table.Sessions.TITLE))); row.put("thirdLabel", getActivity().getString(R.string.lblNativeStatus)); Log.d("Calendar", "native events"); } else if (rowData.getImageName() != null && rowData.getImageName().length() > 0) { row.put("photo", rowData.getImageName()); row.put("secondLabel", rowData.getPersonName()); row.put("thirdLabel", status[cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_STATUS))]); Log.d("Calendar", "app events"); } Log.d("Calendar", (String) row.get("secondLabel")); mapArrayList.add(row); } else { String rule = cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)); RecurrenceRule recRule = new RecurrenceRule(rule); RecurrenceRule.Freq freq = recRule.getFreq(); Date d = new SimpleDateFormat("dd MMM yyyy").parse(Utils.formatConversionSQLite( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_DATE)))); switch (freq) { case MONTHLY: d.setMonth(stDate.getMonth()); case YEARLY: d.setYear(stDate.getYear()); } if (freq == RecurrenceRule.Freq.MONTHLY || freq == RecurrenceRule.Freq.YEARLY) { if (!(d.after(stDate) && d.before(edDate))) continue; } ArrayList<Calendar> dates; dates = CalendarMonthViewFragment.ruleOccurONDate(rule, stDate, edDate); Log.e("RecurRule", "size = " + dates.size()); if (dates.size() > 0) { row = new LinkedHashMap<String, Object>(); if (freq == RecurrenceRule.Freq.DAILY || freq == RecurrenceRule.Freq.WEEKLY) { if (d.after(dates.get(0).getTime())) continue; } long groupSessionId = cursor.getInt(cursor.getColumnIndex(Table.Sessions.GROUP_ID)); int session_type = cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_TYPE)); rowData = getImageName(groupSessionId + "", session_type); row.put("_id", cursor.getString(cursor.getColumnIndex(Table.Sessions.ID))); row.put("name", Utils.formatConversionDateOnly(stDate) + " " + Utils.timeFormatAMPM( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_TIME)))); row.put("rowId", groupSessionId); row.put("type", session_type); if (cursor.getInt(cursor.getColumnIndex(Table.Sessions.IS_NATIVE)) == 1) { row.put("secondLabel", cursor.getString(cursor.getColumnIndex(Table.Sessions.TITLE))); row.put("thirdLabel", getActivity().getString(R.string.lblNativeStatus)); Log.d("Calendar", "native events"); } else if (rowData.getImageName() != null && rowData.getImageName().length() > 0) { row.put("photo", rowData.getImageName()); row.put("secondLabel", rowData.getPersonName()); row.put("thirdLabel", status[cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_STATUS))]); Log.d("Calendar", "app events"); } Log.d("Calendar", (String) row.get("secondLabel")); mapArrayList.add(row); } } } cursor.close(); } catch (Exception e) { e.printStackTrace(); } CustomAsyncTaskListAdapter adapter = new CustomAsyncTaskListAdapter(getActivity(), R.layout.calendar_day_view_session_row, R.id.ivRowImage, R.id.tvFirstName, R.id.tvSecondLabel, R.id.tvThirdLabel, mapArrayList); sessionList.setAdapter(adapter); }