Java Examples for android.text.format.DateFormat
The following java examples will help you to understand the usage of android.text.format.DateFormat. These source code samples are taken from different open source projects.
Example 1
Project: android-mileage-master File: CsvExportActivity.java View source code |
@Override public String performExport(String inputFile, String outputFile) { try { BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile)); CSVWriter csvWriter = new CSVWriter(writer); // TODO(3.5) - export more than just fillup data Uri uri = FillupsTable.BASE_URI; Cursor fillups = mActivity.getContentResolver().query(uri, FillupsTable.CSV_PROJECTION, null, null, null); final int FILLUP_COUNT = fillups.getCount(); publishProgress(new Update(0, FILLUP_COUNT + 1)); final int COLUMN_COUNT = FillupsTable.CSV_PROJECTION.length; String[] data = new String[COLUMN_COUNT]; // write the column data first for (int i = 0; i < COLUMN_COUNT; i++) { data[i] = mActivity.getString(FillupsTable.PLAINTEXT[i]); } csvWriter.writeNext(data); csvWriter.flush(); publishProgress(new Update(mActivity.getString(R.string.update_wrote_headers), 1)); // figure out what columns are where, for formatting purposes int COLUMN_DATE = -1; for (int i = 0; i < COLUMN_COUNT; i++) { if (FillupsTable.CSV_PROJECTION[i].equals(Fillup.DATE)) { COLUMN_DATE = i; } } final DateFormat DATE_FORMAT = android.text.format.DateFormat.getDateFormat(mActivity); // now write the real data int numWritten = 0; while (fillups.moveToNext()) { for (int i = 0; i < COLUMN_COUNT; i++) { if (i == COLUMN_DATE) { data[i] = DATE_FORMAT.format(new Date(fillups.getLong(i))); } else { data[i] = fillups.getString(i); } } csvWriter.writeNext(data); if (++numWritten % 10 == 0) { sendUpdate(numWritten, FILLUP_COUNT); csvWriter.flush(); } else { publishProgress(new Update(numWritten)); } } sendUpdate(numWritten, FILLUP_COUNT); csvWriter.flush(); csvWriter.close(); fillups.close(); return outputFile; } catch (IOException e) { } return null; }
Example 2
Project: ttr-master File: DateUtils.java View source code |
/** * Returns the formatted date and time in the format specified by Controller.dateString() and * Controller.timeString() or if settings indicate the systems configuration should be used it returns the date and * time formatted as specified by the system. * * @param context the application context * @param date the date to be formatted * @return a formatted representation of the date and time */ public static String getDateTime(Context context, Date date) { if (Controller.getInstance().dateTimeSystem()) { java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); return dateFormat.format(date) + " " + timeFormat.format(date); } else { try { // Only display delimiter if both formats are available, if the user did set one to an empty string he // doesn't want to see this information and we can hide the delimiter too. String dateStr = Controller.getInstance().dateString(); String timeStr = Controller.getInstance().timeString(); String delimiter = (dateStr.length() > 0 && timeStr.length() > 0) ? " " : ""; String formatted = dateStr + delimiter + timeStr; return android.text.format.DateFormat.format(formatted, date).toString(); } catch (Exception e) { java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); return dateFormat.format(date) + " " + timeFormat.format(date); } } }
Example 3
Project: ttrss-reader-fork-master File: DateUtils.java View source code |
/** * Returns the formatted date and time in the format specified by Controller.dateString() and * Controller.timeString() or if settings indicate the systems configuration should be used it returns the date and * time formatted as specified by the system. * * @param context the application context * @param date the date to be formatted * @return a formatted representation of the date and time */ public static String getDateTime(Context context, Date date) { if (Controller.getInstance().dateTimeSystem()) { java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); return dateFormat.format(date) + " " + timeFormat.format(date); } else { try { // Only display delimiter if both formats are available, if the user did set one to an empty string he // doesn't want to see this information and we can hide the delimiter too. String dateStr = Controller.getInstance().dateString(); String timeStr = Controller.getInstance().timeString(); String delimiter = (dateStr.length() > 0 && timeStr.length() > 0) ? " " : ""; String formatted = dateStr + delimiter + timeStr; return android.text.format.DateFormat.format(formatted, date).toString(); } catch (Exception e) { java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); return dateFormat.format(date) + " " + timeFormat.format(date); } } }
Example 4
Project: CalendarWidget-master File: DayOfWeekHelper.java View source code |
public static List<String> getDayOfWeek(int weekStartDay) {
Calendar cal = Calendar.getInstance();
// September 7th, 2013 is a Saturday.
// Calendar.SUNDAY = 1, MONDAY = 2, and so forth.
cal.set(2013, Calendar.SEPTEMBER, 7 + weekStartDay, 0, 0, 0);
ArrayList<String> list = new ArrayList<String>(7);
for (int i = 0; i < 7; i++) {
list.add(DateFormat.format("E", cal).toString());
cal.add(Calendar.DATE, 1);
}
return list;
}
Example 5
Project: DroidSweeper-master File: HighScoreListAdapter.java View source code |
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout view;
if (convertView != null) {
view = (LinearLayout) convertView;
} else {
view = (LinearLayout) mLayoutInflater.inflate(R.layout.layout_timelist_item, parent, false);
}
// TODO: Remove redundant Position item!
((TextView) view.findViewById(R.id.tvTimeListItem_Position)).setText(String.valueOf(position + 1));
((TextView) view.findViewById(R.id.tvTimeListItem_Name)).setText(mEntries.get(position).NAME);
((TextView) view.findViewById(R.id.tvTimeListItem_Time)).setText(DateFormat.format("mm:ss", mEntries.get(position).PLAYTIME).toString());
// Localize epoch time and display date and time
Date date = new Date(mEntries.get(position).EPOCHTIME);
((TextView) view.findViewById(R.id.tvTimeListItem_Date)).setText(mDateFormat.format(date) + " " + mTimeFormat.format(date));
return view;
}
Example 6
Project: MoneyTracker-master File: Formatter.java View source code |
public static String format(Date date) { Calendar cal = Calendar.getInstance(); int todayDate = cal.get(Calendar.DAY_OF_YEAR); int todayYear = cal.get(Calendar.YEAR); cal.setTime(date); int testDate = cal.get(Calendar.DAY_OF_YEAR); int testYear = cal.get(Calendar.YEAR); String text = null; if (todayYear == testYear) { if (todayDate == testDate) { text = "Today at"; } else if (todayDate - 1 == testDate) { text = "Yesterday at"; } } if (null == text) { text = DateFormat.format("MMMM dd, yyy", date).toString(); } return text + " " + DateFormat.format("kk:mm", date).toString(); }
Example 7
Project: QMBForm-master File: FormTimeInlineFieldCell.java View source code |
@SuppressWarnings("deprecation")
@Override
protected void initDatePicker(Calendar calendar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mTimePicker.setHour(calendar.get(Calendar.HOUR_OF_DAY));
mTimePicker.setMinute(calendar.get(Calendar.MINUTE));
} else {
mTimePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
mTimePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
}
mTimePicker.setOnTimeChangedListener(this);
if (DateFormat.is24HourFormat(getContext()))
mTimePicker.setIs24HourView(true);
}
Example 8
Project: RadioRake-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), (AddNewScheduledRecordingActivity) getActivity(), hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 9
Project: Overchan-Android-master File: AndroidDateFormat.java View source code |
public static void initPattern() { if (pattern != null) return; DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(MainApplication.getInstance()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(MainApplication.getInstance()); if (dateFormat instanceof SimpleDateFormat && timeFormat instanceof SimpleDateFormat) { pattern = ((SimpleDateFormat) dateFormat).toPattern() + " " + ((SimpleDateFormat) timeFormat).toPattern(); } }
Example 10
Project: glucosio-android-master File: FormatDateTime.java View source code |
public String convertDateTime(String date) { //TODO use joda.time DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat finalDataFormat = DateFormat.getDateInstance(DateFormat.SHORT); DateFormat finalTimeFormat; if (android.text.format.DateFormat.is24HourFormat(context)) { finalTimeFormat = new SimpleDateFormat("HH:mm"); } else { finalTimeFormat = new SimpleDateFormat("hh:mm a"); } Date parsed = null; try { parsed = inputFormat.parse(date); } catch (ParseException e) { reportToFirebase(e); e.printStackTrace(); } String finalData = finalDataFormat.format(parsed); String finalTime = finalTimeFormat.format(parsed); return finalData + " " + finalTime; }
Example 11
Project: MinecraftClock-master File: Watch.java View source code |
/**
* Selects either one of {@link #getFormat12Hour()} or {@link #getFormat24Hour()}
* depending on whether the user has selected 24-hour format.
*
* @param handleTicker true if calling this method should schedule/unschedule the
* time ticker, false otherwise
*/
private void chooseFormat(boolean handleTicker) {
final boolean format24Requested = is24HourModeEnabled();
if (format24Requested) {
mFormat = abc(mFormat24, mFormat12, DEFAULT_FORMAT_12_HOUR);
} else {
mFormat = abc(mFormat12, mFormat24, DEFAULT_FORMAT_24_HOUR);
}
boolean hadSeconds = mHasSeconds;
mHasSeconds = !TextUtils.isEmpty(mFormat) ? mFormat.toString().contains(String.valueOf(DateFormat.SECONDS)) : false;
if (hasWatchface()) {
if (handleTicker && mAttached && hadSeconds != mHasSeconds) {
if (hadSeconds)
getWatchface().getHandler().removeCallbacks(mTicker);
else
mTicker.run();
}
}
}
Example 12
Project: aceim-master File: TimePickerListener.java View source code |
@Override
protected AlertDialog createDialog(final Calendar cal) {
OnTimeSetListener callback = new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
cal.set(Calendar.MINUTE, minute);
listener.onValuePicked(String.valueOf(cal.getTimeInMillis()));
}
};
TimePickerDialog dialog = new TimePickerDialog(activity, callback, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), android.text.format.DateFormat.is24HourFormat(activity));
return dialog;
}
Example 13
Project: android-development-course-master File: NetworkClient.java View source code |
private JSONObject createUser(int userId) {
try {
JSONObject json = new JSONObject();
json.put("id", userId);
json.put("name", "user_" + userId);
if (rand.nextBoolean()) {
json.put("age", rand.nextInt(100));
}
if (rand.nextBoolean()) {
json.put("keyword", "keyword_" + userId);
}
Calendar cal = getPastedTime(-1 * rand.nextInt(3650));
JSONObject joinDate = new JSONObject();
joinDate.put("year", cal.get(Calendar.YEAR));
joinDate.put("month", cal.get(Calendar.MONTH) + 1);
joinDate.put("date", cal.get(Calendar.DATE));
json.put("joinDate", joinDate);
CharSequence postedTime = DateFormat.format("yyyy-MM-dd hh:mm:ss", getPastedTime(-1 * rand.nextInt(100)));
JSONObject status = new JSONObject();
status.put("postedTime", postedTime);
status.put("text", "��や��");
json.put("status", status);
return json;
} catch (JSONException e) {
return null;
}
}
Example 14
Project: android-sdk-demos-master File: AnytimeUserResponseListAdapter.java View source code |
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(R.layout.view_user_response, null);
TextView response = (TextView) convertView.findViewById(R.id.textView_user_response);
TextView responseTime = (TextView) convertView.findViewById(R.id.textView_user_response_time);
response.setText(mResponseList.get(position).getString("UserSuggestion"));
responseTime.setText(DateFormat.format("yyyy-MM-dd HH:mm", mResponseList.get(position).getCreatedAt()).toString());
if (mResponseList.get(position).getBoolean("IsResponseToUser")) {
response.setTextColor(this.mContext.getResources().getColor(R.color.BlueColor));
responseTime.setTextColor(this.mContext.getResources().getColor(R.color.BlueColor));
}
return convertView;
}
Example 15
Project: AndroidTraining-master File: NetworkClient.java View source code |
private JSONObject createUser(int userId) {
try {
JSONObject json = new JSONObject();
json.put("id", userId);
json.put("name", "user_" + userId);
if (rand.nextBoolean()) {
json.put("age", rand.nextInt(100));
}
if (rand.nextBoolean()) {
json.put("keyword", "keyword_" + userId);
}
Calendar cal = getPastedTime(-1 * rand.nextInt(3650));
JSONObject joinDate = new JSONObject();
joinDate.put("year", cal.get(Calendar.YEAR));
joinDate.put("month", cal.get(Calendar.MONTH) + 1);
joinDate.put("date", cal.get(Calendar.DATE));
json.put("joinDate", joinDate);
CharSequence postedTime = DateFormat.format("yyyy-MM-dd hh:mm:ss", getPastedTime(-1 * rand.nextInt(100)));
JSONObject status = new JSONObject();
status.put("postedTime", postedTime);
status.put("text", "��や��");
json.put("status", status);
return json;
} catch (JSONException e) {
return null;
}
}
Example 16
Project: AnyTime-master File: AnytimeUserResponseListAdapter.java View source code |
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(R.layout.view_user_response, null);
TextView response = (TextView) convertView.findViewById(R.id.textView_user_response);
TextView responseTime = (TextView) convertView.findViewById(R.id.textView_user_response_time);
response.setText(mResponseList.get(position).getString("UserSuggestion"));
responseTime.setText(DateFormat.format("yyyy-MM-dd HH:mm", mResponseList.get(position).getCreatedAt()).toString());
if (mResponseList.get(position).getBoolean("IsResponseToUser")) {
response.setTextColor(this.mContext.getResources().getColor(R.color.BlueColor));
responseTime.setTextColor(this.mContext.getResources().getColor(R.color.BlueColor));
}
return convertView;
}
Example 17
Project: Bluetooth-LE-Library---Android-master File: CommonBinding.java View source code |
public static void bind(final Context context, final CommonDeviceHolder holder, final BluetoothLeDevice device) {
final String deviceName = device.getName();
final double rssi = device.getRssi();
if (deviceName != null && deviceName.length() > 0) {
holder.getDeviceName().setText(deviceName);
} else {
holder.getDeviceName().setText(R.string.unknown_device);
}
final String rssiString = context.getString(R.string.formatter_db, String.valueOf(rssi));
final String runningAverageRssiString = context.getString(R.string.formatter_db, String.valueOf(device.getRunningAverageRssi()));
holder.getDeviceLastUpdated().setText(android.text.format.DateFormat.format(Constants.TIME_FORMAT, new java.util.Date(device.getTimestamp())));
holder.getDeviceAddress().setText(device.getAddress());
holder.getDeviceRssi().setText(rssiString + " / " + runningAverageRssiString);
}
Example 18
Project: CloudEndpointTest-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 19
Project: Gathr-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 20
Project: transitwidget-master File: WakeupReceiver.java View source code |
@Override
public void onReceive(Context ctx, Intent intent) {
Log.i(TAG, "onReceive: " + intent.getAction());
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ctx);
int[] widgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(ctx, PredictionWidgetProvider.class));
for (int widgetId : widgetIds) {
NextBusObserverConfig config = new NextBusObserverConfig(ctx, widgetId);
Log.i(TAG, "Reset alarm for widget " + widgetId + " to " + DateFormat.format("h:mmaa", TimeUtils.getCalendarWithTimeFromMidnight(config.getStartObserving())));
Intent serviceIntent = new Intent(ctx, AlarmSchedulerService.class);
serviceIntent.putExtra(AlarmSchedulerService.EXTRA_WIDGET_ID, widgetId);
serviceIntent.putExtra(AlarmSchedulerService.EXTRA_DAY_START_TIME, config.getStartObserving());
ctx.startService(serviceIntent);
}
}
Example 21
Project: wearzaim-master File: PostPaymentService.java View source code |
private void execute(String payment) {
final OAuthRequest request = new OAuthRequest(Verb.POST, getString(R.string.payment));
request.addBodyParameter("category_id", "101");
request.addBodyParameter("genre_id", "10101");
request.addBodyParameter("amount", payment);
String date = DateFormat.format("'yyyy'-'MM'-'dd'", Calendar.getInstance()).toString();
request.addBodyParameter("date", date);
request.addBodyParameter("from_account_id", "1");
final Token accessToken = ZaimUtils.getAccessToken(getApplicationContext());
final OAuthService service = ZaimUtils.getOauthService(getApplicationContext());
service.signRequest(accessToken, request);
request.send();
}
Example 22
Project: Broadband-Usage-master File: CustomDigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 23
Project: cos598b-master File: DateFormatter.java View source code |
public static DateFormat getDateFormat(Context context, String formatString) { java.text.DateFormat dateFormat; if (SHORT_FORMAT.equals(formatString)) { dateFormat = android.text.format.DateFormat.getDateFormat(context); } else if (MEDIUM_FORMAT.equals(formatString)) { dateFormat = android.text.format.DateFormat.getMediumDateFormat(context); } else { Map<String, DateFormat> formatMap = storedFormats.get(); dateFormat = formatMap.get(formatString); if (dateFormat == null) { dateFormat = new SimpleDateFormat(formatString); formatMap.put(formatString, dateFormat); } } return dateFormat; }
Example 24
Project: k9mail-master File: DateFormatter.java View source code |
public static DateFormat getDateFormat(Context context, String formatString) { java.text.DateFormat dateFormat; if (SHORT_FORMAT.equals(formatString)) { dateFormat = android.text.format.DateFormat.getDateFormat(context); } else if (MEDIUM_FORMAT.equals(formatString)) { dateFormat = android.text.format.DateFormat.getMediumDateFormat(context); } else { Map<String, DateFormat> formatMap = storedFormats.get(); dateFormat = formatMap.get(formatString); if (dateFormat == null) { dateFormat = new SimpleDateFormat(formatString); formatMap.put(formatString, dateFormat); } } return dateFormat; }
Example 25
Project: konkamusic-master File: KkDigitalClock.java View source code |
@Override
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 26
Project: Osmand-master File: AudioVideoNoteMenuBuilder.java View source code |
@Override public void buildInternal(View view) { File file = recording.getFile(); if (file != null) { DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext()); Date date = new Date(recording.getFile().lastModified()); buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null); buildPlainMenuItems(view); if (recording.isPhoto()) { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inSampleSize = 4; int rot = recording.getBitmapRotation(); Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath(), opts); if (rot != 0) { Matrix matrix = new Matrix(); matrix.postRotate(rot); Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); bmp.recycle(); bmp = resizedBitmap; } buildImageRow(view, bmp, new OnClickListener() { @Override public void onClick(View v) { Intent vint = new Intent(Intent.ACTION_VIEW); vint.setDataAndType(Uri.fromFile(recording.getFile()), "image/*"); vint.setFlags(0x10000000); v.getContext().startActivity(vint); } }); } } else { buildPlainMenuItems(view); } }
Example 27
Project: safeconnect-master File: DateProvider.java View source code |
public static String getFormattedDate(Context context, long timestamp) { if (timestamp == 0) { return "-"; } DateFormat df = android.text.format.DateFormat.getDateFormat(context); DateFormat tf = android.text.format.DateFormat.getTimeFormat(context); Date date = new Date(timestamp * 1000); Date now = new Date(); //this hour -> xx mins ago if (date.getTime() >= (now.getTime() - (60 * 60 * 1000))) { int minutes = (int) ((now.getTime() - date.getTime()) / 1000 / 60); return (minutes != 1 ? String.format(context.getString(R.string.pref_summ_minutes_ago), minutes) : String.format(context.getString(R.string.pref_summ_1_minute_ago), minutes)); } //today --> today, 17:03 if (DateUtils.isToday(date.getTime())) { return String.format(context.getString(R.string.pref_summ_today), tf.format(date)); } //day, time return String.format(context.getString(R.string.pref_summ_date), df.format(date), tf.format(date)); }
Example 28
Project: sodacloud-master File: ReportsAdapter.java View source code |
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View reportView = inflater.inflate(R.layout.report_item_view, parent, false); if (mReports != null) { MaintenanceReport report = mReports.get(position); TextView title = (TextView) reportView.findViewById(R.id.textViewReportTitle); title.setText(report.getTitle()); TextView content = (TextView) reportView.findViewById(R.id.textViewReportContent); content.setText(report.getContents()); TextView location = (TextView) reportView.findViewById(R.id.textViewReportLocation); //This should be location. Using date because maintenance report doesn't apparently doesn't have a location attribute Date date = report.getCreateTime_(); if (date != null) { java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(mContext); location.setText(dateFormat.format(date)); } ImageView image = (ImageView) reportView.findViewById(R.id.imageViewReportImage); if (report.getImageData() != null) { Bitmap imageBitmap = BitmapFactory.decodeByteArray(report.getImageData(), 0, report.getImageData().length); if (imageBitmap != null) { image.setImageBitmap(imageBitmap); } } } return reportView; }
Example 29
Project: CalendarView-master File: CalendarView.java View source code |
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
TextView date = (TextView) v.findViewById(R.id.date);
if (date instanceof TextView && !date.getText().equals("")) {
Intent intent = new Intent();
String day = date.getText().toString();
if (day.length() == 1) {
day = "0" + day;
}
// return chosen date as string format
intent.putExtra("date", android.text.format.DateFormat.format("yyyy-MM", month) + "-" + day);
setResult(RESULT_OK, intent);
finish();
}
}
Example 30
Project: meetup-client-master File: NetworkTransactionsAdapter.java View source code |
public final void bindView(View view, Context context, Cursor cursor) {
Resources resources;
int i;
Object aobj[];
String s;
String s1;
TextView textview = (TextView) view.findViewById(R.id.transaction_time);
long l = cursor.getLong(2);
textview.setText((new StringBuilder()).append(DateFormat.format("MM-dd hh:mm:ss", new Date(l))).append(".").append(l % 1000L).toString());
((TextView) view.findViewById(R.id.transaction_name)).setText(cursor.getString(1));
ImageView imageview = (ImageView) view.findViewById(0x1020006);
TextView textview1 = (TextView) view.findViewById(R.id.transaction_bytes);
if (cursor.isNull(8)) {
imageview.setImageResource(R.drawable.indicator_green);
int j = cursor.getInt(7);
if (j <= 1) {
Resources resources2 = context.getResources();
int i1 = R.string.network_transaction_one_bytes;
Object aobj2[] = new Object[2];
aobj2[0] = Long.valueOf(cursor.getLong(3));
aobj2[1] = Long.valueOf(cursor.getLong(4));
s1 = resources2.getString(i1, aobj2);
} else {
Resources resources1 = context.getResources();
int k = R.string.network_transaction_many_bytes;
Object aobj1[] = new Object[3];
aobj1[0] = Long.valueOf(cursor.getLong(3));
aobj1[1] = Long.valueOf(cursor.getLong(4));
aobj1[2] = Integer.valueOf(j);
s1 = resources1.getString(k, aobj1);
}
textview1.setText(s1.toString());
} else {
imageview.setImageResource(R.drawable.indicator_red);
textview1.setText(cursor.getString(8));
}
resources = context.getResources();
i = R.string.network_transaction_duration;
aobj = new Object[1];
aobj[0] = Long.valueOf(cursor.getLong(5));
s = resources.getString(i, aobj);
((TextView) view.findViewById(R.id.transaction_duration)).setText(s.toString());
}
Example 31
Project: sofia-core-master File: DatePropertyEditor.java View source code |
// ---------------------------------------------------------- @Override public View createEditor(Context context) { dateFormat = android.text.format.DateFormat.getMediumDateFormat(context); timeFormat = android.text.format.DateFormat.getTimeFormat(context); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); dateButton = new Button(context); dateButton.setGravity(Gravity.CENTER); dateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { displayDatePicker(view.getContext()); } }); timeButton = new Button(context); timeButton.setGravity(Gravity.CENTER); timeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { displayTimePicker(view.getContext()); } }); LinearLayout.LayoutParams lp3 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 3); layout.addView(dateButton, lp3); layout.addView(timeButton, lp1); return layout; }
Example 32
Project: android-15-master File: WebkitTest.java View source code |
@MediumTest
public void testDateSorter() throws Exception {
/**
* Note: check the logging output manually to test
* nothing automated yet, besides object creation
*/
DateSorter dateSorter = new DateSorter(mContext);
Date date = new Date();
for (int i = 0; i < DateSorter.DAY_COUNT; i++) {
Log.i(LOGTAG, "Boundary " + i + " " + dateSorter.getBoundary(i));
Log.i(LOGTAG, "Label " + i + " " + dateSorter.getLabel(i));
}
Calendar c = Calendar.getInstance();
long time = c.getTimeInMillis();
int index;
Log.i(LOGTAG, "now: " + dateSorter.getIndex(time));
for (int i = 0; i < 20; i++) {
// 8 hours
time -= 8 * 60 * 60 * 1000;
date.setTime(time);
c.setTime(date);
index = dateSorter.getIndex(time);
Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() + " " + index + " " + dateSorter.getLabel(index));
}
}
Example 33
Project: android-imf-ext-master File: DigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 34
Project: buddydroid-master File: MessageListAdapter.java View source code |
@Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = activity.getLayoutInflater(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); // Inflate the views from XML View rowView = inflater.inflate(R.layout.message_item, null); final HashMap<?, ?> entryMap = (HashMap<?, ?>) getItem(position); TextView titleView = (TextView) rowView.findViewById(R.id.sender); TextView subjectView = (TextView) rowView.findViewById(R.id.subject); TextView textView = (TextView) rowView.findViewById(R.id.text); TextView dateView = (TextView) rowView.findViewById(R.id.date); try { String text = sanitizeText((String) entryMap.get("message")); String title = sanitizeText((String) entryMap.get("from")); String subject = sanitizeText((String) entryMap.get("subject")); String dates = (String) entryMap.get("date_sent"); int unread = Integer.parseInt((String) entryMap.get("unread_count")); //Log.d(TAG,title+" "+subject+" "); // add text textView.setText(text); // add sender to title titleView.setText(title); // add subject to subtitle subjectView.setText(subject); // add date //2013-03-11 20:32:01 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = simpleDateFormat.parse(dates); if (prefs.getBoolean("relative_date", true)) { CharSequence dateString = DateUtils.getRelativeTimeSpanString(date.getTime(), new Date().getTime(), DateUtils.SECOND_IN_MILLIS); dateView.setText(dateString); } else { // check if today or not Calendar now = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); DateFormat df; if (now.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && now.get(Calendar.MONTH) == calendar.get(Calendar.MONTH) && now.get(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH)) df = android.text.format.DateFormat.getTimeFormat(activity); else df = android.text.format.DateFormat.getMediumDateFormat(activity); dateView.setText(df.format(date)); } if (unread == 0) rowView.setBackgroundColor(0xFFEEEEEE); } catch (Exception e) { e.printStackTrace(); } return rowView; }
Example 35
Project: folio100_frameworks_base-master File: DigitalClock.java View source code |
private void updateTime() {
if (mLive) {
mCalendar.setTimeInMillis(System.currentTimeMillis());
}
PowerManager Pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
if (Pm.isScreenOn()) {
CharSequence newTime = DateFormat.format(mFormat, mCalendar);
mTimeDisplay.setText(newTime);
mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
}
}
Example 36
Project: frameworks_base_disabled-master File: WebkitTest.java View source code |
@MediumTest
public void testDateSorter() throws Exception {
/**
* Note: check the logging output manually to test
* nothing automated yet, besides object creation
*/
DateSorter dateSorter = new DateSorter(mContext);
Date date = new Date();
for (int i = 0; i < DateSorter.DAY_COUNT; i++) {
Log.i(LOGTAG, "Boundary " + i + " " + dateSorter.getBoundary(i));
Log.i(LOGTAG, "Label " + i + " " + dateSorter.getLabel(i));
}
Calendar c = Calendar.getInstance();
long time = c.getTimeInMillis();
int index;
Log.i(LOGTAG, "now: " + dateSorter.getIndex(time));
for (int i = 0; i < 20; i++) {
// 8 hours
time -= 8 * 60 * 60 * 1000;
date.setTime(time);
c.setTime(date);
index = dateSorter.getIndex(time);
Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() + " " + index + " " + dateSorter.getLabel(index));
}
}
Example 37
Project: GlowNotifier-master File: DigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 38
Project: open-bixi-gpstracker-master File: DateView.java View source code |
/* * (non-Javadoc) * @see android.widget.TextView#setText(java.lang.CharSequence, android.widget.TextView.BufferType) */ @Override public void setText(CharSequence charSeq, BufferType type) { // Behavior for the graphical editor if (this.isInEditMode()) { super.setText(charSeq, type); return; } long longVal; if (charSeq.length() == 0) { longVal = 0l; } else { try { longVal = Long.parseLong(charSeq.toString()); } catch (NumberFormatException e) { longVal = 0l; } } this.mDate = new Date(longVal); DateFormat dateFormat = android.text.format.DateFormat.getLongDateFormat(this.getContext().getApplicationContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(this.getContext().getApplicationContext()); String text = timeFormat.format(this.mDate) + " " + dateFormat.format(mDate); super.setText(text, type); }
Example 39
Project: property-db-master File: WebkitTest.java View source code |
@MediumTest
public void testDateSorter() throws Exception {
/**
* Note: check the logging output manually to test
* nothing automated yet, besides object creation
*/
DateSorter dateSorter = new DateSorter(mContext);
Date date = new Date();
for (int i = 0; i < DateSorter.DAY_COUNT; i++) {
Log.i(LOGTAG, "Boundary " + i + " " + dateSorter.getBoundary(i));
Log.i(LOGTAG, "Label " + i + " " + dateSorter.getLabel(i));
}
Calendar c = Calendar.getInstance();
long time = c.getTimeInMillis();
int index;
Log.i(LOGTAG, "now: " + dateSorter.getIndex(time));
for (int i = 0; i < 20; i++) {
// 8 hours
time -= 8 * 60 * 60 * 1000;
date.setTime(time);
c.setTime(date);
index = dateSorter.getIndex(time);
Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() + " " + index + " " + dateSorter.getLabel(index));
}
}
Example 40
Project: Stiri-din-Android-master File: NewsItem.java View source code |
public String getPubDateAsString(Context context) { if (this.pubDate == 0) { return ""; } Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.setTimeInMillis(this.pubDate); Date articleDate = calendar.getTime(); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); DateFormat dateFormat = android.text.format.DateFormat.getLongDateFormat(context); return dateFormat.format(articleDate) + " " + timeFormat.format(articleDate); }
Example 41
Project: WS171-frameworks-base-master File: WebkitTest.java View source code |
@MediumTest
public void testDateSorter() throws Exception {
/**
* Note: check the logging output manually to test
* nothing automated yet, besides object creation
*/
DateSorter dateSorter = new DateSorter(mContext);
Date date = new Date();
for (int i = 0; i < DateSorter.DAY_COUNT; i++) {
Log.i(LOGTAG, "Boundary " + i + " " + dateSorter.getBoundary(i));
Log.i(LOGTAG, "Label " + i + " " + dateSorter.getLabel(i));
}
Calendar c = Calendar.getInstance();
long time = c.getTimeInMillis();
int index;
Log.i(LOGTAG, "now: " + dateSorter.getIndex(time));
for (int i = 0; i < 20; i++) {
// 8 hours
time -= 8 * 60 * 60 * 1000;
date.setTime(time);
c.setTime(date);
index = dateSorter.getIndex(time);
Log.i(LOGTAG, "time: " + DateFormat.format("yyyy/MM/dd kk:mm:ss", c).toString() + " " + index + " " + dateSorter.getLabel(index));
}
}
Example 42
Project: XobotOS-master File: DigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 43
Project: Android-Cookbook-Examples-master File: MainActivity.java View source code |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView textView1 = (TextView) findViewById(R.id.textview1); TextView textView2 = (TextView) findViewById(R.id.textview2); TextView textView3 = (TextView) findViewById(R.id.textview3); TextView textView4 = (TextView) findViewById(R.id.textview4); TextView textView5 = (TextView) findViewById(R.id.textview5); // 09/21/2011 02:17 pm String delegate = "MM/dd/yy hh:mm a"; Date noteTS = new Date(); textView1.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); // Sep 21,2011 02:17 pm delegate = "MMM dd, yyyy h:mm aa"; textView2.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); //September 21,2011 02:17pm delegate = "MMMM dd, yyyy h:mmaa"; textView3.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); //Wed, September 21,2011 02:17:48 pm delegate = "E, MMMM dd, yyyy h:mm:ss aa"; textView4.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); delegate = //Wednesday, September 21,2011 02:17:48 pm "EEEE, MMMM dd, yyyy h:mm aa"; textView5.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); }
Example 44
Project: androidbible-master File: ReminderTimePreference.java View source code |
@Override
protected void onClick() {
super.onClick();
String currentValue = getPersistedString(null);
final int hour = currentValue == null ? 12 : Integer.parseInt(currentValue.substring(0, 2));
final int minute = currentValue == null ? 0 : Integer.parseInt(currentValue.substring(2, 4));
final Context context = getContext();
HackedTimePickerDialog dialog = new HackedTimePickerDialog(context, getTitle(), context.getString(R.string.dr_timepicker_set), context.getString(R.string.dr_timepicker_off), new HackedTimePickerDialog.HackedTimePickerListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
persistString(String.format(Locale.US, "%02d%02d", hourOfDay, minute));
notifyChanged();
}
@Override
public void onTimeOff(TimePicker view) {
persistString(null);
notifyChanged();
}
}, hour, minute, DateFormat.is24HourFormat(context));
dialog.show();
}
Example 45
Project: AppCompat-Extension-Library-master File: DateFormatUtils.java View source code |
public static String getBestDateTimePattern(Locale locale, String skeleton) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
return DateFormat.getBestDateTimePattern(locale, skeleton);
} else {
// Try to improve the skeleton on older devices
if (skeleton.equals("EMMMd"))
return "E, MMM d";
if (skeleton.equals("MMMMy"))
return "MMMM yyyy";
if (skeleton.equals("Hm"))
return "H:m";
if (skeleton.equals("hm"))
return "h:m";
return skeleton;
}
}
Example 46
Project: apps-android-wikipedia-master File: DateUtil.java View source code |
public static String getFeedCardDateString(@NonNull Date date) { // todo: consider allowing TWN date formats. It would be useful to have but might be // difficult for translators to write correct format specifiers without being able to // test them. We should investigate localization support in date libraries such as // Joda-Time and how TWN solves this classic problem. DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(WikipediaApp.getInstance()); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(date); }
Example 47
Project: arduino-android-master File: InputController.java View source code |
public void handleGeigerMessage(char flag, int reading) {
Log.d("SRM", "setTemp " + reading);
if (flag == 'E') {
mRadiationImage.setVisibility(ImageView.VISIBLE);
mp.start();
} else if (flag == 'R') {
mRadiationImage.setVisibility(ImageView.INVISIBLE);
mTemperature.setText("" + reading);
} else if (flag == 'L') {
String logText = mLogView.getText().toString();
String timeFormatted = (String) DateFormat.format("hh:mm", new Date());
mLogView.setText(logText + "\n" + timeFormatted + "\t\t\t" + reading);
}
}
Example 48
Project: Attendance-Taker-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
dateBackListener = (DateBackListener) getActivity();
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 49
Project: auto-wol-master File: TimePickerFragment.java View source code |
/* (non-Javadoc)
* @see android.app.DialogFragment#onCreateDialog(android.os.Bundle)
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mCallback = (OnTimePickedListener) getActivity();
Bundle bundle = this.getArguments();
mLayoutId = bundle.getInt("layoutId");
int hour = bundle.getInt("hour");
int minute = bundle.getInt("minute");
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 50
Project: buyingtime-android-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle args = getArguments();
final Calendar c = Calendar.getInstance();
//The second input is a default value in case hour or minute are empty
int hour = args.getInt("hour", c.get(Calendar.HOUR_OF_DAY));
int minute = args.getInt("minute", c.get(Calendar.MINUTE));
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 51
Project: Cadar-master File: WeekHolder.java View source code |
@Override public void run() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(title.getContext().getString(R.string.calendar_week)); stringBuilder.append(" "); stringBuilder.append(period.first.get(Calendar.WEEK_OF_YEAR)); stringBuilder.append(", "); stringBuilder.append(DateFormat.format(DATE_FORMAT, period.first)); stringBuilder.append(" - "); stringBuilder.append(DateFormat.format(DATE_FORMAT, period.second)); final Spannable date = new SpannableString(stringBuilder.toString()); uiHandler.post(new Runnable() { @Override public void run() { title.setText(date); } }); }
Example 52
Project: cgeo-master File: TimeDialog.java View source code |
@Override
@NonNull
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Bundle args = getArguments();
date = (Calendar) args.getSerializable("date");
final int hour = date.get(Calendar.HOUR_OF_DAY);
final int minute = date.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 53
Project: ComicBook-master File: TimePickerDialogFragment.java View source code |
/*package*/ static Dialog createDialog(Bundle args, Context activityContext, @Nullable OnTimeSetListener onTimeSetListener) { final Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); boolean is24hour = DateFormat.is24HourFormat(activityContext); if (args != null) { hour = args.getInt(TimePickerDialogModule.ARG_HOUR, now.get(Calendar.HOUR_OF_DAY)); minute = args.getInt(TimePickerDialogModule.ARG_MINUTE, now.get(Calendar.MINUTE)); is24hour = args.getBoolean(TimePickerDialogModule.ARG_IS24HOUR, DateFormat.is24HourFormat(activityContext)); } return new DismissableTimePickerDialog(activityContext, onTimeSetListener, hour, minute, is24hour); }
Example 54
Project: DeviceConnect-Android-master File: ResultDetailsFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_result_details, container, false);
Bundle bundle = getArguments();
if (bundle == null) {
return view;
}
ResultData.ResultAdapter adapter = ResultData.INSTANCE.getAdapter(view.getContext());
ResultData.Result result = adapter.getItem((int) bundle.getLong("id"));
TextView textFrom = (TextView) view.findViewById(R.id.textResultFrom);
TextView textChannel = (TextView) view.findViewById(R.id.textResultChannel);
TextView textDate = (TextView) view.findViewById(R.id.textResultDate);
TextView textText = (TextView) view.findViewById(R.id.textResultText);
TextView textServiceId = (TextView) view.findViewById(R.id.textResultServiceId);
TextView textPath = (TextView) view.findViewById(R.id.textResultPath);
TextView textData = (TextView) view.findViewById(R.id.textResultData);
TextView textResult = (TextView) view.findViewById(R.id.textResultResult);
textFrom.setText(result.from);
textChannel.setText(result.channel);
textDate.setText(DateFormat.format("yyyy/MM/dd kk:mm:ss", result.date));
textText.setText(result.text);
textServiceId.setText(result.data.serviceId);
textPath.setText(result.data.path);
textData.setText(result.data.body);
textResult.setText(result.response);
return view;
}
Example 55
Project: dropbox-android-sync-sdk-master File: FolderAdapter.java View source code |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(android.R.layout.simple_list_item_activated_2, parent, false); } DbxFileInfo info = mEntries.get(position); TextView text = (TextView) convertView.findViewById(android.R.id.text1); text.setText(getName(info)); TextView text2 = (TextView) convertView.findViewById(android.R.id.text2); if (info.isFolder) { text2.setText(R.string.status_folder); text.setEnabled(false); text2.setEnabled(false); } else { String modDate = DateFormat.getMediumDateFormat(mContext).format(info.modifiedTime) + " " + DateFormat.getTimeFormat(mContext).format(info.modifiedTime); text2.setText(modDate); text.setEnabled(true); text2.setEnabled(true); } return convertView; }
Example 56
Project: drum-machine.audio-master File: FileItem.java View source code |
public String dateTimeToString(Long timeStamp, String title) { if (timeStamp == null || DrumCloud.X == null) return ""; else { Date jDate = new Date(timeStamp); java.text.DateFormat df = DateFormat.getDateFormat(DrumCloud.X); String date = df.format(jDate); df = DateFormat.getTimeFormat(DrumCloud.X); String time = df.format(jDate); return title + ": " + date + " - " + time; } }
Example 57
Project: enviroCar-app-master File: DateUtils.java View source code |
public static String getDateString(Context context, long date) { Calendar now = Calendar.getInstance(); now.setTimeZone(TimeZone.getDefault()); Calendar time = Calendar.getInstance(); time.setTimeZone(TimeZone.getDefault()); time.setTimeInMillis(date); if (now.get(Calendar.DATE) == time.get(Calendar.DATE)) { return context.getString(R.string.today); } else if (now.get(Calendar.DATE) - time.get(Calendar.DATE) == 1) { return context.getString(R.string.yesterday); } else { return DateFormat.format("EE, MM yyyy", time).toString(); // return DateFormat.format("MMMM dd yyyy, h:mm aa", time).toString(); } }
Example 58
Project: gearshift-master File: TimePickerFragment.java View source code |
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour, minute;
if (getArguments().containsKey(ARG_HOUR)) {
hour = getArguments().getInt(ARG_HOUR);
c.set(Calendar.HOUR_OF_DAY, hour);
} else {
hour = c.get(Calendar.HOUR_OF_DAY);
}
if (getArguments().containsKey(ARG_MINUTE)) {
minute = getArguments().getInt(ARG_MINUTE);
c.set(Calendar.MINUTE, minute);
} else {
minute = c.get(Calendar.MINUTE);
}
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 59
Project: Hancel-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
if (!isCustomDate) {
calendar = Calendar.getInstance();
}
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), (TrackDialog) getActivity(), hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 60
Project: honki_android-master File: MainActivity.java View source code |
private void loadMemo() {
Calendar calendar = Calendar.getInstance();
StringBuilder builder = new StringBuilder();
Cursor cursor = getContentResolver().query(CONTENT_URI, new String[] { "date", "text" }, null, null, "date ASC");
if (cursor != null) {
while (cursor.moveToNext()) {
calendar.setTimeInMillis(cursor.getLong(0));
CharSequence date = android.text.format.DateFormat.format("yyyy/MM/dd, E, kk:mm", calendar);
String text = cursor.getString(1);
builder.append(date + ":" + text).append("\n");
}
}
mTextView.setText(builder.toString());
}
Example 61
Project: iglaset-master File: CommentsParser.java View source code |
@Override
public void onStartElement(String name, Attributes atts) {
if (name.equals("comment")) {
mCurrentComment = new Comment();
mCurrentComment.setDrinkId(Integer.parseInt(atts.getValue("article_id").trim()));
mCurrentComment.setUserId(Integer.parseInt(atts.getValue("user_id").trim()));
mCurrentComment.setNickname(atts.getValue("nickname").trim());
try {
Date created = CommentsParser.CreatedTime.parse(atts.getValue("created").trim());
mCurrentComment.setCreated(DateFormat.format("yyyy-MM-dd", created));
} catch (ParseException e) {
mCurrentComment.setCreated(null);
}
int rating = 0;
if (!TextUtils.isEmpty(atts.getValue("rating").trim())) {
rating = (int) Float.parseFloat(atts.getValue("rating").trim());
}
mCurrentComment.setRating(rating);
}
}
Example 62
Project: ijoomer-adv-sdk-master File: IjoomerDataPickerView.java View source code |
@Override public void onDateChanged(final DatePicker view, final int year, final int month, final int day) { if (this.isBithDate) { Calendar c = Calendar.getInstance(); c.set(year, month, day); c.add(Calendar.YEAR, 18); if (c.get(Calendar.YEAR) > (Calendar.getInstance().get(Calendar.YEAR))) { view.init(IjoomerDataPickerView.this.year, IjoomerDataPickerView.this.month, IjoomerDataPickerView.this.day, IjoomerDataPickerView.this); Calendar calendar = Calendar.getInstance(); calendar.set(IjoomerDataPickerView.this.year, IjoomerDataPickerView.this.month, IjoomerDataPickerView.this.day); setTitle(DateFormat.format(format, calendar)); } else { this.year = year; this.month = month; this.day = day; view.init(year, month, day, IjoomerDataPickerView.this); Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); setTitle(DateFormat.format(format, calendar)); } } }
Example 63
Project: m2e-master File: MainActivity.java View source code |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView textView1 = (TextView) findViewById(R.id.textview1); TextView textView2 = (TextView) findViewById(R.id.textview2); TextView textView3 = (TextView) findViewById(R.id.textview3); TextView textView4 = (TextView) findViewById(R.id.textview4); TextView textView5 = (TextView) findViewById(R.id.textview5); // 09/21/2011 02:17 pm String delegate = "MM/dd/yy hh:mm a"; Date noteTS = new Date(); textView1.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); // Sep 21,2011 02:17 pm delegate = "MMM dd, yyyy h:mm aa"; textView2.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); //September 21,2011 02:17pm delegate = "MMMM dd, yyyy h:mmaa"; textView3.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); //Wed, September 21,2011 02:17:48 pm delegate = "E, MMMM dd, yyyy h:mm:ss aa"; textView4.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); delegate = //Wednesday, September 21,2011 02:17:48 pm "EEEE, MMMM dd, yyyy h:mm aa"; textView5.setText("Found Time :: " + DateFormat.format(delegate, noteTS)); }
Example 64
Project: maniana-fork-master File: DateOrder.java View source code |
public static DateOrder localDateOrder(Context context) {
final String key = String.valueOf(DateFormat.getDateFormatOrder(context)).toLowerCase();
final int monthIndex = key.indexOf('m');
final int dayIndex = key.indexOf('d');
if (monthIndex >= 0 && dayIndex >= 0) {
return (monthIndex < dayIndex) ? MD : DM;
}
// Unknown, use default
LogUtil.warning("Unknown date order: [%s]", key);
return MD;
}
Example 65
Project: material-remixer-android-master File: TransactionItemView.java View source code |
public void setData(TransactionItem data, boolean iconVisible) { businessTypeIcon.setImageResource(data.getBusinessTypeIconResource()); businessTypeIcon.setVisibility(iconVisible ? View.VISIBLE : View.GONE); businessName.setText(data.getBusinessName()); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getContext()); date.setText(dateFormat.format(data.getDate())); NumberFormat numberFormat = NumberFormat.getCurrencyInstance(); amount.setText(numberFormat.format(data.getAmount())); }
Example 66
Project: Misc-master File: TimerService.java View source code |
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
Log.d(TAG, "TimeTickReceiver#onReceive ACTION_TIME_TICK");
Intent newIntent = new Intent(context, Popup.class);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
newIntent.putExtra("time", DateFormat.format("MM/dd/yy h:mmaa", System.currentTimeMillis()));
context.startActivity(newIntent);
}
}
Example 67
Project: MozuAndroidInStoreAssistant-master File: OrdersAdapter.java View source code |
@Override
public View getView(int position, View convertView, ViewGroup parent) {
OrderViewHolder viewHolder;
if (convertView != null) {
viewHolder = (OrderViewHolder) convertView.getTag();
} else {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.order_list_item, parent, false);
viewHolder = new OrderViewHolder(convertView);
convertView.setTag(viewHolder);
}
Order order = getItem(position);
viewHolder.orderNumber.setText(String.valueOf(order.getOrderNumber()));
String date = order.getSubmittedDate() != null ? DateFormat.format("MM/dd/yy hh:mm a", new Date(order.getSubmittedDate().getMillis())).toString() : "";
viewHolder.orderDate.setText(date);
viewHolder.paymentStatus.setText(order.getPaymentStatus());
viewHolder.status.setText(order.getStatus());
viewHolder.total.setText(mNumberFormat.format(order.getTotal()));
return convertView;
}
Example 68
Project: MSLoggerBase-master File: FRDLogManager.java View source code |
/**
*
* @throws FileNotFoundException
*/
private void createLogFile() throws FileNotFoundException {
if (!ApplicationSettings.INSTANCE.isWritable()) {
return;
}
Date now = new Date();
String fileName = DateFormat.format("yyyy-MM-dd_kk.mm.ss", now).toString() + ".frd";
logFile = new File(ApplicationSettings.INSTANCE.getDataDir(), fileName);
absolutePath = logFile.getAbsolutePath();
os = new BufferedOutputStream(new FileOutputStream(logFile));
}
Example 69
Project: MVCHelper-master File: MovieAmountTask2.java View source code |
@Override
protected Void doInBackground(Void... params) {
try {
Thread.sleep(2000);
Random random = new Random();
int commentCount = random.nextInt(100);
int playCount = random.nextInt(1000) + 10;
long updateTime = System.currentTimeMillis();
sender.sendData(new MovieAmount(name, commentCount, playCount, name + " " + DateFormat.format("dd kk:mm:ss", updateTime)));
} catch (Exception e) {
e.printStackTrace();
sender.sendError(e);
}
return null;
}
Example 70
Project: Path-of-Exile-Racer-master File: AlarmUtils.java View source code |
public static void addAlarm(Context context, Race race, long delay) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent operation = getPendingIntentForRace(context, race, PendingIntent.FLAG_UPDATE_CURRENT); long time = race.getStartAt().getTime() - delay; am.set(AlarmManager.RTC_WAKEUP, time, operation); Date date = new Date(time); Toast.makeText(context, context.getString(R.string.notification_scheduled, DateFormat.getTimeFormat(context).format(date), DateFormat.getDateFormat(context).format(date)), Toast.LENGTH_LONG).show(); }
Example 71
Project: project_open-master File: TimeUtils.java View source code |
public static String getLocalTime(Context context, String time) {
// å?–出年月日æ?¥ï¼Œæ¯”较å—符串å?³å?¯
String str_curTime = DateFormat.format("yyyy-MM-dd", new Date()).toString();
int result = str_curTime.compareTo(time.substring(0, time.indexOf(" ")));
if (result > 0) {
return "昨天" + time.substring(time.indexOf(" "), time.lastIndexOf(":"));
} else if (result == 0) {
return "今天" + time.substring(time.indexOf(" "), time.lastIndexOf(":"));
} else {
return time;
}
}
Example 72
Project: qksms-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (mPreference == null) {
Log.w(TAG, "No preference set");
return null;
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
try {
Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
c.setTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity());
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
Example 73
Project: QuickNews-master File: TimeUtils.java View source code |
public static String getLocalTime(Context context, String time) {
// å?–出年月日æ?¥ï¼Œæ¯”较å—符串å?³å?¯
String str_curTime = DateFormat.format("yyyy-MM-dd", new Date()).toString();
int result = str_curTime.compareTo(time.substring(0, time.indexOf(" ")));
if (result > 0) {
return "昨天" + time.substring(time.indexOf(" "), time.lastIndexOf(":"));
} else if (result == 0) {
return "今天" + time.substring(time.indexOf(" "), time.lastIndexOf(":"));
} else {
return time;
}
}
Example 74
Project: react-native-sidemenu-master File: TimePickerDialogFragment.java View source code |
/*package*/ static Dialog createDialog(Bundle args, Context activityContext, @Nullable OnTimeSetListener onTimeSetListener) { final Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); boolean is24hour = DateFormat.is24HourFormat(activityContext); if (args != null) { hour = args.getInt(TimePickerDialogModule.ARG_HOUR, now.get(Calendar.HOUR_OF_DAY)); minute = args.getInt(TimePickerDialogModule.ARG_MINUTE, now.get(Calendar.MINUTE)); is24hour = args.getBoolean(TimePickerDialogModule.ARG_IS24HOUR, DateFormat.is24HourFormat(activityContext)); } return new DismissableTimePickerDialog(activityContext, onTimeSetListener, hour, minute, is24hour); }
Example 75
Project: ReactNativeApp-master File: TimePickerDialogFragment.java View source code |
/*package*/ static Dialog createDialog(Bundle args, Context activityContext, @Nullable OnTimeSetListener onTimeSetListener) { final Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); boolean is24hour = DateFormat.is24HourFormat(activityContext); if (args != null) { hour = args.getInt(TimePickerDialogModule.ARG_HOUR, now.get(Calendar.HOUR_OF_DAY)); minute = args.getInt(TimePickerDialogModule.ARG_MINUTE, now.get(Calendar.MINUTE)); is24hour = args.getBoolean(TimePickerDialogModule.ARG_IS24HOUR, DateFormat.is24HourFormat(activityContext)); } return new DismissableTimePickerDialog(activityContext, onTimeSetListener, hour, minute, is24hour); }
Example 76
Project: robolectric-master File: ShadowDateFormatTest.java View source code |
@Test
public void getLongDateFormat_returnsADateFormat_January() {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.DATE, 12);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.YEAR, 1970);
Date date = cal.getTime();
assertEquals("January 12, 1970", DateFormat.getLongDateFormat(null).format(date));
}
Example 77
Project: SmartReceiptsLibrary-master File: MyCalendarDialog.java View source code |
@Override @SuppressWarnings("deprecation") public final void onDateSet(int day, int month, int year) { //**This Date constructor is deprecated final Date date = new Date(year - 1900, month, day); mDateManager.setCachedDate(date); String dateString = DateFormat.getDateFormat(mContext).format(date); //This block is for mEdit if (mEdit != null) { mEdit.setText(dateString); mEdit.date = date; if (mDateSetListener != null) mDateSetListener.onDateSet(date); } //This block is for mEnd if (//ugly hack (order dependent set methods below) mEnd != null && mEnd.date == null) { //+3600000 for DST hack final Date endDate = new Date(date.getTime() + mDuration * 86400000L + 3600000L); String endString = DateFormat.getDateFormat(mContext).format(endDate); mEnd.setText(endString); mEnd.date = endDate; } }
Example 78
Project: Team5GeoTopics-master File: ReplyLevelActivity.java View source code |
private void updateViewingComment(CommentModel comment) { if (comment.getmEsID().equals(viewingComment.getmEsID())) { Log.w("ReplyLevel", "Updating viewing comment"); Log.w("ReplyLevel", viewingComment.getmBody()); Log.w("ReplyLevel", comment.getmBody()); viewingComment = comment; if (viewingComment.isTopLevel()) { title.setText(viewingComment.getmTitle()); } else { title.setVisibility(View.GONE); divider.setVisibility(View.GONE); } body.setText(viewingComment.getmBody()); if (viewingComment.hasPicture()) { image.setImageBitmap(viewingComment.getPicture()); } else { image.setVisibility(View.GONE); } Date date = comment.getDate(); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(application.getContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(application.getContext()); author.setText("By " + viewingComment.getmAuthor()); this.date.setText(dateFormat.format(date)); time.setText(timeFormat.format(date)); } }
Example 79
Project: tvbrowserandroid-master File: TimePreference.java View source code |
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
mTime.set(Calendar.HOUR_OF_DAY, CompatUtils.getTimePickerHour(mTimePicker));
mTime.set(Calendar.MINUTE, CompatUtils.getTimePickerMinute(mTimePicker));
int minutes = CompatUtils.getTimePickerHour(mTimePicker) * 60 + CompatUtils.getTimePickerMinute(mTimePicker);
setTitle(DateFormat.getTimeFormat(getContext()).format(mTime.getTime()));
if (callChangeListener(minutes)) {
persistInt(minutes);
}
}
}
Example 80
Project: Typical_IF-master File: DateUtils.java View source code |
public static String getFormattedDate(long smsTimeInMilis) { Calendar smsTime = Calendar.getInstance(); smsTime.setTimeZone(TimeZone.getTimeZone("Europe/Kiev")); smsTime.setTimeInMillis(smsTimeInMilis * 1000); Calendar now = Calendar.getInstance(); now.setTimeZone(TimeZone.getTimeZone("Europe/Kiev")); if (now.get(Calendar.DATE) == smsTime.get(Calendar.DATE)) { return String.format(Constants.TODAY, DateFormat.format(Constants.TIME_FORMAT_STRING, smsTime)); } else if (now.get(Calendar.DATE) - smsTime.get(Calendar.DATE) == 1) { return String.format(Constants.YESTERDAY, DateFormat.format(Constants.TIME_FORMAT_STRING, smsTime)); } else if (now.get(Calendar.YEAR) == smsTime.get(Calendar.YEAR)) { return DateFormat.format(Constants.DATE_TIME_FORMAT_STRING, smsTime).toString(); } else return DateFormat.format(Constants.OTHER_FORMAT_STRING, smsTime).toString(); }
Example 81
Project: udrunk-master File: TimeUtil.java View source code |
@SuppressWarnings("deprecation") public static String formatAgoDate(Date date, Context context) { String result = null; Date now = new Date(); long diff = now.getTime() - date.getTime(); int value; Resources res = context.getResources(); // Less than a minute if (diff < MINUTE) { value = (int) (diff / SECOND); result = res.getQuantityString(R.plurals.seconds_ago, value, value); } else // Less than an hour if (diff < HOUR) { value = (int) (diff / MINUTE); result = res.getQuantityString(R.plurals.minutes_ago, value, value); } else // Less than 12 hours if (diff < DAY / 2) { value = (int) (diff / HOUR); result = res.getQuantityString(R.plurals.hours_ago, value, value); } else // Today if (diff < DAY && date.getDate() == now.getDate()) { result = res.getString(R.string.todayat, DateFormat.format("h:mmaa", date)); } else // Yesterday if (diff < 2 * DAY && date.getDate() == (now.getDate() - 1)) { result = res.getString(R.string.yesterdayat, DateFormat.format("h:mmaa", date)); } else // Less than a month if (diff < MONTH) { value = (int) (diff / DAY); result = res.getQuantityString(R.plurals.days_ago, value, value); } else // More than a month { value = (int) (diff / MONTH); result = res.getQuantityString(R.plurals.months_ago, value, value); } return result; }
Example 82
Project: Veckify-master File: AlarmSchedulingTest.java View source code |
private void assertNextAlarmEquals(String expectedTime, int hour, int minute, int repeatDays, long oneoffTimeMs, String nowTime) throws Exception {
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd kk:mm");
final Date date = formatter.parse(nowTime);
final Calendar cal = AlarmUtils.getNextAlarmTime(true, hour, minute, repeatDays, oneoffTimeMs, date.getTime());
assertEquals(expectedTime, DateFormat.format("yyyy-MM-dd kk:mm", cal));
}
Example 83
Project: Emby.AndroidTv-master File: ProgramGridCell.java View source code |
private void initComponent(Activity context, ILiveTvGuide activity, BaseItemDto program) { mActivity = activity; mProgram = program; LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.program_grid_cell, this, false); this.addView(v); mProgramName = (TextView) findViewById(R.id.programName); mInfoRow = (LinearLayout) findViewById(R.id.infoRow); mProgramName.setText(program.getName()); mProgram = program; mProgramName.setFocusable(false); mInfoRow.setFocusable(false); mRecIndicator = (ImageView) findViewById(R.id.recIndicator); if (Utils.isTrue(program.getIsMovie())) mBackgroundColor = getResources().getColor(R.color.guide_movie_bg); else if (Utils.isTrue(program.getIsNews())) mBackgroundColor = getResources().getColor(R.color.guide_news_bg); else if (Utils.isTrue(program.getIsSports())) mBackgroundColor = getResources().getColor(R.color.guide_sports_bg); else if (Utils.isTrue(program.getIsKids())) mBackgroundColor = getResources().getColor(R.color.guide_kids_bg); setBackgroundColor(mBackgroundColor); if (program.getStartDate() != null && program.getEndDate() != null) { TextView time = new TextView(context); Date localStart = Utils.convertToLocalDate(program.getStartDate()); if (localStart.getTime() + 60000 < activity.getCurrentLocalStartDate()) mProgramName.setText("<< " + mProgramName.getText()); time.setText(android.text.format.DateFormat.getTimeFormat(TvApp.getApplication()).format(Utils.convertToLocalDate(program.getStartDate())) + "-" + android.text.format.DateFormat.getTimeFormat(TvApp.getApplication()).format(Utils.convertToLocalDate(program.getEndDate()))); mInfoRow.addView(time); } if (program.getOfficialRating() != null && !program.getOfficialRating().equals("0")) { InfoLayoutHelper.addSpacer(context, mInfoRow, " ", 10); InfoLayoutHelper.addBlockText(context, mInfoRow, program.getOfficialRating(), 10); } if (program.getIsHD() != null && program.getIsHD()) { InfoLayoutHelper.addSpacer(context, mInfoRow, " ", 10); InfoLayoutHelper.addBlockText(context, mInfoRow, "HD", 10); } if (program.getSeriesTimerId() != null) { mRecIndicator.setImageResource(R.drawable.recseries); } else if (program.getTimerId() != null) { mRecIndicator.setImageResource(R.drawable.rec); } setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mActivity.showProgramOptions(); } }); }
Example 84
Project: Purple-Robot-master File: ProbeTrigger.java View source code |
public String getDiagnosticString(Context context) { String name = this.name(); String identifier = this.identifier(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String key = "last_fired_" + identifier; long lastFired = prefs.getLong(key, 0); String lastFiredString = context.getString(R.string.trigger_fired_never); if (lastFired != 0) { DateFormat formatter = android.text.format.DateFormat.getMediumDateFormat(context); DateFormat timeFormatter = android.text.format.DateFormat.getTimeFormat(context); lastFiredString = formatter.format(new Date(lastFired)) + " " + timeFormatter.format(new Date(lastFired)); } String enabled = context.getString(R.string.trigger_disabled); if (this.enabled(context)) enabled = context.getString(R.string.trigger_enabled); return context.getString(R.string.trigger_diagnostic_string, name, identifier, enabled, lastFiredString); }
Example 85
Project: the-blue-alliance-android-master File: BaseNotification.java View source code |
public String getNotificationTimeString(Context c) { DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(c); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(c); if (notificationTime == null) return ""; return dateFormat.format(notificationTime) + " " + timeFormat.format(notificationTime); }
Example 86
Project: xabber-android-master File: StringUtils.java View source code |
/** * @param timeStamp * @return String with time or with date and time depend on current time. */ public static String getSmartTimeText(Context context, Date timeStamp) { if (timeStamp == null) { return ""; } // today Calendar midnight = new GregorianCalendar(); // reset hour, minutes, seconds and millis midnight.set(Calendar.HOUR_OF_DAY, 0); midnight.set(Calendar.MINUTE, 0); midnight.set(Calendar.SECOND, 0); midnight.set(Calendar.MILLISECOND, 0); if (timeStamp.getTime() > midnight.getTimeInMillis()) { return timeFormat.format(timeStamp); } else { DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); return dateFormat.format(timeStamp) + " " + timeFormat.format(timeStamp); } }
Example 87
Project: android-floatinglabel-widgets-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
readArguments();
int hour = selectedInstant.getHourOfDay();
int minute = selectedInstant.getMinuteOfHour();
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), timeSetListener, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
Example 88
Project: android-sdk-sources-for-api-level-23-master File: DigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 89
Project: android_frameworks_base-master File: DigitalClock.java View source code |
public void run() {
if (mTickerStopped)
return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mCalendar));
invalidate();
long now = SystemClock.uptimeMillis();
long next = now + (1000 - now % 1000);
mHandler.postAtTime(mTicker, next);
}
Example 90
Project: android_WallBox-master File: DateBuilder.java View source code |
private int getHour(Context c, String sdf) {
int hour = Integer.parseInt(sdf.toString());
if (!DateFormat.is24HourFormat(c)) {
if (hour > 12) {
return hour - 12;
} else if (hour == 0) {
return 12;
} else {
return hour;
}
} else {
return hour;
}
}
Example 91
Project: apteryx-master File: TextFormat.java View source code |
public static String formatDateSmart(Context context, long time) { Calendar current = Calendar.getInstance(); Calendar date = Calendar.getInstance(); date.setTimeInMillis(time); int dayToday = current.get(Calendar.DAY_OF_YEAR); int day = date.get(Calendar.DAY_OF_YEAR); if (day == dayToday) return DateFormat.format("kk:mm", time).toString(); StringBuilder result = new StringBuilder(); if (dayToday - day == 1) result.append(context.getString(R.string.yesterday)); else if (dayToday - day == -1) result.append(context.getString(R.string.tomorrow)); else { if (current.get(Calendar.YEAR) == date.get(Calendar.YEAR)) result.append("dd MMM"); else result.append("dd MMM yyyy"); } result.append(" kk:mm"); return DateFormat.format(result.toString(), time).toString(); }
Example 92
Project: AutoBackground-master File: TimePickerFragment.java View source code |
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), TimePickerFragment.this, hour, minute, DateFormat.is24HourFormat(getActivity()));
timePickerDialog.setTitle(getArguments().getString("title", ""));
return timePickerDialog;
}
Example 93
Project: btpka3.github.com-master File: MyTime2IntentService.java View source code |
@Override
public void handleMessage(Message msgfromClient) {
Log.e(TAG, "MyTime2IntentService handleMessage !!!!!!!!!!!!" + msgfromClient);
// Message msgToClient = Message.obtain(msgfromClient);
switch(msgfromClient.what) {
//msg å®¢æˆ·ç«¯ä¼ æ?¥çš„消æ?¯
case MSG_TIME:
if (isTimeRunning()) {
return;
}
timeRunning = true;
int time = msgfromClient.arg1;
for (int i = 0; i < time; i++) {
try {
Thread.sleep(1000);
// 返回给客户端的消�
Message msgToClient = Message.obtain(null, MyTime2IntentService.MSG_TIME);
CharSequence timeStr = DateFormat.format("hh:mm:ss", System.currentTimeMillis());
Bundle mBundle = new Bundle();
mBundle.putString("timeStr", timeStr.toString());
msgToClient.setData(mBundle);
Log.e(TAG, "MyTime2IntentService rely mBundle = " + mBundle);
msgfromClient.replyTo.send(msgToClient);
Log.e(TAG, "MyTime2IntentService rely message !!!!!!!!!!!!" + msgToClient);
} catch (InterruptedException e) {
e.printStackTrace();
return;
} catch (RemoteException e) {
e.printStackTrace();
return;
}
}
timeRunning = false;
break;
default:
Log.e(TAG, "MyTime2IntentService defalut !!!!!!!!!!!!" + msgfromClient);
break;
}
super.handleMessage(msgfromClient);
}
Example 94
Project: droidkaigi2016-master File: DateUtil.java View source code |
@NonNull
public static String getMonthDate(Date date, Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), FORMAT_MMDD);
return new SimpleDateFormat(pattern).format(date);
} else {
int flag = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_NO_YEAR;
return DateUtils.formatDateTime(context, date.getTime(), flag);
}
}
Example 95
Project: FitHealthBetaGitRepo-master File: MealRow.java View source code |
public void setLog(LogMeal log) {
mLog = log;
LinearLayout mCircle = (LinearLayout) findViewById(R.id.circle);
TextView mMealName = (TextView) findViewById(R.id.log_meal_name1);
TextView mCalories = (TextView) findViewById(R.id.log_calories);
TextView mServing = (TextView) findViewById(R.id.serving);
TextView mTime = (TextView) findViewById(R.id.time);
mCircle.bringToFront();
mMealName.setText(mLog.getMealName() + "");
mCalories.setText(df.format(mLog.getCalorieCount()) + " ");
mServing.setText(mLog.getServingSize() + " " + mLog.getMealServing());
long lStartTime = new Date().getTime();
long lEndTime = mLog.getDate().getTime();
long difference = lEndTime - lStartTime;
int seconds = (int) (difference / 1000) * (-1);
int minutes = (int) ((difference / (1000 * 60)));
int min = minutes * -1;
int hours = (int) ((difference / (1000 * 60 * 60)) % 24);
int hour = hours * -1;
if (seconds < 60 && minutes < 60) {
mTime.setText("Seconds ago");
} else if (seconds >= 60 && min < 60 && hour < 1) {
mTime.setText(min + " Min");
} else {
mTime.setText(DateFormat.format("h:m a", mLog.getDate()));
}
ImageView recipe = (ImageView) findViewById(R.id.recipe);
if (mLog.getRecipe() != null) {
recipe.setVisibility(VISIBLE);
} else {
recipe.setVisibility(GONE);
}
}
Example 96
Project: GeekAlarm-master File: ActivityUtils.java View source code |
public static int getHour(Activity activity) {
final WheelView hours = (WheelView) activity.findViewById(R.id.hour);
boolean is24Hour = DateFormat.is24HourFormat(activity);
if (is24Hour) {
return hours.getCurrentItem();
} else {
final WheelView ampm = (WheelView) activity.findViewById(R.id.ampm);
boolean isAM = ampm.getCurrentItem() == 0;
int hour = hours.getCurrentItem();
hour++;
hour %= 12;
if (!isAM) {
hour += 12;
}
return hour;
}
}
Example 97
Project: jdroid-master File: TimePickerDialogFragment.java View source code |
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
View view = inflate(R.layout.jdroid_time_picker_dialog_fragment);
dialogBuilder.setView(view);
final TimePicker timePicker = (TimePicker) view.findViewById(R.id.timePicker);
timePicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
timePicker.setCurrentHour(DateUtils.getHour(defaultTime, true));
timePicker.setCurrentMinute(DateUtils.getMinute(defaultTime));
dialogBuilder.setPositiveButton(getString(R.string.jdroid_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
Date time = DateUtils.getTime(timePicker.getCurrentHour(), timePicker.getCurrentMinute());
int requestCode = getTargetRequestCode();
((OnTimeSetListener) getTargetFragment()).onTimeSet(time, requestCode);
}
});
dialogBuilder.setNegativeButton(getString(R.string.jdroid_cancel), null);
return dialogBuilder.create();
}
Example 98
Project: madsonic-5.5-master File: ChatAdapter.java View source code |
@Override public View getView(int position, View convertView, ViewGroup parent) { ChatMessage message = this.getItem(position); ViewHolder holder; int layout; String messageUser = message.getUsername(); Date messageTime = new java.util.Date(message.getTime()); String messageText = message.getMessage(); String me = Util.getUserName(activity, Util.getActiveServer(activity)); if (messageUser.equals(me)) { layout = R.layout.chat_item_reverse; } else { layout = R.layout.chat_item; } if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(activity).inflate(layout, parent, false); TextView usernameView = (TextView) convertView.findViewById(R.id.chat_username); TextView timeView = (TextView) convertView.findViewById(R.id.chat_time); TextView messageView = (TextView) convertView.findViewById(R.id.chat_message); messageView.setMovementMethod(LinkMovementMethod.getInstance()); Linkify.addLinks(messageView, Linkify.EMAIL_ADDRESSES); Linkify.addLinks(messageView, Linkify.WEB_URLS); Linkify.addLinks(messageView, phoneMatcher, "tel:"); holder.message = messageView; holder.username = usernameView; holder.time = timeView; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity); String messageTimeFormatted = String.format("[%s]", timeFormat.format(messageTime)); holder.username.setText(messageUser); holder.message.setText(messageText); holder.time.setText(messageTimeFormatted); return convertView; }
Example 99
Project: MaterialScrollBar-master File: DateAndTimeIndicator.java View source code |
@Override
protected String getTextElement(Integer currentSection, IDateableAdapter adapter) {
Date date = adapter.getDateForElement(currentSection);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
String text = "";
if (includeTime) {
text += DateFormat.getTimeFormat(context).format(date);
}
if (includeMonth) {
text += " " + months[calendar.get(Calendar.MONTH)].substring(0, 3);
}
if (includeDay) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
if (String.valueOf(day).length() == 1) {
text += " 0" + day;
} else {
text += " " + day;
}
}
if (includeYear) {
if (includeDay) {
text += ",";
}
text += " " + calendar.get(Calendar.YEAR);
}
return text.trim();
}
Example 100
Project: mobile2-android-master File: DateTimeUtil.java View source code |
public static String getShortFriendlyDate(Date dt) { String dtStr = DateFormat.format("MMM d, yyyy", dt).toString(); Date today = getToday(); String todayStr = DateFormat.format("MMM d, yyyy", today).toString(); if (dtStr.equals(todayStr)) { return "Today"; } Date yesterday = getYesterday(); String yesterdayStr = DateFormat.format("MMM d, yyyy", yesterday).toString(); if (dtStr.equals(yesterdayStr)) { return "Yesterday"; } if (dt.getYear() != today.getYear()) { return dtStr; } else { return DateFormat.format("MMM d", dt).toString(); } }
Example 101
Project: MobileBackendStarter-master File: PostListFragment.java View source code |
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = super.getView(position, convertView, parent);
CloudEntity item = getItem(position);
TextView tv = (TextView) convertView.findViewById(R.id.name);
tv.setText(getCreatorName(item));
CharSequence time = DateFormat.format("hh:mm:ss ", item.getCreatedAt());
tv = (TextView) convertView.findViewById(R.id.time);
tv.setText(time);
tv = (TextView) convertView.findViewById(R.id.message);
tv.setText(item.get("message") + "");
return convertView;
}