[ 
https://issues.apache.org/jira/browse/LANG-1377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Darko Palic updated LANG-1377:
------------------------------
    Description: 
I have following example to parse dates. The parsing fails in the given cases.
{quote}@Test
 public void dateFormatParseStrictTest() throws ParseException {

      String[] lMessageDateStrArray = new String [ ]  {
            "03.05.2017 08:05:15",
            "03.05.17 09:05:15",
            "13:05:15 03.05",
            "03.05 07:05",
            "03.05 09:05:15"
      };

      String lDateFormatCommon1 = "dd.MM.yyyy hh:mm:ss";
      String lDateFormatCommon2 = "dd.MM.yy hh:mm:ss";
      // fallback formats
      String lDateFormatStrange1 = "hh:mm dd.MM";
      String lDateFormatStrange2 = "dd.MM hh:mm";
      String lDateFormatStrange3 = "dd.MM hh:mm:ss";

      for (String lMessageDateStr : lMessageDateStrArray) {
         Date lMessageDate = DateUtils.parseDateStrictly(lMessageDateStr, 
Locale.GERMAN, lDateFormatCommon1, lDateFormatCommon2, lDateFormatStrange1,
               lDateFormatStrange2, lDateFormatStrange3);
      }


}{quote}

  was:
I have following example to parse dates. The parsing fails in the given cases.
{quote}@Test
 public void dateFormatParseStrictTest() throws ParseException {
      String[] lMessageDateStrArray = new String[] {
            "03.05.2017 08:05:15",
            "03.05.17 09:05:15",
            "13:05:15 03.05",
            "03.05 07:05",
            "03.05 09:05:15"
      };

      String lDateFormatCommon1 = "dd.MM.yyyy hh:mm:ss";
      String lDateFormatCommon2 = "dd.MM.yy hh:mm:ss";
      // fallback formats
      String lDateFormatStrange1 = "hh:mm dd.MM";
      String lDateFormatStrange2 = "dd.MM hh:mm";
      String lDateFormatStrange3 = "dd.MM hh:mm:ss";

      for (String lMessageDateStr : lMessageDateStrArray) {
         Date lMessageDate = DateUtils.parseDateStrictly(lMessageDateStr, 
Locale.GERMAN, lDateFormatCommon1, lDateFormatCommon2, lDateFormatStrange1,
               lDateFormatStrange2, lDateFormatStrange3);
      }

}
{quote}


> DateUtils.parseDateStrictly is not working properly
> ---------------------------------------------------
>
>                 Key: LANG-1377
>                 URL: https://issues.apache.org/jira/browse/LANG-1377
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 3.7
>            Reporter: Darko Palic
>            Priority: Major
>
> I have following example to parse dates. The parsing fails in the given cases.
> {quote}@Test
>  public void dateFormatParseStrictTest() throws ParseException {
>       String[] lMessageDateStrArray = new String [ ]  {
>             "03.05.2017 08:05:15",
>             "03.05.17 09:05:15",
>             "13:05:15 03.05",
>             "03.05 07:05",
>             "03.05 09:05:15"
>       };
>       String lDateFormatCommon1 = "dd.MM.yyyy hh:mm:ss";
>       String lDateFormatCommon2 = "dd.MM.yy hh:mm:ss";
>       // fallback formats
>       String lDateFormatStrange1 = "hh:mm dd.MM";
>       String lDateFormatStrange2 = "dd.MM hh:mm";
>       String lDateFormatStrange3 = "dd.MM hh:mm:ss";
>       for (String lMessageDateStr : lMessageDateStrArray) {
>          Date lMessageDate = DateUtils.parseDateStrictly(lMessageDateStr, 
> Locale.GERMAN, lDateFormatCommon1, lDateFormatCommon2, lDateFormatStrange1,
>                lDateFormatStrange2, lDateFormatStrange3);
>       }
> }{quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to