List of usage examples for android.text.format Time Time
public Time(Time other)
From source file:Main.java
/** * @return String//from www . ja v a 2 s . c o m * @throws * @Title: getTime * @Description: TODO */ public static String now() { Time nowTime = new Time("Asia/chongqing"); nowTime.setToNow(); return nowTime.format("%Y%m%d"); }
From source file:uk.org.openseizuredetector.SdData.java
public SdData() { simpleSpec = new int[10]; dataTime = new Time(Time.getCurrentTimezone()); }
From source file:com.granita.tasks.notification.NotificationActionIntentService.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override//from w w w. ja v a 2 s . c om protected void onHandleIntent(Intent intent) { mAuthority = getString(R.string.org_dmfs_tasks_authority); final String action = intent.getAction(); final Context context = this; if (intent.hasExtra(EXTRA_NOTIFICATION_ID)) { Uri taskUri = intent.getData(); int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(notificationId); if (ACTION_COMPLETE.equals(action)) { markCompleted(taskUri); } else if (intent.hasExtra(EXTRA_TASK_DUE) && intent.hasExtra(EXTRA_TIMEZONE)) { long due = intent.getLongExtra(EXTRA_TASK_DUE, -1); String tz = intent.getStringExtra(EXTRA_TIMEZONE); boolean allDay = intent.getBooleanExtra(EXTRA_ALLDAY, false); if (ACTION_DELAY_1H.equals(action)) { Time time = new Time(tz); time.set(due); time.allDay = false; time.hour++; time.normalize(true); delayTask(taskUri, time); } else if (ACTION_DELAY_1D.equals(action)) { if (tz == null) { tz = "UTC"; } Time time = new Time(tz); time.set(due); time.allDay = allDay; time.monthDay++; time.normalize(true); delayTask(taskUri, time); } } } else if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) { /* * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent to add some extra data, it must unparcel the * NotificationAction object. It throws a ClassNotFoundException when unparcelling. To avoid this, do the marshalling ourselves. */ final NotificationAction notificationAction; final byte[] data = intent.getByteArrayExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION); if (data != null) { final Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); notificationAction = NotificationAction.CREATOR.createFromParcel(in, NotificationAction.class.getClassLoader()); } else { return; } if (NotificationActionUtils.ACTION_UNDO.equals(action)) { NotificationActionUtils.cancelUndoTimeout(context, notificationAction); NotificationActionUtils.cancelUndoNotification(context, notificationAction); resendNotification(notificationAction); } else if (ACTION_COMPLETE.equals(action)) { // All we need to do is switch to an Undo notification NotificationActionUtils.createUndoNotification(context, notificationAction); NotificationActionUtils.registerUndoTimeout(this, notificationAction); } else { if (NotificationActionUtils.ACTION_UNDO_TIMEOUT.equals(action) || NotificationActionUtils.ACTION_DESTRUCT.equals(action)) { // Process the action NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.processUndoNotification(this, notificationAction); processDesctructiveNotification(notificationAction); } } } }
From source file:com.andexert.calendarlistview.library.SimpleMonthView.java
public SimpleMonthView(Context context, TypedArray typedArray) { super(context); Resources resources = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); today = new Time(Time.getCurrentTimezone()); today.setToNow();//from www . j a v a2 s . c o m mDayOfWeekTypeface = resources.getString(R.string.sans_serif); mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay, resources.getColor(R.color.to_day)); mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName, resources.getColor(R.color.normal_day)); mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName, resources.getColor(R.color.normal_day)); mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDay, resources.getColor(R.color.normal_day)); mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDay, resources.getColor(R.color.normal_day)); mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background)); mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_text)); mIsShowMonthDay = typedArray.getBoolean(R.styleable.DayPickerView_showMonthDay, true); mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false); mStringBuilder = new StringBuilder(50); MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day)); MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeMonth, resources.getDimensionPixelSize(R.dimen.text_size_month)); MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDayName, resources.getDimensionPixelSize(R.dimen.text_size_day_name)); MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight, resources.getDimensionPixelOffset( mIsShowMonthDay ? R.dimen.header_month_height_showWeek : R.dimen.header_month_height)); DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius)); mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight, resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6); isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, true); initView(); }
From source file:uk.org.openseizuredetector.client.SdClientService.java
/** * onStartCommand - start regular download of status data from the server. *//*from ww w . ja va 2 s . c om*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "SdClientService service starting"); // Update preferences. Log.v(TAG, "calling updatePrefs()"); updatePrefs(); // Display a notification icon in the status bar of the phone to // show the service is running. Log.v(TAG, "showing Notification"); showNotification(); // Start timer to check status of pebble regularly. mStatusTime = new Time(Time.getCurrentTimezone()); mStatusTime.setToNow(); if (statusTimer == null) { Log.v(TAG, "onCreate(): starting status timer"); statusTimer = new Timer(); statusTimer.schedule(new TimerTask() { @Override public void run() { getSdData(); } }, 0, mDataUpdatePeriod); } else { Log.v(TAG, "onCreate(): status timer already running."); } // Apply the wake-lock to prevent CPU sleeping (very battery intensive!) if (mWakeLock != null) { mWakeLock.acquire(); Log.v(TAG, "Applied Wake Lock to prevent device sleeping"); } else { Log.d(TAG, "mmm...mWakeLock is null, so not aquiring lock. This shouldn't happen!"); } return START_STICKY; }
From source file:uk.org.openseizuredetector.SdServer.java
/** * onStartCommand - start the web server and the message loop for * communications with other processes.// ww w . j a v a 2s. c om */ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "onStartCommand() - SdServer service starting"); // Update preferences. Log.v(TAG, "onStartCommand() - calling updatePrefs()"); updatePrefs(); // Display a notification icon in the status bar of the phone to // show the service is running. Log.v(TAG, "showing Notification"); showNotification(); // Record last time we sent an SMS so we can limit rate of SMS // sending to one per minute. mSMSTime = new Time(Time.getCurrentTimezone()); // Start receiving data from the pebble watch startPebbleServer(); // Start timer to check status of pebble regularly. mPebbleStatusTime = new Time(Time.getCurrentTimezone()); //getPebbleStatus(); if (statusTimer == null) { Log.v(TAG, "onCreate(): starting status timer"); statusTimer = new Timer(); statusTimer.schedule(new TimerTask() { @Override public void run() { getPebbleStatus(); } }, 0, 1000); } else { Log.v(TAG, "onCreate(): status timer already running."); } // Start timer to retrieve pebble settings regularly. getPebbleSdSettings(); if (settingsTimer == null) { Log.v(TAG, "onCreate(): starting settings timer"); settingsTimer = new Timer(); settingsTimer.schedule(new TimerTask() { @Override public void run() { getPebbleSdSettings(); } }, 0, 1000 * 60); } else { Log.v(TAG, "onCreate(): settings timer already running."); } // Start timer to log data regularly.. if (dataLogTimer == null) { Log.v(TAG, "onCreate(): starting dataLog timer"); dataLogTimer = new Timer(); dataLogTimer.schedule(new TimerTask() { @Override public void run() { logData(); } }, 0, 1000 * 60); } else { Log.v(TAG, "onCreate(): dataLog timer already running."); } // Start the web server startWebServer(); // Apply the wake-lock to prevent CPU sleeping (very battery intensive!) if (mWakeLock != null) { mWakeLock.acquire(); Log.v(TAG, "Applied Wake Lock to prevent device sleeping"); } else { Log.d(TAG, "mmm...mWakeLock is null, so not aquiring lock. This shouldn't happen!"); } return START_STICKY; }
From source file:com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragmentAdapter.java
@Override public void update(DataClientInterface dataClient, DataConsumerInterface.InsertCallback iCallback) { Pair<OHLC, Time> pricePair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_PRICE_DEF); Pair<Integer, Time> volPair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_VOL_DEF); OHLC price = new OHLC(pricePair.first); int vol = volPair.first.intValue(); Time time = new Time(pricePair.second); /* if we've rolled past TIME_GRANULARITY */ if (_hasSegment.get() && _segHasRolled(_lastGranularSegTime, time, DataClientInterface.TIME_GRANULARITY)) { iCallback.insertRow(//from ww w. j a va 2 s . c om _createContentValues(_lastGranularPriceSeg, _lastGranularVolSeg, _lastGranularSegTime), _symbol, (DataConsumerInterface) this); _lastGranularSegTime = _truncateTime(time, GMS, true, false); /* Log.d("Data-Consumer-Update-DB", _lastGranularSegTime.format("%H:%M:%S") ); */ } _lastGranularPriceSeg = new OHLC(price); _lastGranularVolSeg = vol; if (!_streamReady.get() || _myCursor == null) { _updateTime.set(time); return; } /* Log.d("Data-Consumer-Update-Current", _lastPriceSeg.toString() + " " + String.valueOf(_lastVolSeg) + " " +time.format("%H:%M:%S")); */ if (price.high > _highPrice) { _highPrice = price.high; Intent iii = new Intent(HighLowChange.NEW_HIGH_PRICE); iii.putExtra(HighLowChange.EXTRA_VALUE, price.high); iii.putExtra(HighLowChange.FRAGMENT_ID, MY_ID); _localBcastMngr.sendBroadcast(iii); } if (price.low < _lowPrice) { _lowPrice = price.low; Intent iii = new Intent(HighLowChange.NEW_LOW_PRICE); iii.putExtra(HighLowChange.EXTRA_VALUE, price.low); iii.putExtra(HighLowChange.FRAGMENT_ID, MY_ID); _localBcastMngr.sendBroadcast(iii); } try { /* remember vol is cumm. vis-a-vis the granular seg */ _mainSgmnt.update(_getBucketIndex(price.close), vol); } catch (RuntimeException e) { //DEBUG Log.d("UPDATE EXCEPTION", "::BEGIN:: " + e.getMessage()); e.printStackTrace(); Log.d("UPDATE EXCEPTION", "::END:: " + e.getMessage()); } /* high volume is checked in the panel, where it is agglomerated */ _updateTime.set(time); }
From source file:mad.codeforcommunity.CalendarView.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.monthI: //returns to the current month Time today = new Time(Time.getCurrentTimezone()); Intent intent = new Intent(this, CalendarView.class); intent.putExtra("date", today.year + "-" + today.month + "-" + today.monthDay); startActivityForResult(intent, 1); break;/*from w w w. j a va 2s . com*/ case R.id.dayI: setContentView(findViewById(R.layout.calendar_item)); //returns to the current date loadEventView(findViewById(R.layout.calendar_item)); break; case R.id.createI: //go to webpage to create new event //setContentView(R.layout.create_layout); Intent createInt = new Intent(this, CreateEvent.class); startActivity(createInt); break; case R.id.refreshI: //refresh the calendar refreshCalendar(); break; } return true; }
From source file:uk.org.openseizuredetector.OsdUtil.java
/** * Write data to SD card - writes to data log file unless alarm=true, * in which case writes to alarm log file. *///from ww w . ja va 2s . co m public void writeToLogFile(String fname, String msgStr) { Log.v(TAG, "writeToLogFile(" + fname + "," + msgStr + ")"); //showToast("Logging " + msgStr); Time tnow = new Time(Time.getCurrentTimezone()); tnow.setToNow(); String dateStr = tnow.format("%Y-%m-%d"); fname = fname + "_" + dateStr + ".txt"; // Open output directory on SD Card. if (isExternalStorageWritable()) { try { FileWriter of = new FileWriter(getDataStorageDir().toString() + "/" + fname, true); if (msgStr != null) { String dateTimeStr = tnow.format("%Y-%m-%d %H:%M:%S"); Log.v(TAG, "writing msgStr"); of.append(dateTimeStr + ", " + tnow.toMillis(true) + ", " + msgStr + "<br/>\n"); } of.close(); } catch (Exception ex) { Log.e(TAG, "writeToLogFile - error " + ex.toString()); showToast("ERROR Writing to Log File"); } } else { Log.e(TAG, "ERROR - Can not Write to External Folder"); } }
From source file:com.android.calendar.AllInOneActivity.java
@Override protected void onNewIntent(Intent intent) { String action = intent.getAction(); if (DEBUG)/*from w w w .ja v a 2s.co m*/ Log.d(TAG, "New intent received " + intent.toString()); // Don't change the date if we're just returning to the app's home if (Intent.ACTION_VIEW.equals(action) && !intent.getBooleanExtra(Utils.INTENT_KEY_HOME, false)) { long millis = parseViewAction(intent); if (millis == -1) { millis = Utils.timeFromIntentInMillis(intent); } if (millis != -1 && mViewEventId == -1 && mController != null) { Time time = new Time(mTimeZone); time.set(millis); time.normalize(true); mController.sendEvent(this, EventType.GO_TO, time, time, -1, ViewType.CURRENT); } } }