Created
August 17, 2015 09:21
-
-
Save devrath/76b8186a83f2cb27a134 to your computer and use it in GitHub Desktop.
Getting Data and time seperately
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UtilDateTimeConv { | |
| //FORMAT THE SERVER IS SENDING DATE & TIME ----- > yyyy-MM-dd'T'hh:mm:ss | |
| //////////////////////////// FORMAT - ONE - DETAILS //////////////////////////////// | |
| //FORMAT-ONE-DATE ------------------------------ > MMM dd, yyyy --- > JULY 05, 2015 | |
| //FORMAT-ONE-TIME ------------------------------ > hh:mm a -------- > 5:45 PM | |
| //////////////////////////// FORMAT - ONE - DETAILS //////////////////////////////// | |
| //FORMAT-ONE-DATE | |
| public static String getDateInFormatOne(String str) { | |
| String mDate= CommonFunctions.toDate(str); | |
| String newDateString = null; | |
| DateFormat srcDateFrm = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); | |
| DateFormat destDateFrm = new SimpleDateFormat("MMM dd, yyyy",Locale.ENGLISH); | |
| Date finalDate; | |
| try { | |
| finalDate = srcDateFrm.parse(mDate); | |
| newDateString = destDateFrm.format(finalDate); | |
| System.out.println(newDateString); | |
| } catch (ParseException e) { | |
| e.printStackTrace(); | |
| } | |
| return newDateString; | |
| } | |
| //FORMAT-ONE-TIME | |
| public static String getTimeInFormatOne(String str) { | |
| String mTime=CommonFunctions.toTime(str); | |
| String newTimeString = null; | |
| DateFormat srcTimeFrm = new SimpleDateFormat("hh:mm:ss",Locale.ENGLISH); | |
| DateFormat destTimeFrm = new SimpleDateFormat("hh:mm a",Locale.ENGLISH); | |
| Date finalTime; | |
| try { | |
| finalTime = srcTimeFrm.parse(mTime); | |
| newTimeString = destTimeFrm.format(finalTime); | |
| System.out.println(finalTime); | |
| } catch (ParseException e) { | |
| e.printStackTrace(); | |
| } | |
| return newTimeString; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment