summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java
blob: 3ee326af4c1cc10d05938d2133979ef84ef22444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.openecomp.sdc.vendorlicense;

import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class VendorLicenseUtil {

  private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();

  public static String getIsoFormatDate(String inputDate) {
    mdcDataDebugMessage.debugEntryMessage("inputDate date", inputDate);
    String isoFormatDate = null;
    SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    SimpleDateFormat inputDateFormat = new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss'Z'");

    try {
      isoFormatDate = isoDateFormat.format(inputDateFormat.parse(inputDate));
    } catch (ParseException e) {
      mdcDataDebugMessage.debugExitMessage("parsing error", isoFormatDate);
      isoFormatDate = null;
    }

    mdcDataDebugMessage.debugExitMessage("formatted date", isoFormatDate);
    return isoFormatDate;
  }
}