@Test public void testDaysInMonth_february_nbOfDaysShouldAdaptAccordingToYear() throws Exception { assertThat(Utilities.daysInMonth(2400, 2), is(29)); assertThat(Utilities.daysInMonth(1996, 2), is(29)); assertThat(Utilities.daysInMonth(2003, 2), is(28)); }
protected static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: daysInMonth = 30; } return daysInMonth; }
Utilities { protected static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: daysInMonth = 30; } return daysInMonth; } }
Utilities { protected static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: daysInMonth = 30; } return daysInMonth; }  }
Utilities { protected static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: daysInMonth = 30; } return daysInMonth; }  static void setTmpPath(String tmp_path); static String getTmpPath(); static void updateDates(String fromDate, String untilDate); static boolean isValidDate(String dateString); static String completeDate(String date); static String toString(Document doc); static String innerXmlToString(Node node); static Element findNode(String attribut, String value, NodeList orgs); static void generateIDs(Document doc); static void trimEOL(Node node, Document doc); static void clearTmpDirectory(); static String storeTmpFile(InputStream inBinary); static String storeToTmpXmlFile(InputStream inBinary); static void getBinaryURLContent(File file, InputStream in); static String formatDate(Date date); static Date parseStringDate(String dateString); static String getHalIDFromHalDocID(String halDocID); static String getVersionFromURI(String uri); static String getHalURIFromFilename(String filename); static Set<String> getDates(); static String trimEncodedCharaters(String string); static void unzipIt(String file, String outPath); static String readFile(String fileName); static InputStream request(String request); static String formatXMLString(String xmlString); static void checkPath(String path); static String convertStreamToString(InputStream is); final static String removeAccents(String input); final static Element getElementByAttribute(String attr, String value, Element root); static Element matchAuthor(String fullname, NodeList authorsFromfulltextTeiHeader); }
Utilities { protected static int daysInMonth(int year, int month) { int daysInMonth; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break; case 2: if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { daysInMonth = 29; } else { daysInMonth = 28; } break; default: daysInMonth = 30; } return daysInMonth; }  static void setTmpPath(String tmp_path); static String getTmpPath(); static void updateDates(String fromDate, String untilDate); static boolean isValidDate(String dateString); static String completeDate(String date); static String toString(Document doc); static String innerXmlToString(Node node); static Element findNode(String attribut, String value, NodeList orgs); static void generateIDs(Document doc); static void trimEOL(Node node, Document doc); static void clearTmpDirectory(); static String storeTmpFile(InputStream inBinary); static String storeToTmpXmlFile(InputStream inBinary); static void getBinaryURLContent(File file, InputStream in); static String formatDate(Date date); static Date parseStringDate(String dateString); static String getHalIDFromHalDocID(String halDocID); static String getVersionFromURI(String uri); static String getHalURIFromFilename(String filename); static Set<String> getDates(); static String trimEncodedCharaters(String string); static void unzipIt(String file, String outPath); static String readFile(String fileName); static InputStream request(String request); static String formatXMLString(String xmlString); static void checkPath(String path); static String convertStreamToString(InputStream is); final static String removeAccents(String input); final static Element getElementByAttribute(String attr, String value, Element root); static Element matchAuthor(String fullname, NodeList authorsFromfulltextTeiHeader);  }