It would be something + or - like... But it’s just the same logic, because I didn’t write in an IDE... n I can say that the code is right ^^
//Aqui temos uma função que retornará uma variável do tipo inteiro
public int converterData(int _dia, int _mes){
//Aqui uma variável que vai armazenar o número de dias até aquela data
int quantidadeDias = (((_mes - 1) * 30) + _dia);
//Aqui dividimos por 7, ou seja, 7 dias na semana para saber o número de semanas
int numeroSemana = (quantidadeDias / 7);
//Aqui só retornamos a resposta
return numeroSemana;
}
To call the function you will do something like this:
//Pronto, você já tem a resposta de qual semana vai ser no dia 05 de dezembro
int resposta = converterData(5,12);
The logic is basically this, but it will never return you the right answer because normally the year starts with the first week in December of last year...
This is certainly not the best way... I believe that java should have some lib for calendars
Take a look here: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=java%20get%20week%20number
Many people have had the same doubt, you can find something ;)
But I think it makes a difference, right? The proposal is that every month of the year is 30 days.
– Marcio.Rezende