Get Global Date String from Existing/Current String Date
==================
call Function
-------------
getGlobalDateStringFromString("22/11/2016","dd/mm/yyyy");
Function body----------------public String getGlobalDateStringFromString(String strdate,String formatDate) { Date date = Calendar.getInstance().getTime(); if (!strdate.equalsIgnoreCase("")) { SimpleDateFormat formatCompare = new SimpleDateFormat(formatDate); try { date = formatCompare.parse(strdate); } catch (ParseException e) { e.printStackTrace(); } } SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd yyyy hh:mm a zz"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return simpleDateFormat.format(date); }Get Global Date String from Existing/Current Date==================public String getGlobalDateString(Date date) { if (date == null) date = Calendar.getInstance().getTime(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd yyyy hh:mm a zz"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return simpleDateFormat.format(date); }
No comments:
Post a Comment