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:DateFormatDemo.java
static public void displayDate(Locale currentLocale) { Date today;//from w ww .jav a 2s.c om String dateOut; DateFormat dateFormatter; dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale); today = new Date(); dateOut = dateFormatter.format(today); System.out.println(dateOut + " " + currentLocale.toString()); }
From source file:com.vityuk.ginger.provider.format.JdkDateUtils.java
private static int createJdkDateStyleCode(DateFormatStyle formatStyle) { switch (formatStyle) { case SHORT:// ww w. ja va 2 s.c om return DateFormat.SHORT; case MEDIUM: return DateFormat.MEDIUM; case LONG: return DateFormat.LONG; case FULL: return DateFormat.FULL; case DEFAULT: return DateFormat.DEFAULT; default: throw new IllegalArgumentException(); } }
From source file:DateFormatDemo.java
static public void showBothStyles(Locale currentLocale) { Date today;//from w w w . j ava2 s.co m String result; DateFormat formatter; int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL }; System.out.println(); System.out.println("Locale: " + currentLocale.toString()); System.out.println(); today = new Date(); for (int k = 0; k < styles.length; k++) { formatter = DateFormat.getDateTimeInstance(styles[k], styles[k], currentLocale); result = formatter.format(today); System.out.println(result); } }
From source file:net.xisberto.work_schedule.history.HistoryPagerAdapter.java
@Override public CharSequence getPageTitle(int position) { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT); return dateFormat.format(getSelectedDay(position).getTime()); }
From source file:DateFormatDemo.java
static public void showDateStyles(Locale currentLocale) { Date today = new Date(); String result;/*w w w. ja v a 2s . c o m*/ DateFormat formatter; int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL }; System.out.println(); System.out.println("Locale: " + currentLocale.toString()); System.out.println(); for (int k = 0; k < styles.length; k++) { formatter = DateFormat.getDateInstance(styles[k], currentLocale); result = formatter.format(today); System.out.println(result); } }
From source file:DateFormatDemo.java
static public void showTimeStyles(Locale currentLocale) { Date today = new Date(); String result;/*ww w . j a v a 2s. c o m*/ DateFormat formatter; int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL }; System.out.println(); System.out.println("Locale: " + currentLocale.toString()); System.out.println(); for (int k = 0; k < styles.length; k++) { formatter = DateFormat.getTimeInstance(styles[k], currentLocale); result = formatter.format(today); System.out.println(result); } }
From source file:com.arcao.menza.fragment.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); Preference feedBackPref = findPreference("feedback"); feedBackPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/* w ww. j a va 2s. c om*/ public boolean onPreferenceClick(Preference preference) { FeedbackHelper.sendFeedBack(getActivity(), R.string.feedback_email, R.string.feedback_subject, R.string.feedback_message); return true; } }); Preference licensesPref = findPreference("licenses"); licensesPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent i = new Intent(getActivity(), WebViewActivity.class); i.putExtra(WebViewActivity.PARAM_TITLE, R.string.pref_licenses); i.putExtra(WebViewActivity.PARAM_RAW_RESOURCE, R.raw.licenses); startActivity(i); return true; } }); findPreference("version").setSummary(getVersion(getActivity()) + " (" + BuildConfig.GIT_SHA + ")"); try { findPreference("build_time").setSummary(DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, getResources().getConfiguration().locale) .format(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(BuildConfig.BUILD_TIME))); } catch (ParseException e) { Log.e(TAG, e.getMessage(), e); } // fix for Android 2.x updateListPreferenceSummary(PrefConstant.PRICE_GROUP); updateListPreferenceSummary(PrefConstant.DEFAULT_PLACE); }
From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java
@Test public void testValidFormatEmptyLogs() { final String result = converter.convert(new ArrayList<JobLogModel>()); Mockito.verify(formatFactory, Mockito.times(1)).createDateTimeFormat(DateFormat.DEFAULT, -1); Assert.assertTrue(StringUtils.isEmpty(result)); }
From source file:org.jamwiki.utils.DateUtil.java
/** * Given a string, return the matching DateFormat style (SHORT, LONG, etc) * or -1 if there is no corresponding style. */// w ww.j a va2 s .co m public static int stringToDateFormatStyle(String format) { if (StringUtils.equalsIgnoreCase(format, "SHORT")) { return DateFormat.SHORT; } else if (StringUtils.equalsIgnoreCase(format, "MEDIUM")) { return DateFormat.MEDIUM; } else if (StringUtils.equalsIgnoreCase(format, "LONG")) { return DateFormat.LONG; } else if (StringUtils.equalsIgnoreCase(format, "FULL")) { return DateFormat.FULL; } else if (StringUtils.equalsIgnoreCase(format, "DEFAULT")) { return DateFormat.DEFAULT; } return -1; }
From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java
@Test public void testValidFormatLogs() { final String pattern = "dd HH"; converter.setDateFormatPattern(pattern); final Date date = new Date(); final JobLogModel logEntry = new JobLogModel(); logEntry.setCreationtime(date);// ww w . jav a 2s . com logEntry.setLevel(JobLogLevel.FATAL); 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: <empty>" + CharUtils.LF, sdf.format(date))); }