Fórum Calculando o ano bissexto #568207
09/04/2009
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public static void main(String[] args) { int year = 2200; /** Os nomes dos meses */ String[] months = { "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }; int dom[] = { 31, 28, 31, 30, /* jan fev mar abr */ 31, 30, 31, 31, /* mai jun jul ago */ 30, 31, 30, 31 /* set out nov dez */ }; /** Os dias em cada mes */ if (year % 400 == 0) { dom[1] = 29; } else { if(year%4 == 0 && year%100!=0){ dom[1] = 29; } } System.out.println("Resultado: " + dom[1] ); } |

Dalton
Curtir tópico
+ 0Posts
09/04/2009
Vitor Pamplona
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import java.util.Calendar; public class Main { public static void main(String[] args) { System.out.println(getMaxDiasFevereiro(2004)); } public static int getMaxDiasFevereiro(int year) { Calendar cal = (Calendar) Calendar.getInstance().clone(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, 1); // Fevereiro return cal.getActualMaximum(Calendar.DAY_OF_MONTH); } } |
Gostei + 0
09/04/2009
Vitor Pamplona
1 2 3 4 5 6 7 8 9 | /** * @author Lucastex - lucas@javafree.com.br */ import java.util.GregorianCalendar; public class Bissexto { public static void main(String[] args) { System.out.println(new GregorianCalendar().isLeapYear(2004)); } } |
Gostei + 0
09/04/2009
Vitor Pamplona
Gostei + 0
09/04/2009
Vitor Pamplona
Gostei + 0
09/04/2009
Vitor Pamplona
1 2 3 | public boolean torcedorIgualATime() { return dalton.equals(gremio); } |
Gostei + 0
09/04/2009
Vitor Pamplona
Gostei + 0
09/04/2009
Vitor Pamplona
1 | System.out.println("Resultado: " + dom[1]); |
Gostei + 0
09/04/2009
Vitor Pamplona
1 | System.out.println("Resultado: " + dom[1]); |
1 2 3 4 5 6 7 | if (year % 400 == 0) { Bissexto! } else { if(year%4 == 0 && year%100!=0){ Bissexto! } } |
1 | System.out.println(new GregorianCalendar().isLeapYear(2004)); |
Gostei + 0
09/04/2009
Vitor Pamplona
1 | System.out.println(new GregorianCalendar().isLeapYear(2004)); |