Get Date String from Existing/Current String Date
==================
==================
public String getDateStringFromFormatString(String strdate,String formate,String formate1) {
Date date = Calendar.getInstance().getTime(); if (!strdate.equalsIgnoreCase("")) { SimpleDateFormat formatCompare = new SimpleDateFormat(formate1); try { date = formatCompare.parse(strdate); } catch (ParseException e) { date = Calendar.getInstance().getTime(); e.printStackTrace(); } } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formate, Locale.getDefault()); return simpleDateFormat.format(date); }
Call
================
getDateStringFromFormatString("","MMM dd, yyyy",""); // get current date in your format
No comments:
Post a Comment