Java Date Parse DateTimeParse(String DateTimeString, String LMS)

Here you can find the source of DateTimeParse(String DateTimeString, String LMS)

Description

Date Time Parse

License

Creative Commons License

Declaration

public static String DateTimeParse(String DateTimeString, String LMS) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String DateTimeParse(String DateTimeString, String LMS) {
        //System.out.println("DateTimeString: " + DateTimeString);
        String parsedDate = "";
        Date dte = null;//from  w  w w  .  ja va 2  s. c  o  m
        DateFormat formatter = null;
        try {
            // WebCT Example: September 10, 2008 9:51 AM
            // Blackboard 22/02/10 8:37 AM
            // Moodle Tuesday, 23 February 2010, 04:11 pm
            // September 10, 2008 9:51 AM
            // Tuesday,  23 February 2010, 04:11 pm
            // E, dd MMM yyyy HH:mm:ss Z
            // D2L Jul 24, 2010 3:02 AM
            if (LMS.equals("WebCT")) {
                formatter = new SimpleDateFormat("MMM ddd,yyyy hh:mm a");
                dte = (Date) formatter.parse(DateTimeString);
            } else if (LMS.equals("Moodle")) {
                //23 February 2010, 04:11 pm
                formatter = new SimpleDateFormat("ddd MMM yyyy, hh:mm a");
                dte = (Date) formatter.parse(DateTimeString);
            } else if (LMS.equals("Blackboard")) {
                formatter = new SimpleDateFormat("dd/MM/yy hh:mm a");
                dte = (Date) formatter.parse(DateTimeString);
            } else if (LMS.equals("D2L")) {
                formatter = new SimpleDateFormat("MMM ddd, yyyy hh:mm a");
                dte = (Date) formatter.parse(DateTimeString);
            } else if (LMS.equals("US")) {
                formatter = new SimpleDateFormat("MM/dd/yyyy");
                dte = (Date) formatter.parse(DateTimeString);
            } else if (LMS.equals("Angel")) {
                formatter = new SimpleDateFormat("dd/MM/yyyy");
                dte = (Date) formatter.parse(DateTimeString);
            }

            DateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd");
            parsedDate = formatter2.format(dte);
        } catch (ParseException e) {

            System.out.println(e.getMessage());
        }
        return parsedDate;
    }
}

Related

  1. dateStringToDate(String dateString, String DateStringType)
  2. dateStringToDateObject(String dateString, String dateFormat)
  3. datetime(String s)
  4. dateTime(String s)
  5. datetimeParse(String datetime)
  6. getDateFromCurrentAnd24HRTime(Date current, String hr24Time)
  7. getDateFromDateAge(Date currentDate, String age)
  8. getDateFromDatestamp(String datestamp)
  9. getDateFromDateTimeUTCFormat(final String dateString)