Friday, July 4, 2014

DATE PARSING

DATE PARSING

Today i am going to explain to you about date parsing based on the date format so if you are a java developer and trying to parse the date based on the format u want you can try this example.

The date format is SimpleDateFormat("hh:mm a E, MMM. dd yyyy");
then you can parse the date in the following way.


    function parseOptions(dateTime){   
         date = dateTime.substr(10, dateTime.length);
          var n = date.indexOf("&Modify");
          var time = date.substr(0,12);
          var dateField = date.substr(1, (n-1));
          var modfyField = date.substr(n, date.length);
          var dtF = dateField.indexOf(",");
          dtMonFormat = dateField.substr(dtF+1, n);
          dttF = GetDate(dtMonFormat);
          timeDate = time+" "+dttF;
          var options='<option value="'+timeDate+'">'+timeDate+'</option>';
          $("select#wkUpSel").append(options);
           
        }

function GetDate(str) {
         var arr = str.split('.');
           var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
           var i = 1;
      
           for (i; i <= months.length; i++) {
           if (months[i] == trimString(arr[0])){
           break;
            }
         }
      
          var ddyy = trimString(arr[1]);
          arrayDDYY = ddyy.split(' ');
           var formatddate = (i+1) + '/' +arrayDDYY[0]+'/'+arrayDDYY[1];
           return formatddate;
        }

No comments:

Easy Way to Handle Android Notifications

Android Notifications Android Toast class provides a handy way to show users alerts but problem is that these alerts are not persist...