Date parsing perversion

          private MapDF=new HashMap();
          private ConvertDate CD =new ConvertDate();

          DF.put("ddmmyyyy",new SimpleDateFormat ("ddMMyyyy",Locale.ITALIAN));
          DF.put("yyyymmdd",new SimpleDateFormat ("yyyyMMdd",Locale.ITALIAN));
          DF.put("yymmdd",new SimpleDateFormat ("yyMMdd",Locale.ITALIAN));
          String[] DI=IDS.getString(1).split(" ");
          dateIntervallo=new Date[]{CD.Convert("XXX"+DI[0], "???yyyymmdd"),
		CD.Convert("XXX"+DI[1], "???yyyymmdd")};
          class ConvertDate
                 public Date Convert(String extrDate,String dateTemplate) throws Exception
                      String DT=dateTemplate.substring(dateTemplate.lastIndexOf("?")+1).
				replaceAll("[^a-zA-Z0-9]", "");
                      String date=extrDate.substring(dateTemplate.lastIndexOf("?")+1,
				.replaceAll("[^a-zA-Z0-9]", "");
                      try{return DF.get(DT).parse(date);}
                      catch (Exception e){throw new Exception("Unknown Format Date");}

Add the XXX
Add the ???
Remove the XXX
Remove the ???
Choose a pattern
Change the pattern
Lets it cook for 20 minutes

Actually in the production codebase of a biggest italian TLC company


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s