Recently, time has been an issue on the minds of many people. Unfortunately, as far as I can tell, only about half of them installed the software required to deal with the new Daylight Saving schedule. This means that for about three weeks, people trying to share appointments and events will have trouble, at least sometimes.

The real problem is that these intermittent issues will probably only last three weeks and will thereafter be forgotten. Until October. Then, no one will be expecting it. As the poet should have written, time is not on my side.

With that in mind, Mike sends in yet another date function. This one attempts to tell whether a given date is today or not. (If you suspect the previous paragraphs have nothing to do with this snippet, you get a gold star.)

 

  ===================
  //input param date must be in format YYYY?MM?DD
  //where ? might be any character
  //returns "TODAY" or "NOT_TODAY"

  String date = IDataUtil.getString( cursor, "date" );

  String checkMe = date.trim();
  int year = Integer.parseInt( checkMe.substring(0,4) );
  int month = Integer.parseInt( checkMe.substring(5,7) );
  int day = Integer.parseInt( checkMe.substring(8,10) );

  GregorianCalendar today = new GregorianCalendar();
  int currentYear = today.get( GregorianCalendar.YEAR );
  int currentMonth = today.get( GregorianCalendar.MONTH ) + 1;
  int currentDay = today.get( GregorianCalendar.DATE );

  String result = null;

  if( year == currentYear
      && month == currentMonth
      && day == currentDay )
    result = "TODAY";
  else
    result = "NOT_TODAY"; 
  =============

 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!