List of usage examples for java.util Calendar WEEK_OF_MONTH
int WEEK_OF_MONTH
To view the source code for java.util Calendar WEEK_OF_MONTH.
Click Source Link
get
and set
indicating the week number within the current month. From source file:Main.java
public static int getNumberOfWeeksInCurrentMonth() { Calendar calendar = getCalendarWithTime(getStartOfCurrentMonth()); return calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); }
From source file:Main.java
public static int getNumberOfWeeksInMonth(int year, int month) { Calendar calendar = Calendar.getInstance(Locale.FRANCE); calendar.set(year, month, 1, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); }
From source file:Main.java
public static String week() { // Create calendar instance Calendar calendar = Calendar.getInstance(); System.out.println("Current week of this month = " + calendar.get(Calendar.WEEK_OF_MONTH)); System.out.println("Current week of this year = " + calendar.get(Calendar.WEEK_OF_YEAR)); return ""; }
From source file:Main.java
public static int getWeekOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww .j av a 2 s .c o m*/ return cal.get(Calendar.WEEK_OF_MONTH); }
From source file:Main.java
public static void addCalendarWeek(Calendar cal, int weeks) { cal.add(Calendar.WEEK_OF_MONTH, weeks); }
From source file:Main.java
public static int getWeekOfMonth() { Calendar calendar = Calendar.getInstance(); int week = calendar.get(Calendar.WEEK_OF_MONTH); return week - 1; }
From source file:Main.java
public static void moveToCalendarWeekOfMonth(Calendar cal, int weekOfMonth) { assertArgumentNotMinusInteger("weekOfMonth", weekOfMonth); cal.set(Calendar.WEEK_OF_MONTH, weekOfMonth); }
From source file:com.milos.neo4j.dao.impl.GameDAOImpl.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRED) @Override//from w w w. java 2 s . com public void deleteOldGames() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.WEEK_OF_MONTH, -1); String deleteQuery = "MATCH (n:UserGameScores)--(g:Game) where g.creationDate <= {date} detach delete n, g"; Map<String, Long> params = new HashMap<>(); params.put("date", calendar.getTimeInMillis()); session.query(deleteQuery, params, false); }
From source file:CalendarDemo.java
public void format() { // Tell the calendar what date/time to format calendar.setTime(timeNow);/* w w w . ja va2 s . c o m*/ // print out most of the known fields System.out.println("ERA: " + calendar.get(Calendar.ERA)); System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR)); System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH)); System.out.println("DATE: " + calendar.get(Calendar.DATE)); System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH)); System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR)); System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK)); System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); System.out.println("HOUR: " + calendar.get(Calendar.HOUR)); System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY)); System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE)); System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND)); System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000))); System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET) / (60 * 60 * 1000))); }
From source file:org.kalypso.commons.time.PeriodUtils.java
public static Period getPeriod(final int calendarField, final int amount) { switch (calendarField) { case Calendar.YEAR: return Period.years(amount); case Calendar.MONTH: return Period.months(amount); case Calendar.WEEK_OF_YEAR: case Calendar.WEEK_OF_MONTH: return Period.weeks(amount); case Calendar.DAY_OF_MONTH: case Calendar.DAY_OF_YEAR: case Calendar.DAY_OF_WEEK: case Calendar.DAY_OF_WEEK_IN_MONTH: return Period.days(amount); case Calendar.HOUR: case Calendar.HOUR_OF_DAY: return Period.hours(amount); case Calendar.MINUTE: return Period.minutes(amount); case Calendar.SECOND: return Period.seconds(amount); case Calendar.MILLISECOND: return Period.millis(amount); case Calendar.AM_PM: case Calendar.ERA: default://from w w w . j a v a2 s. co m throw new UnsupportedOperationException(); } }