List of usage examples for java.util Calendar SHORT
int SHORT
To view the source code for java.util Calendar SHORT.
Click Source Link
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); String n = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale); System.out.printf(n);/*from w ww . ja v a 2s . c o m*/ }
From source file:Main.java
public static String getDay() { return Calendar.getInstance().getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US); }
From source file:Main.java
public static String getShortDateDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.DATE); }
From source file:Main.java
public static String getShortMonthYearDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.YEAR); }
From source file:Main.java
public static String getWeekDay(int position) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, position + 1); return calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()); }
From source file:Main.java
/** Convert a calendar date into a string as specified by http://tools.ietf.org/html/rfc822#section-5.1 * @param date the calendar instance to convert to a string * @param locale the locale to use when outputting strings such as a day of the week, or month of the year. * @return a string in the format: "day_abbreviation, day_of_month month_abbreviation year hour:minute:second GMT" *//*from w w w . j a v a 2 s . c o m*/ // package-private - unused static final String convertDateToStringRfc822(Calendar date, Locale locale) { Date a = Date.from(Instant.now()); a.toString(); int day = date.get(Calendar.DAY_OF_MONTH); int hour = date.get(Calendar.HOUR_OF_DAY); int minute = date.get(Calendar.MINUTE); int second = date.get(Calendar.SECOND); String str = date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale) + ", " + (day < 10 ? "0" + day : day) + " " + date.getDisplayName(Calendar.MONTH, Calendar.SHORT, locale) + " " + date.get(Calendar.YEAR) + " " + (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" + (second < 10 ? "0" + second : second) + " GMT"; return str; }
From source file:calendar.services.transformers.EntryToDayTransformer.java
@Override public DaySummary transform(List<Entry> entryList) { BigDecimal total = new BigDecimal(0); Calendar cal = Calendar.getInstance(); cal.setTime(this.date); if (!entryList.isEmpty()) { daySummary.setEntries(entryList); total = entryList.stream().map((x) -> x.getHours()).reduce((x, y) -> x.add(y)).get(); }/* w ww . java 2 s.c om*/ daySummary.setDay(cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.UK)); daySummary.setTotal(total); return daySummary; }
From source file:iSoron.HistoryChart.java
private void drawAxis(Canvas canvas, RectF location) { float verticalOffset = pTextHeader.getFontSpacing() * 0.4f; for (String day : DateUtils.getLocaleDayNames(Calendar.SHORT)) { location.offset(0, columnWidth); canvas.drawText(day, location.left + headerTextOffset, location.centerY() + verticalOffset, pTextHeader);// w ww.ja va 2 s . com } }
From source file:iSoron.HistoryChart.java
private float getWeekdayLabelWidth() { float width = 0; for (String w : DateUtils.getLocaleDayNames(Calendar.SHORT)) width = Math.max(width, pSquareFg.measureText(w)); return width; }
From source file:net.kw.shrdlu.grtgtfs.Activities.RiderAlertsActivity.java
/** * Get the latest twitter info. Some of this copied from http://www.vogella.com/articles/AndroidJSON/article.html *//* www. ja v a 2s.c o m*/ ArrayList<String[]> readTwitterFeed() { final StringBuilder builder = new StringBuilder(); final HttpClient client = new DefaultHttpClient(); final HttpGet httpGet = new HttpGet(TwitterURL + TwitterQry); httpGet.setHeader("Authorization", "Bearer " + AccessToken); try { final HttpResponse response = client.execute(httpGet); final StatusLine statusLine = response.getStatusLine(); final int statusCode = statusLine.getStatusCode(); if (statusCode == 200) { final HttpEntity entity = response.getEntity(); final InputStream content = entity.getContent(); final BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } reader.close(); content.close(); // Result is an array of tweets final JSONArray arr = (JSONArray) new JSONTokener(builder.toString()).nextValue(); final ArrayList<String[]> tweets = new ArrayList<>(); // Need to grok dates of form "created_at": "Thu, 15 Nov 2012 18:27:17 +0000" final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"); dateFormat.setLenient(true); for (int i = 0; i < arr.length(); i++) { final String text = arr.getJSONObject(i).get("text").toString(); String tweettime = arr.getJSONObject(i).get("created_at").toString(); // Extract & reformat the date Date created; final GregorianCalendar cal = new GregorianCalendar(); try { created = dateFormat.parse(tweettime); cal.setTime(created); String day, mon; day = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()); mon = cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault()); tweettime = String.format("%s %02d:%02d - %s %d", day, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), mon, cal.get(Calendar.DAY_OF_MONTH)); } catch (final Exception e) { Log.d(TAG, "Exception: " + e.getMessage() + ", parsing tweet date `" + tweettime + "'"); tweettime = "--:--"; } tweets.add(new String[] { tweettime, text }); } return tweets; } else { Log.d(TAG, "Failed to download twitter info"); } } catch (final ClientProtocolException e) { Log.d(TAG, "ClientProtocolException: " + e.getMessage() + ", Failed to download twitter info"); } catch (final IOException e) { Log.d(TAG, "IOException: " + e.getMessage() + ", Failed to download twitter info"); } catch (final Exception e) { Log.d(TAG, "Exception: " + e.getMessage() + ", Failed to download twitter info"); } return null; }