Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>the java code:</p> <pre><code>public class CalendarUI { public static String Dias[] = { "", "DOM", "SEG", "TER", "QUA", "QUI", "SEX", "SAB" }; public static String Meses[] = { "JAN", "FEV", "MAR", "ABR", "MAI", "JUN", "JUL", "AGO", "SET", "OUT", "NOV", "DEZ" }; public static void printCalendar(int currMonth){ int i = 1; Calendar c = Calendar.getInstance(); NumberFormat formatter = new DecimalFormat("##00"); c.set(Calendar.YEAR, 2009); c.set(Calendar.MONTH, currMonth); c.set(Calendar.DATE, i); // cabecalho com o mes System.out.println(" - " + Meses[currMonth] + " - "); // ajuste para o primeiro dia for (; i &lt; c.get(Calendar.DAY_OF_WEEK); i++) { System.out.print(" "); } // principal for (i = 1; i &lt;= 31; i++) { c.set(Calendar.DATE, i); if (c.get(Calendar.MONTH) == currMonth) { if (c.get(Calendar.DAY_OF_WEEK) == 1) System.out.println(""); System.out.print("[ " + Dias[c.get(Calendar.DAY_OF_WEEK)] + ", " + formatter.format(i) + " ]"); } } System.out.println("\n\n"); } public static void main(String[] args) { for (int j = 0; j &lt; 12; j++) { CalendarUI.printCalendar(j); } } </code></pre> <hr> <p>the output with correct indent of days in months (example given for may):</p> <pre><code> - MAI - [ SEX, 01 ][ SAB, 02 ] [ DOM, 03 ][ SEG, 04 ][ TER, 05 ][ QUA, 06 ][ QUI, 07 ][ SEX, 08 ][ SAB, 09 ] [ DOM, 10 ][ SEG, 11 ][ TER, 12 ][ QUA, 13 ][ QUI, 14 ][ SEX, 15 ][ SAB, 16 ] [ DOM, 17 ][ SEG, 18 ][ TER, 19 ][ QUA, 20 ][ QUI, 21 ][ SEX, 22 ][ SAB, 23 ] [ DOM, 24 ][ SEG, 25 ][ TER, 26 ][ QUA, 27 ][ QUI, 28 ][ SEX, 29 ][ SAB, 30 ] [ DOM, 31 ] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload