List of usage examples for java.util Calendar AUGUST
int AUGUST
To view the source code for java.util Calendar AUGUST.
Click Source Link
From source file:Main.java
public static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; default:/*from w w w . j a v a 2s . co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:Main.java
public static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29; default://from w w w . j a va 2 s.c om throw new IllegalArgumentException("Invalid Month"); } }
From source file:Main.java
public static String getDateString() { String stringDate = ""; Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); int month = calendar.get(Calendar.MONTH); int dayInt = calendar.get(Calendar.DAY_OF_MONTH); switch (day) { case Calendar.SUNDAY: stringDate += "Sunday"; break;//from w ww .ja v a 2s . co m case Calendar.MONDAY: stringDate += "Monday"; break; case Calendar.TUESDAY: stringDate += "Tuesday"; break; case Calendar.WEDNESDAY: stringDate += "Wednesday"; break; case Calendar.THURSDAY: stringDate += "Thursday"; break; case Calendar.FRIDAY: stringDate += "Friday"; break; case Calendar.SATURDAY: stringDate += "Saturday"; break; } switch (month) { case Calendar.JANUARY: stringDate += ", January"; break; case Calendar.FEBRUARY: stringDate += ", February"; break; case Calendar.MARCH: stringDate += ", March"; break; case Calendar.APRIL: stringDate += ", April"; break; case Calendar.MAY: stringDate += ", May"; break; case Calendar.JUNE: stringDate += ", June"; break; case Calendar.JULY: stringDate += ", July"; break; case Calendar.AUGUST: stringDate += ", August"; break; case Calendar.SEPTEMBER: stringDate += ", September"; break; case Calendar.OCTOBER: stringDate += ", October"; break; case Calendar.NOVEMBER: stringDate += ", November"; break; case Calendar.DECEMBER: stringDate += ", December"; break; } stringDate += (" " + dayInt); return stringDate; }
From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java
/** * {@inheritDoc}//from w w w .j a v a 2s. c o m */ @Override public int getSchuljahr(final Calendar currentDate) { if (currentDate.get(Calendar.MONTH) >= Calendar.AUGUST) { return currentDate.get(Calendar.YEAR) + 1; } else { return currentDate.get(Calendar.YEAR); } }
From source file:is.idega.idegaweb.egov.gumbo.licenses.SetDraganotveidiValidPeriod.java
public void execute(ExecutionContext executionContext) throws Exception { final Interval period; final Calendar now = Calendar.getInstance(); now.set(Calendar.HOUR, 0);//w w w .java 2 s . c om now.set(Calendar.MINUTE, 0); now.set(Calendar.SECOND, 0); now.set(Calendar.MILLISECOND, 0); final Calendar mayStart = Calendar.getInstance(); mayStart.set(now.get(Calendar.YEAR), Calendar.MAY, 1, 0, 0, 0); final Calendar augEnd = Calendar.getInstance(); augEnd.set(now.get(Calendar.YEAR), Calendar.AUGUST, 31, 0, 0, 0); if (now.after(mayStart) && now.before(augEnd)) { period = new Interval(now.getTime(), augEnd.getTime()); } else { period = findNearestPeriod(now); } executionContext.setVariable("date_validityFrom", period.getFrom()); executionContext.setVariable("date_validityTo", period.getTo()); }
From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java
/** * {@inheritDoc}/*from w w w .jav a2 s. c om*/ */ @Override public Halbjahr getHalbjahr(final Calendar currentDate) { if (currentDate.get(Calendar.MONTH) >= Calendar.MARCH && currentDate.get(Calendar.MONTH) < Calendar.AUGUST) { return Halbjahr.Beide_Halbjahre; } else { return Halbjahr.Erstes_Halbjahr; } }
From source file:org.jasig.schedassist.impl.relationship.advising.TermCalculator.java
/** * Calculate the term number for the specified date time (as a {@link Calendar}). * This uses a rough formula to determine Fall/Spring/Summer semesters: <pre>//from w ww.ja va 2 s . co m if the month is between January and May (inclusive), the term is Spring. if the month is between June and August (inclusive), the term is Summer. if the month is between September and December (inclusive), the term is Fall. </pre> * * This is only approximate. * * @param calendar * @return */ public static String calculateTerm(final Calendar calendar) { StringBuilder term = new StringBuilder(); int month = calendar.get(Calendar.MONTH); String monthDigit; if (month >= Calendar.JANUARY && month <= Calendar.MAY) { monthDigit = "4"; } else if (month >= Calendar.JUNE && month <= Calendar.AUGUST) { monthDigit = "6"; } else { monthDigit = "2"; } int year = calendar.get(Calendar.YEAR); if ("2".equals(monthDigit)) { // increment year by one for fall semester year++; } String centuryDigit = "0"; if (year >= 2000) { centuryDigit = "1"; } int twoDigitYear = year % 100; String yearDigit = StringUtils.leftPad(Integer.toString(twoDigitYear), 2, "0"); term.append(centuryDigit); term.append(yearDigit); term.append(monthDigit); return term.toString(); }
From source file:is.idega.idegaweb.egov.gumbo.licenses.SetDraganotveidiValidPeriod.java
private Interval findNearestPeriod(Calendar now) { final int year; if (now.get(Calendar.MONTH) > Calendar.AUGUST) { year = now.get(Calendar.YEAR) + 1; } else {//w w w . j a v a 2 s . com year = now.get(Calendar.YEAR); } final Calendar mayStart = Calendar.getInstance(); mayStart.set(year, Calendar.MAY, 1, 0, 0, 0); final Calendar augEnd = Calendar.getInstance(); augEnd.set(year, Calendar.AUGUST, 31, 0, 0, 0); return new Interval(mayStart.getTime(), augEnd.getTime()); }
From source file:ch.cyberduck.core.ftp.parser.StingrayFTPEntryParserTest.java
/** * http://trac.cyberduck.ch/ticket/1198/* w w w . j a v a2s .com*/ */ @Test public void testFile() { FTPFile parsed; parsed = parser.parseFTPEntry("-r--r--r-- 0 165100 165100 Aug 1 10:24 grau2.tif"); assertNotNull(parsed); assertEquals("grau2.tif", parsed.getName()); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals(Calendar.AUGUST, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(10, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY)); assertEquals(24, parsed.getTimestamp().get(Calendar.MINUTE)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)); }
From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java
/** * {@inheritDoc}/*from w ww . j a v a 2s .c o m*/ */ @Override public Calendar getLeavedSchoolDate(final Calendar currentDate) { final Calendar result = Calendar.getInstance(); if (currentDate.get(Calendar.MONTH) >= Calendar.APRIL && currentDate.get(Calendar.MONTH) < Calendar.OCTOBER) { result.set(currentDate.get(Calendar.YEAR), Calendar.FEBRUARY, 1, 0, 0, 0); } else if (currentDate.get(Calendar.MONTH) < Calendar.APRIL) { result.set(currentDate.get(Calendar.YEAR) - 1, Calendar.AUGUST, 1, 0, 0, 0); } else { result.set(currentDate.get(Calendar.YEAR), Calendar.AUGUST, 1, 0, 0, 0); } result.set(Calendar.MILLISECOND, 0); return result; }