Date Parsing Perversion /4

		public static long parseDate(String month,String day,String time_year)
			throws Exception
		{
			int pos_2p;
			try 
			{
				GregorianCalendar calendar = new GregorianCalendar();
				if((pos_2p=time_year.indexOf(":"))!=-1)
					calendar.set(calendar.get(Calendar.YEAR),
					((Month_STR.indexOf(month)+1+4)/4)-1,
					Integer.parseInt(day),
					Integer.parseInt(time_year.substring(0,pos_2p)),
					Integer.parseInt(time_year.substring(pos_2p+1)),
					0);
				else
					calendar.set(Integer.parseInt(time_year),
					((Month_STR.indexOf(month)+1+4)/4)-1,
					Integer.parseInt(day),
					0,0);
					
				return calendar.getTime().getTime();
				
			} 
			catch (Exception e) 
			{
				e.printStackTrace();
			}
			return 0;
		}

.getTime().getTime()

Advertisements

4 responses to “Date Parsing Perversion /4

  • Emanuele

    SimpleDateFormat: who are you?

    • LMC

      An hideous class that toss away creativity from the developers!

      (And what about getTimeInMillis, did you see it?)

      • Emanuele

        Yeah, sure. He/she must have used that instead of getTime().getTime().

        The worst part is the date parsing in my opinion. According to my experience it’s a big mess: prone to errors, hard to debug.

      • LMC

        In fact, he had fail proof’d it by wrapping the whole thing in the try/catch block(Catching Exception… I would go with Throwable, to be sure!). The only way to make it works =)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s