List of usage examples for java.text DateFormat DEFAULT
int DEFAULT
To view the source code for java.text DateFormat DEFAULT.
Click Source Link
From source file:de.perdian.commons.lang.conversion.impl.converters.StringToDateConverter.java
@Override protected DateFormat resolveDefaultFormat(Locale locale) { String pattern = this.getPattern(); if (pattern != null) { return new SimpleDateFormat(pattern, locale); } else {/* ww w .j a v a2 s . c om*/ Class<? extends Date> targetDateClass = this.getTargetDateClass(); if (targetDateClass == null || targetDateClass.equals(java.util.Date.class) || targetDateClass.equals(java.sql.Date.class)) { return DateFormat.getDateInstance(DateFormat.DEFAULT, locale); } else if (targetDateClass.equals(java.sql.Timestamp.class)) { return DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale); } else if (targetDateClass.equals(java.sql.Time.class)) { return DateFormat.getTimeInstance(DateFormat.DEFAULT, locale); } else { return DateFormat.getInstance(); } } }
From source file:dev.memento.MementoClient.java
/** * //from w w w. jav a 2s .c o m */ public MementoClient() { // Set the date and time format SimpleDateTime.mDateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US); SimpleDateTime.mTimeFormat = DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.US); // Holds all the timemaps for the web page being viewed mTimeMaps = new HashSet<TimeMap>(); mMementos = new MementoList(); }
From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java
@Test public void testValidFormatLogsWithEntries() { final String pattern = "dd HH"; converter.setDateFormatPattern(pattern); final StringBuilder messageBuilder = new StringBuilder(1000); for (int i = 0; i < 5; i++) { messageBuilder.append("message" + i + CharUtils.LF); }/* w w w . j a v a 2s . co m*/ final Date date = new Date(); final JobLogModel logEntry = new JobLogModel(); logEntry.setCreationtime(date); logEntry.setLevel(JobLogLevel.FATAL); logEntry.setMessage(messageBuilder.toString()); final List<JobLogModel> entries = Arrays.asList(logEntry); final String result = converter.convert(entries); Mockito.verify(formatFactory, Mockito.times(1)).createDateTimeFormat(DateFormat.DEFAULT, -1); final SimpleDateFormat sdf = (SimpleDateFormat) formatFactory.createDateTimeFormat(DateFormat.DEFAULT, -1); sdf.applyPattern(pattern); Assert.assertEquals(result, String.format("%s: FATAL: " + messageBuilder.toString(), sdf.format(date))); }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
static void resetLocale() { NUMBER_FORMAT0 = NumberFormat.getNumberInstance(GUIMediator.getLocale()); NUMBER_FORMAT0.setMaximumFractionDigits(0); NUMBER_FORMAT0.setMinimumFractionDigits(0); NUMBER_FORMAT0.setGroupingUsed(true); NUMBER_FORMAT1 = NumberFormat.getNumberInstance(GUIMediator.getLocale()); NUMBER_FORMAT1.setMaximumFractionDigits(1); NUMBER_FORMAT1.setMinimumFractionDigits(1); NUMBER_FORMAT1.setGroupingUsed(true); DATETIME_FORMAT = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, GUIMediator.getLocale());// ww w . j ava 2 s . com FULL_DATETIME_FORMAT = new SimpleDateFormat("EEE, MMM. d, yyyy h:mm a", GUIMediator.getLocale()); GENERAL_UNIT_KILOBYTES = I18n.tr("KB"); GENERAL_UNIT_MEGABYTES = I18n.tr("MB"); GENERAL_UNIT_GIGABYTES = I18n.tr("GB"); GENERAL_UNIT_TERABYTES = I18n.tr("TB"); GENERAL_UNIT_KBPSEC = I18n.tr("KB/s"); }
From source file:me.taylorkelly.mywarp.bukkit.commands.printer.InfoPrinter.java
/** * Gets information text.// ww w .j av a 2s. c om * * @param receiver the Actor who will receive the text * @return the text */ public String getText(Actor receiver) { StrBuilder info = new StrBuilder(); // heading info.append(ChatColor.GOLD); info.append(MESSAGES.getString("info.heading", ChatColor.getByChar(warp.getType().getColorCharacter()) + warp.getName() + ChatColor.GOLD)); info.appendNewLine(); // creator info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.created-by")); info.append(" "); info.append(ChatColor.WHITE); Profile creator = warp.getCreator(); info.append(creator.getName().or(creator.getUniqueId().toString())); if (receiver instanceof LocalPlayer && warp.isCreator((LocalPlayer) receiver)) { info.append(" "); info.append(MESSAGES.getString("info.created-by-you")); } info.appendNewLine(); // location info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.location")); info.append(" "); info.append(ChatColor.WHITE); info.append(MESSAGES.getString("info.location.position", warp.getPosition().getFloorX(), warp.getPosition().getFloorY(), warp.getPosition().getFloorZ(), warp.getWorld().getName())); info.appendNewLine(); // if the warp is modifiable, show information about invitations if (warp.isModifiable(receiver)) { // invited players info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.invited-players")); info.append(" "); info.append(ChatColor.WHITE); Set<Profile> invitedPlayers = warp.getInvitedPlayers(); if (invitedPlayers.isEmpty()) { info.append("-"); } else { List<String> invitedPlayerNames = new ArrayList<String>(); for (Profile profile : invitedPlayers) { invitedPlayerNames.add(profile.getName().or(profile.getUniqueId().toString())); } Collections.sort(invitedPlayerNames); info.appendWithSeparators(invitedPlayerNames, ", "); } info.appendNewLine(); // invited groups info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.invited-groups")); info.append(" "); info.append(ChatColor.WHITE); List<String> invitedGroups = Ordering.natural().sortedCopy(warp.getInvitedGroups()); if (invitedGroups.isEmpty()) { info.append("-"); } else { info.appendWithSeparators(invitedGroups, ", "); } info.appendNewLine(); } // creation date info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.creation-date", warp.getCreationDate())); info.append(" "); info.append(ChatColor.WHITE); info.append(DateFormat.getDateInstance(DateFormat.DEFAULT, LocaleManager.getLocale()) .format(warp.getCreationDate())); info.appendNewLine(); // visits info.append(ChatColor.GRAY); info.append(MESSAGES.getString("info.visits")); info.append(" "); info.append(ChatColor.WHITE); info.append(MESSAGES.getString("info.visits.per-day", warp.getVisits(), warp.getVisitsPerDay())); return info.toString(); }
From source file:org.apache.click.util.Format.java
/** * Return a formatted current date string using the default DateFormat. * * @return a formatted date string//from w w w . j a v a 2s .c om */ public String currentDate() { DateFormat format = DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale()); return format.format(new Date()); }
From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java
@Test public void testValidFormatLogsWithEntriesTruncated() { final String pattern = "dd HH"; converter.setDateFormatPattern(pattern); final StringBuilder messageFromLogs = new StringBuilder(1000); for (int i = 0; i < 15; i++) { messageFromLogs.append("message" + i + CharUtils.LF); }//from ww w .java 2 s . c o m final StringBuilder messageExpected = new StringBuilder(1000); for (int i = 0; i < 10; i++) { messageExpected.append("message" + i + (i == 9 ? "" : String.valueOf(CharUtils.LF))); } messageExpected.append(" ..." + CharUtils.LF); final Date date = new Date(); final JobLogModel logEntry = new JobLogModel(); logEntry.setCreationtime(date); logEntry.setLevel(JobLogLevel.FATAL); logEntry.setMessage(messageFromLogs.toString()); final List<JobLogModel> entries = Arrays.asList(logEntry); final String result = converter.convert(entries); Mockito.verify(formatFactory, Mockito.times(1)).createDateTimeFormat(DateFormat.DEFAULT, -1); final SimpleDateFormat sdf = (SimpleDateFormat) formatFactory.createDateTimeFormat(DateFormat.DEFAULT, -1); sdf.applyPattern(pattern); Assert.assertEquals(result, String.format("%s: FATAL: " + messageExpected.toString(), sdf.format(date))); }
From source file:org.sonar.core.i18n.DefaultI18n.java
/** * Format date for the given locale. JVM timezone is used. *///from ww w . j av a 2 s.co m @Override public String formatDateTime(Locale locale, Date date) { return DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT, locale).format(date); }
From source file:org.sonar.core.i18n.DefaultI18n.java
@Override public String formatDate(Locale locale, Date date) { return DateFormat.getDateInstance(DateFormat.DEFAULT, locale).format(date); }
From source file:be.brunoparmentier.openbikesharing.app.activities.StationsListActivity.java
private void setDBLastUpdateText() { TextView lastUpdate = (TextView) findViewById(R.id.dbLastUpdate); long dbLastUpdate = settings.getLong(PREF_KEY_DB_LAST_UPDATE, -1); if (dbLastUpdate == -1) { lastUpdate.setText(//from ww w.ja v a 2 s . com String.format(getString(R.string.db_last_update), getString(R.string.db_last_update_never))); } else { lastUpdate.setText(String.format(getString(R.string.db_last_update), DateUtils.formatSameDayTime( dbLastUpdate, System.currentTimeMillis(), DateFormat.DEFAULT, DateFormat.DEFAULT))); } }