Take the 2-minute tour ×

I can't figure this out at all. I did:

int num = ((month-1)*30+day)%134;
              //a,b,c are just for the Log
        String a = String.valueOf(num);
        String b = String.valueOf(month);
        String c = String.valueOf(day);

        num ++;// don't want zero
        String stringnum = String.valueOf(num);

month is todays month, day is today (i.e. december 31st = 12,31). In ANdroid this is taken from CALENDAR. Now this program was working fine until today. Jan 1st. What happens is the DB searches for a string of index num, taken from the date. The problem isnt in the DB, its in this code. Jan 1st is month=0, day = 1, naturally, but after mod 134 I get, courtesy of LogCat:

01-01 12:07:38.554: VERBOSE/variables(6917): -29,0,1

But 1mod134 != -29. I can't understand where -29 comes from.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

When month is 0, (month-1)*30 is -30.

share|improve this answer
add comment

Sorry. I figured it out almost immediately after posting. month = 0, so month -1 = -1. I assumed month would start from 1 and go to 12, not zero to 11. Sorry for wasting anybody's time!

share|improve this answer
yep, an obi-wan error. make 'em every day myself. –  jcomeau_ictx Jan 1 '11 at 3:25
add comment

Your Answer


