List of usage examples for java.util Calendar DAY_OF_WEEK_IN_MONTH
int DAY_OF_WEEK_IN_MONTH
To view the source code for java.util Calendar DAY_OF_WEEK_IN_MONTH.
Click Source Link
get
and set
indicating the ordinal number of the day of the week within the current month. From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); System.out.println(now.get(Calendar.DAY_OF_WEEK_IN_MONTH)); }
From source file:MainClass.java
public static void main(String[] a) { Calendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); 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_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("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:DayWeek.java
public static void main(String[] av) { //+/* w w w. j av a 2 s . c o m*/ Calendar c = Calendar.getInstance(); // today System.out.println("Year: " + c.get(Calendar.YEAR)); System.out.println("Month: " + c.get(Calendar.MONTH)); System.out.println("Day: " + c.get(Calendar.DAY_OF_MONTH)); System.out.println("Day of week = " + c.get(Calendar.DAY_OF_WEEK)); System.out.println("Day of year = " + c.get(Calendar.DAY_OF_YEAR)); System.out.println("Week in Year: " + c.get(Calendar.WEEK_OF_YEAR)); System.out.println("Week in Month: " + c.get(Calendar.WEEK_OF_MONTH)); System.out.println("Day of Week in Month: " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("Hour: " + c.get(Calendar.HOUR)); System.out.println("AM or PM: " + c.get(Calendar.AM_PM)); System.out.println("Hour (24-hour clock): " + c.get(Calendar.HOUR_OF_DAY)); System.out.println("Minute: " + c.get(Calendar.MINUTE)); System.out.println("Second: " + c.get(Calendar.SECOND)); //- }
From source file:Main.java
public static int getWeekOfMonth() { return Calendar.getInstance().get(Calendar.DAY_OF_WEEK_IN_MONTH); }
From source file:Main.java
public static int getWeekOfMonth() { return calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH); }
From source file:CalendarDemo.java
public void format() { // Tell the calendar what date/time to format calendar.setTime(timeNow);//from w ww . j av a 2 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:com.apress.progwt.server.web.controllers.SignupIfPossibleController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse arg1) throws Exception { if (userService.nowAcceptingSignups()) { Map<String, Object> model = new HashMap<String, Object>(); CreateUserRequestCommand comm = new CreateUserRequestCommand(); Calendar c = Calendar.getInstance(); c.get(Calendar.DAY_OF_WEEK_IN_MONTH); String secretKey = CryptUtils .hashString(invitationService.getSalt() + c.get(Calendar.DAY_OF_WEEK_IN_MONTH)); model.put("hideSecretKey", true); model.put("secretkey", secretKey); if (req.getServletPath().contains("2")) { return new ModelAndView("redirect:signup2.html", model); } else {// ww w .ja v a2s. c o m return new ModelAndView("redirect:signup.html", model); } } else { return new ModelAndView(getMailingListView()); } }
From source file:com.gsr.myschool.server.job.impl.ExpiredDossierJobImpl.java
@Override public void work() { SimpleDateFormat dateformat = new SimpleDateFormat(GlobalParameters.DATE_FORMAT); logger.info("Job started at " + dateformat.format(new Date())); int number = 0; DossierFilterDTO filter = new DossierFilterDTO(); filter.setStatus(DossierStatus.CREATED); List<Dossier> dossiers = dossierService.findAllDossiersByCriteria(filter, null, null).getDossiers(); for (Dossier dossier : dossiers) { // ne supprimer que les dossier cres non soumis des filieres generales if (dossier.getFiliere() != null && dossier.getFiliere().getId().longValue() >= GlobalParameters.PREPA_FILIERE_FROM) continue; if (dossier.getCreateDate() != null) { Calendar date = new GregorianCalendar(); date.setTime(dossier.getCreateDate()); date.add(Calendar.DAY_OF_WEEK_IN_MONTH, 1); Calendar deleteAfterThis = new GregorianCalendar(); if (deleteAfterThis.after(date)) { logger.info("deleting dossier id : " + dossier.getId() + "."); try { inscriptionService.deleteInscription(dossier.getId()); number++;/* w w w . j a v a 2 s . com*/ } catch (Exception e) { logger.fatal(e.getMessage()); } } } } logger.info("Job ended at " + dateformat.format(new Date()) + " with " + number + " Dossier deleted"); }
From source file:com.apress.progwt.server.service.impl.InvitationServiceImpl.java
private boolean isValidTimestampKey(String randomkey) { Calendar c = Calendar.getInstance(); c.get(Calendar.DAY_OF_WEEK_IN_MONTH); String preCrypt = salt + c.get(Calendar.DAY_OF_WEEK_IN_MONTH); String crypt = CryptUtils.hashString(preCrypt); return crypt.equals(randomkey); }
From source file:TimeLib.java
/** * Based on code posted at//w ww . ja v a2 s .co m * http://forum.java.sun.com/thread.jspa?threadID=488676&messageID=2292012 */ private static int estimateUnitsBetween(long t0, long t1, int field) { long d = t1 - t0; switch (field) { case Calendar.MILLISECOND: return (int) d; // this could be very inaccurate. TODO: use long instead of int? case Calendar.SECOND: return (int) (d / SECOND_MILLIS + .5); case Calendar.MINUTE: return (int) (d / MINUTE_MILLIS + .5); case Calendar.HOUR_OF_DAY: case Calendar.HOUR: return (int) (d / HOUR_MILLIS + .5); case Calendar.DAY_OF_WEEK_IN_MONTH: case Calendar.DAY_OF_MONTH: // case Calendar.DATE : // codes to same int as DAY_OF_MONTH return (int) (d / DAY_MILLIS + .5); case Calendar.WEEK_OF_YEAR: return (int) (d / WEEK_MILLIS + .5); case Calendar.MONTH: return (int) (d / MONTH_MILLIS + .5); case Calendar.YEAR: return (int) (d / YEAR_MILLIS + .5); case DECADE: return (int) (d / DECADE_MILLIS + .5); case CENTURY: return (int) (d / CENTURY_MILLIS + .5); case MILLENIUM: return (int) (d / MILLENIUM_MILLIS + .5); default: return 0; } }