poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Reichel <andr...@manticore-projects.com>
Subject Re: DateDif
Date Tue, 24 Feb 2015 10:00:42 GMT
Dear All,

as I was just working with time gaps, perhaps the following template
might be helpful:

private static int getTimeGap(Date d1, Date d2) {
    int tg = 0;
    int increment = d1.before(d2)
            ? 1
            : -1;
    Calendar cal1 = GregorianCalendar.getInstance();
    cal1.setTime(d1);
    cal1.set(Calendar.HOUR_OF_DAY, 12);
    cal1.set(Calendar.MINUTE, 0);
    cal1.set(Calendar.SECOND, 0);
    cal1.set(Calendar.MILLISECOND, 0);

    Calendar cal2 = GregorianCalendar.getInstance();
    cal2.setTime(d2);
    cal2.set(Calendar.HOUR_OF_DAY, 12);
    cal2.set(Calendar.MINUTE, 0);
    cal2.set(Calendar.SECOND, 0);
    cal2.set(Calendar.MILLISECOND, 0);

    while (cal1.compareTo(cal2) != 0) {
      cal1.add(Calendar.DATE, increment);
      tg += increment;
    }
    return tg;
  }

Best regards
Andreas

On Tue, 2015-02-24 at 09:38 +0000, Nick Burch wrote:
> On Mon, 23 Feb 2015, Blake Watson wrote:
> > So, I hit my first unimplemented function: DateDif
> >
> > I'm curious as to why it's not implemented.
> 
> Because no-one has got round to volunteering a contribution to add it!
> 
> (All the functions used in my $DAYJOB spreadsheets which need POI 
> evaluation are implemented, as I suspect they are for the other 
> contributors to the project so far. We're all volunteers here, so we all 
> work on the things that matter to us)
> 
> 
> If this function matters to you, we'd love a patch! A rough guide to 
> contributing is available at http://poi.apache.org/guidelines.html - a 
> patch plus unit test would be wonderful. If you're new to Excel formula 
> evaluation in POI, then this talk from Yegor from a few years ago is 
> probably the best into we have:
> http://people.apache.org/~yegor/apachecon_us2010/Evaluation_Of_Excel_Formulas_In_POI.pptx
> 
> Please do implement this missing function, and any others too that 
> interest you!
> 
> Thanks
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message