List of usage examples for java.text DateFormat SHORT
int SHORT
To view the source code for java.text DateFormat SHORT.
Click Source Link
From source file:com.bdb.weather.display.day.DayWindPane.java
@Override public List<SeriesControl> configure(Menu menu) { List<SeriesControl> controls = new ArrayList<>(); controls.add(new SeriesControl(HistoricalSeriesInfo.AVG_WIND_SPEED_SERIES, false)); controls.add(new SeriesControl(HistoricalSeriesInfo.AVG_WIND_DIRECTION_SERIES, false)); controls.add(new SeriesControl(HistoricalSeriesInfo.HIGH_WIND_SPEED_SERIES, false)); controls.add(new SeriesControl(HistoricalSeriesInfo.HIGH_WIND_DIRECTION_SERIES, false)); controls.add(new SeriesControl(HistoricalSeriesInfo.WIND_GUST_SPEED_SERIES, false)); controls.add(new SeriesControl(HistoricalSeriesInfo.WIND_GUST_DIRECTION_SERIES, false)); WindItemRenderer renderer = new WindItemRenderer(); getPlot().setRenderer(renderer);//from w w w . j av a2 s .co m WeatherSenseConstants.configureGustRenderer(renderer, GUST_SERIES_INDEX); StandardXYToolTipGenerator ttgen = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, DateFormat.getTimeInstance(DateFormat.SHORT), Speed.getDefaultFormatter()); getPlot().getRenderer().setBaseToolTipGenerator(ttgen); return controls; }
From source file:de.tobiasbielefeld.solitaire.ui.statistics.RecentScoresFragment.java
/** * Loads the high score list//from ww w .ja v a 2 s . c o m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_statistics_tab3, container, false); //if the app got killed while the statistics are open and then the user restarts the app, //my helper classes aren't initialized so they can't be used. In this case, simply //close the statistics try { loadData(); } catch (NullPointerException e) { getActivity().finish(); return view; } TableLayout tableLayout = (TableLayout) view.findViewById(R.id.statisticsTableHighScores); TextView textNoEntries = (TextView) view.findViewById(R.id.statisticsTextNoEntries); if (scores.getRecentScore(0, 2) != 0) { textNoEntries.setVisibility(View.GONE); } for (int i = 0; i < Scores.MAX_SAVED_SCORES; i++) { //for each entry in highScores, add a new view with it if (scores.getRecentScore(i, 2) == 0) { //if the score is zero, don't show it continue; } TableRow row = (TableRow) LayoutInflater.from(getContext()).inflate(R.layout.statistics_scores_row, null); TextView textView1 = (TextView) row.findViewById(R.id.row_cell_1); TextView textView2 = (TextView) row.findViewById(R.id.row_cell_2); TextView textView3 = (TextView) row.findViewById(R.id.row_cell_3); TextView textView4 = (TextView) row.findViewById(R.id.row_cell_4); textView1.setText(String.format(Locale.getDefault(), "%s %s", scores.getRecentScore(i, 0), dollar)); long time = scores.getRecentScore(i, 1); textView2.setText(String.format(Locale.getDefault(), "%02d:%02d:%02d", time / 3600, (time % 3600) / 60, (time % 60))); textView3.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(scores.getRecentScore(i, 2))); textView4.setText( new SimpleDateFormat("HH:mm", Locale.getDefault()).format(scores.getRecentScore(i, 2))); tableLayout.addView(row); } return view; }
From source file:com.zimbra.cs.service.util.ItemDataFile.java
public static void list(InputStream is, Set<MailItem.Type> types, String cset, PrintStream os) throws IOException { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); TarEntry te;/*from w ww .ja v a 2s . c om*/ TarInputStream tis = new TarInputStream(new GZIPInputStream(is), cset == null ? "UTF-8" : cset); os.format("%-13s %17s %10s %6s %s\n", "TYPE", "DATE", "SIZE", "METASZ", "PATH"); try { TarEntry idEntry = null; while ((te = tis.getNextEntry()) != null) { if (te.getName().endsWith(".meta")) { if (idEntry != null && !skip(types, MailItem.Type.of((byte) idEntry.getMajorDeviceId()))) { os.format("%-13s %17s %10s %6d %s\n", idEntry.getGroupName(), df.format(idEntry.getModTime()), 0, idEntry.getSize(), idEntry.getName().substring(0, idEntry.getName().indexOf(".meta"))); } idEntry = te; } else { if (!skip(types, MailItem.Type.of((byte) te.getMajorDeviceId()))) { os.format("%-13s %17s %10s %6d %s\n", te.getGroupName(), df.format(te.getModTime()), te.getSize(), idEntry == null ? 0 : idEntry.getSize(), te.getName()); } idEntry = null; } } if (idEntry != null && !skip(types, MailItem.Type.of((byte) idEntry.getMajorDeviceId()))) { os.format("%-13s %17s %10s %6d %s\n", idEntry.getGroupName(), df.format(idEntry.getModTime()), 0, idEntry.getSize(), idEntry.getName().substring(0, idEntry.getName().indexOf(".meta"))); } } finally { tis.close(); } }
From source file:DateValidator.java
/** * <p>Checks if the field is a valid date. The <code>Locale</code> is * used with <code>java.text.DateFormat</code>. The setLenient method * is set to <code>false</code> for all.</p> * * @param value The value validation is being performed on. * @param locale The locale to use for the date format, defaults to the default * system default if null.// w ww.jav a 2 s . c om * @return true if the date is valid. */ public boolean isValid(String value, Locale locale) { if (value == null) { return false; } DateFormat formatter = null; if (locale != null) { formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale); } else { formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); } formatter.setLenient(false); try { formatter.parse(value); } catch (ParseException e) { return false; } return true; }
From source file:phex.gui.tabs.download.DownloadOverviewPanel.java
public DownloadOverviewPanel() { dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); }
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Updates the days to target.// w w w. ja va2 s .c o m */ private void updateDays() { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class); int[] appIds = appManager.getAppWidgetIds(cName); DayCalculator dayCalc = new DayCalculator(); if (!isOnline()) { try { Thread.sleep(60000); } catch (InterruptedException e) { Log.e(TAG, "Interrupted: " + e.getLocalizedMessage()); } } for (int appId : appIds) { PrefManager pm = new PrefManager(this, appId); Calendar target = pm.getTarget(); boolean[] chkDays = pm.getCheckedDays(); int days = pm.getLastDiff(); if (isOnline()) { try { days = dayCalc.getDaysLeft(target.getTime(), chkDays); Map<String, Object> saveMap = new HashMap<String, Object>(); Long diff = Long.valueOf(days); saveMap.put(PrefManager.KEY_DIFF, diff); pm.save(saveMap); } catch (JSONException e) { Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage()); } } else { Log.e(TAG, "No internet connection!"); } RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String targetStr = df.format(target.getTime()); rv.setTextViewText(R.id.target, targetStr); String dayStr = String.format(Locale.getDefault(), "%d %s", days, getResources().getString(R.string.unit)); rv.setTextViewText(R.id.dayCount, dayStr); // put widget id into intent Intent configIntent = new Intent(this, ConfigActivity.class); configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent); // update widget appManager.updateAppWidget(appId, rv); } }
From source file:am.project.x.business.widgets.zxingscanview.ZxingScanViewActivity.java
@Override public void onResult(ZxingScanView scanView, Result result, Bitmap barcode, float scaleFactor) { ParsedResult parsedResult = ResultParser.parseResult(result); final String format = "format:" + result.getBarcodeFormat().toString(); final String type = "type:" + parsedResult.getType().toString(); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); final String date = "date:" + formatter.format(new Date(result.getTimestamp())); String meta = ""; Map<ResultMetadataType, Object> metadata = result.getResultMetadata(); if (metadata != null) { StringBuilder metadataText = new StringBuilder(20); for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) { if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) { metadataText.append(entry.getValue()).append('\n'); }/*from w w w . jav a2 s .c o m*/ } if (metadataText.length() > 0) { metadataText.setLength(metadataText.length() - 1); meta = metadataText.toString(); } } CharSequence displayContents = parsedResult.getDisplayResult(); Toast.makeText(this, format + "\n" + type + "\n" + date + "\n" + meta + "\n" + displayContents, Toast.LENGTH_SHORT).show(); // ??? scanView.restartScanDelay(3000); }
From source file:org.olat.core.util.Formatter.java
License:asdf
/** * formats the given date so it is friendly to read * /*from w w w. j av a 2 s . co m*/ * @param d the date * @return a String with the formatted date */ public String formatDate(Date d) { DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); df.setLenient(false); String da = df.format(d); return da; }
From source file:de.jcup.egradle.eclipse.ide.execution.EclipseLaunchProcessExecutor.java
@Override protected void handleProcessStarted(EnvironmentProvider provider, Process process, Date started, File workingDirectory, String[] commands) { String label = "<none>"; if (provider instanceof GradleContext) { label = ((GradleContext) provider).getCommandString(); }/*w w w.j a v a2s . c o m*/ String path = "inside root project"; Map<String, String> attributes = new HashMap<>(); String timestamp = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(started); /* * Will be shown in process information dialog - see * org.eclipse.debug.internal.ui.preferences. ProcessPropertyPage */ StringBuilder sb = new StringBuilder(); for (String key : provider.getEnvironment().keySet()) { String value = provider.getEnvironment().get(key); sb.append(key); sb.append('='); sb.append(value); sb.append(System.getProperty("line.separator")); } attributes.put(DebugPlugin.ATTR_ENVIRONMENT, sb.toString()); attributes.put(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8"); attributes.put(DebugPlugin.ATTR_WORKING_DIRECTORY, workingDirectory.getAbsolutePath()); attributes.put(DebugPlugin.ATTR_LAUNCH_TIMESTAMP, timestamp); attributes.put(DebugPlugin.ATTR_PATH, path); /* * using an unbreakable space 00A0 to avoid unnecessary breaks in view */ cmdLine = StringUtils.join(Arrays.asList(commands), '\u00A0'); attributes.put(IProcess.ATTR_CMDLINE, cmdLine); /* * bind process to runtime process, so visible and correct handled in * debug UI */ EGradleRuntimeProcess rp = EGradleRuntimeProcess.create(launch, process, label, attributes); // rp.getStreamsProxy().getOutputStreamMonitor().addListener(rp); outputHandler.output("Launch started - for details see output of " + label); if (!rp.canTerminate()) { outputHandler.output("Started process cannot terminate"); } }
From source file:lucee.commons.i18n.FormatUtil.java
public static DateFormat[] getDateFormats(Locale locale, TimeZone tz, boolean lenient) { String id = "d-" + locale.hashCode() + "-" + tz.getID() + "-" + lenient; DateFormat[] df = formats.get(id); if (df == null) { List<DateFormat> list = new ArrayList<DateFormat>(); list.add(DateFormat.getDateInstance(DateFormat.FULL, locale)); list.add(DateFormat.getDateInstance(DateFormat.LONG, locale)); list.add(DateFormat.getDateInstance(DateFormat.MEDIUM, locale)); list.add(DateFormat.getDateInstance(DateFormat.SHORT, locale)); addCustom(list, locale, FORMAT_TYPE_DATE); df = list.toArray(new DateFormat[list.size()]); for (int i = 0; i < df.length; i++) { df[i].setLenient(lenient);//from ww w .j a v a 2s . co m df[i].setTimeZone(tz); } formats.put(id, df); } return df; }