List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance(int style)
From source file:Main.java
public static String getPrettyDate(int year, int month, int day) { Calendar c = new GregorianCalendar(year, month, day); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG); return dateFormat.format(c.getTime()); }
From source file:Main.java
public static String dateFormat(Date date, int format) { DateFormat dateFormat1 = DateFormat.getDateInstance(format); return dateFormat1.format(date); }
From source file:Main.java
public static String normalizeDate(String rDate) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.US); Date date = null;// w w w . j a va2s . com try { date = simpleDateFormat.parse(rDate); } catch (ParseException e) { e.printStackTrace(); } return DateFormat.getDateInstance(DateFormat.LONG).format(date); }
From source file:DateUtils.java
/** * A method to get the current date to use in a timestamp * * @return a string containing the timestamp */// w w w . j a va2 s . c o m public static String getCurrentDate() { GregorianCalendar calendar = new GregorianCalendar(); DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL); return formatter.format(calendar.getTime()); }
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:jgnash.ui.commodity.SecurityItemLabelGenerator.java
/** * Creates an item label generator using the default date and number * formats./*w ww . j av a2s . c om*/ * @param node SecurityNode to base format on */ public SecurityItemLabelGenerator(final SecurityNode node) { this(DateFormat.getDateInstance(DateFormat.SHORT), CommodityFormat.getShortNumberFormat(node.getReportedCurrencyNode())); }
From source file:com.espian.ticktock.CountdownFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getArguments() == null) throw new IllegalArgumentException("No args supplied for fragment"); try {//from w w w . j a v a2 s .com final Date date = DateFormat.getDateInstance(DateFormat.LONG).parse(getArguments().getString("date")); mIdAsString = getArguments().getString(BaseColumns._ID); mLabelView.setText(mLabel = getArguments().getString("label")); mDateView.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date)); mHelper = new LoadHideHelper(this); new Thread(new Runnable() { @Override public void run() { // Requires an ugly fudge because, for some reason, the Days class accesses // the disk through random access, which throws errors with StrictMode. int days = Days.daysBetween(new DateTime(new Date()), new DateTime(date)).getDays(); Bundle b = new Bundle(); b.putString("result", String.valueOf(days + 1)); Message m = Message.obtain(asyncHandler); m.setData(b); asyncHandler.sendMessage(m); } }).start(); } catch (ParseException e) { Toast.makeText(getActivity(), "Malformed date was stored", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } //getActivity().getLoaderManager().initLoader(TickTockProvider.LOADER_SINGLE_ITEM, getArguments(), this); }
From source file:com.liferay.mobile.sample.model.Contact.java
protected DateFormat getDateFormatter() { if (_formatter == null) { _formatter = DateFormat.getDateInstance(DateFormat.LONG); } return _formatter; }
From source file:org.hippoecm.frontend.plugins.cms.dashboard.EventModel.java
public EventModel(JcrNodeModel eventNode) { this(eventNode, null, DateFormat.getDateInstance(DateFormat.SHORT)); }
From source file:org.metawidget.example.struts.addressbook.converter.ToStringConverter.java
@SuppressWarnings("rawtypes") public Object convert(Class clazz, Object value) { if (value == null || "".equals(value)) { return null; }//from w w w . j a v a2 s . com // Convert enums to their .name() form, not their .toString() form, so that we can // use .valueOf() in EnumConverter. if (value instanceof Enum) { return ((Enum) value).name(); } // Do the Date toString here, as unfortunately it seems // org.apache.commons.beanutils.converters.DateConverter.convertToString never // gets called? if (value instanceof Date) { return DateFormat.getDateInstance(DateFormat.SHORT).format((Date) value); } return value.toString(); }