List of usage examples for java.util Calendar MONTH
int MONTH
To view the source code for java.util Calendar MONTH.
Click Source Link
get
and set
indicating the month. From source file:ch.cyberduck.core.ftp.parser.FilezillaFTPEntryParserTest.java
@Test public void testParse() throws Exception { FTPFile parsed;/*from w w w.j a v a2s. c o m*/ // #3119 parsed = parser.parseFTPEntry("-rw-r--r-- 1 ftp ftp 100847 Sep 10 2004 octfront2.jpg"); assertNotNull(parsed); assertEquals("octfront2.jpg", parsed.getName()); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals(100847, parsed.getSize()); assertEquals(Calendar.SEPTEMBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(10, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); 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)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)); }
From source file:ch.cyberduck.core.ftp.parser.RumpusFTPEntryParserTest.java
@Test public void testParse() throws Exception { FTPFile parsed;//w w w .j av a 2s. co m parsed = parser.parseFTPEntry("drwxr-xr-x folder 0 Oct 18 13:02 Akrilik"); assertNotNull(parsed); assertEquals("Akrilik", parsed.getName()); assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType()); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(18, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); 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)); assertTrue(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)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)); parsed = parser.parseFTPEntry("drwxrwxrwx folder 0 Oct 11 14:53 Uploads"); assertNotNull(parsed); assertEquals("Uploads", parsed.getName()); assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType()); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(11, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); 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)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)); parsed = parser.parseFTPEntry("-rw-r--r-- 0 589878 589878 Oct 15 13:03 WebDAV SS.bmp"); assertNotNull(parsed); assertEquals("WebDAV SS.bmp", parsed.getName()); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); 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)); assertTrue(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:Main.java
/** * Adds a number of months to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null/*w w w .ja v a 2 s. co m*/ * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addMonths(Date date, int amount) { return add(date, Calendar.MONTH, amount); }
From source file:controllers.UserReportController.java
@RequestMapping("/summarizedReport") public String getFullUserReport(Map<String, Object> model, @RequestParam(value = "dateCampaignFrom", required = false) Date dateCampaignFrom, @RequestParam(value = "dateCampaignTo", required = false) Date dateCampaignTo, HttpServletRequest request) throws Exception { lk.dataByUserAndCompany(request, model); Long cabinetId = (long) request.getSession().getAttribute(CABINET_ID_SESSION_NAME); if (dateCampaignFrom == null || dateCampaignFrom.toString().equals("")) { Calendar cl = Calendar.getInstance(); cl.set(Calendar.YEAR, Calendar.MONTH, 1, 0, 0, 0); dateCampaignFrom = cl.getTime(); }//from w w w . j a v a2 s. c om if (dateCampaignTo == null || dateCampaignTo.toString().equals("")) { dateCampaignTo = new Date(); } LinkedHashMap<User, HashMap> reportMap = eventService .getUsersAndSuccessfulFailedPerformancesForReport(dateCampaignFrom, dateCampaignTo, cabinetId); model.put("reportMap", reportMap); model.put("errors", eventService.getErrors()); return "summarizedUserReport"; }
From source file:org.openmrs.module.pharmacyapi.api.service.prescriptionservice.PrescriptionGeneratorTest.java
@Test public void shouldGenerateNonArvPrescriptionWithActiveStatus() throws Exception { this.executeDataSet("prescriptionservice/shouldGenerateNonArvPrescriptionWithActiveStatus-dataset.xml"); final Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2017); calendar.set(Calendar.MONTH, 10); calendar.set(Calendar.DAY_OF_MONTH, 8); final Date date = calendar.getTime(); final List<DrugOrder> drugOrders = new ArrayList<>(); drugOrders.add((DrugOrder) Context.getOrderService().getOrder(100)); drugOrders.add((DrugOrder) Context.getOrderService().getOrder(101)); final List<Prescription> prescriptions = this.prescriptionGenerator.generatePrescriptions(drugOrders, date); Assert.assertEquals(1, prescriptions.size()); final Prescription prescription = prescriptions.get(0); Assert.assertEquals(PrescriptionStatus.ACTIVE, prescription.getPrescriptionStatus()); Assert.assertFalse(prescription.isArv()); Assert.assertEquals(2, prescription.getPrescriptionItems().size()); }
From source file:net.ceos.project.poi.annotated.bean.ObjectNullBuilder.java
/** * Validate the ObjectNull based on the object build with the method * 'buildObjectNull'//w w w . j a v a 2s.c om * * @param toValidate * the object to validate */ public static void validateObjectNull(ObjectNull toValidate) { ObjectNull base = buildObjectNull(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); Calendar calendarUnmarshal = Calendar.getInstance(); calendarUnmarshal.setTime(toValidate.getDateAttribute()); assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR)); assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH)); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH)); assertEquals(base.getStringAttribute(), toValidate.getStringAttribute()); assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute()); assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute()); assertEquals(base.getLongAttribute(), toValidate.getLongAttribute()); assertEquals(base.getBooleanAttribute(), toValidate.getBooleanAttribute()); assertEquals(base.getJob().getJobCode(), toValidate.getJob().getJobCode()); assertEquals(base.getJob().getJobFamily(), toValidate.getJob().getJobFamily()); assertEquals(base.getJob().getJobName(), toValidate.getJob().getJobName()); assertEquals(base.getIntegerPrimitiveAttribute(), toValidate.getIntegerPrimitiveAttribute()); assertEquals(base.getDoublePrimitiveAttribute(), toValidate.getDoublePrimitiveAttribute()); assertEquals(base.getLongPrimitiveAttribute(), toValidate.getLongPrimitiveAttribute()); assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute()); assertEquals(base.getAddressInfo().getAddress(), toValidate.getAddressInfo().getAddress()); assertEquals(base.getAddressInfo().getNumber(), toValidate.getAddressInfo().getNumber()); assertEquals(base.getAddressInfo().getCity(), toValidate.getAddressInfo().getCity()); assertEquals(base.getAddressInfo().getCityCode(), toValidate.getAddressInfo().getCityCode()); assertEquals(base.getAddressInfo().getCountry(), toValidate.getAddressInfo().getCountry()); assertEquals(base.getFloatAttribute(), toValidate.getFloatAttribute()); assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute()); assertEquals(base.getUnitFamily(), toValidate.getUnitFamily()); assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute()); assertEquals(base.getShortAttribute(), toValidate.getShortAttribute()); assertEquals(base.getShortPrimitiveAttribute(), toValidate.getShortPrimitiveAttribute()); // TODO add new validation below }
From source file:com.chortitzer.web.usi.controller.NisSinLecturaBean.java
public NisSinLecturaBean() { try {// w w w .jav a2 s . c om int mesActual = calendar.get(Calendar.MONTH) + 1; for (int i = 1; i > -11; i--) { mesList.add(mesActual); mesActual--; if (mesActual == 0) { mesActual = 12; } } int anoActual = calendar.get(Calendar.YEAR); for (int i = anoActual; i > anoActual - 3; i--) { anoList.add(i); } } catch (Exception ex) { LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error!", ex.getMessage())); } }
From source file:ch.cyberduck.core.ftp.parser.TrellixFTPEntryParserTest.java
@Test public void testParse() throws Exception { FTPFile parsed;// w w w.ja va 2s .c om //#1213 parsed = parser.parseFTPEntry("-rw-r--r-- FTP User 10439 Apr 20 05:29 ASCheckbox_2_0.zip"); assertNotNull(parsed); assertEquals("ASCheckbox_2_0.zip", parsed.getName()); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals(10439, parsed.getSize()); assertEquals(Calendar.APRIL, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(20, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); 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)); assertTrue(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:DateUtils.java
public static final String dateToString(Date dt, String dateformat) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(dt);// w w w . java 2s.co m StringBuffer ret = new StringBuffer(); String separator = new String(); if (dateformat.equals(DateUtils.FORMAT_YYYYMMDD)) { separator = "-"; } if (dateformat.equals(DateUtils.FORMAT_YYYYMMDD_SLASHES)) { separator = "/"; } ret.append(cal.get(Calendar.YEAR)); ret.append(separator); ret.append(cal.get(Calendar.MONTH) + 1); ret.append(separator); ret.append(cal.get(Calendar.DATE)); return ret.toString(); }
From source file:com.cemeterylistingswebtest.test.rest.RegistrationControllerTest.java
@Test(enabled = false) public void testCreate() { System.out.println("Registration Testing"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, Calendar.FEBRUARY); calendar.set(Calendar.DATE, 4); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); UserRole user = new UserRole.Builder().setLevel(1).build(); Subscriber newSub = new Subscriber.Builder().setEmail("zaakir@gmail.com").setFirstName("zaakir") .setSurname("arendse").setPwd("123").setUsername("zak").setSubscriptionDate(javaSqlDate) .setUserRoleID(user).build(); HttpEntity<Subscriber> requestEntity = new HttpEntity<>(newSub, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/Registration/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); id = newSub.getSubscriberID();/* w w w . j a v a 2 s .c om*/ }