Java Date Parse dateParseFromMyJsFormat(String jsDate)

Here you can find the source of dateParseFromMyJsFormat(String jsDate)

Description

Parse date from my string format to Data source string example - '2014-02-13_00.00.00'

License

Open Source License

Declaration

public static Date dateParseFromMyJsFormat(String jsDate) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static final SimpleDateFormat MY_JS_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");

    /**/* w  ww  .j  a  v a  2s .c om*/
     *  Parse date from my string format to Data
     *  source string example - '2014-02-13_00.00.00'
     */
    public static Date dateParseFromMyJsFormat(String jsDate) throws ParseException {
        /* if string '2014-02-13_00.00' then change it to '2014-02-13_00.00.00'*/

        if (jsDate.split("_")[1].length() == 5) {
            jsDate += ".00";
        }

        return MY_JS_DATE_FORMAT.parse(jsDate);
    }
}

Related

  1. dateFromString(String value)
  2. DateFromStringFormat(final String date, final String format)
  3. dateFromW3CDTF(String date)
  4. dateParse(String date)
  5. dateParse(String date2BeParsed)
  6. dateParser()
  7. dateParser(Date date)
  8. dateParser(String dateStr, String inputDateFormat, String outputDateFormat)
  9. dateParser(String param)