Monthly Archives: July 2011

The hard way

If you have to initialize a boolean, you can use ‘true’ or ‘false’. It’s easy.

But if you feel a little more fancy you can use something like that:

	boolean result = (IU.getId_profile()+"-"+IU.getId_project()+"-"+IU.getId_LEV())
		  .equals(IU.getId_profile()+"-"+IU.getId_project()+"-"+IU.getId_LEV());


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()