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:com.cemeterylistingswebtest.test.services.LoginServiceTest.java
@Test public void AuthenticateTest() { loginServ = ctx.getBean(LoginService.class); repo = ctx.getBean(SubscriberRepository.class); //create subscribers userRepo = ctx.getBean(UserRoleRepository.class); 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(); //userRepo.save(user); //userRoleID = user.getUserRoleID(); Subscriber newSub = new Subscriber.Builder().setEmail("manfredOsulivan@horseRaddish.com") .setFirstName("Manfred").setSurname("Osulivan").setPwd("jesus").setUsername("ManiFredOssy") .setSubscriptionDate(javaSqlDate).setUserRoleID(user).build(); repo.save(newSub);//from w w w. j a va 2 s . co m id = newSub.getSubscriberID(); Assert.assertTrue(loginServ.authenticate(newSub.getUsername(), newSub.getPwd()), "Login successful"); Assert.assertFalse(loginServ.authenticate(newSub.getUsername(), ""), "Login Failed; no password"); Assert.assertFalse(loginServ.authenticate("", newSub.getPwd()), "Login Failed ; no username"); Assert.assertFalse(loginServ.authenticate("", ""), "Login Failed no username or password"); }
From source file:com.sirma.itt.emf.time.ISO8601DateFormat.java
/** * Format calendar instance into ISO format. * /*from w w w . ja va 2s .co m*/ * @param calendar * the calendar instance to format * @return the ISO formatted string */ public static String format(Calendar calendar) { if (calendar == null) { return null; } StringBuilder formatted = new StringBuilder(28); padInt(formatted, calendar.get(Calendar.YEAR), 4); formatted.append('-'); padInt(formatted, calendar.get(Calendar.MONTH) + 1, 2); formatted.append('-'); padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), 2); formatted.append('T'); padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), 2); formatted.append(':'); padInt(formatted, calendar.get(Calendar.MINUTE), 2); formatted.append(':'); padInt(formatted, calendar.get(Calendar.SECOND), 2); formatted.append('.'); padInt(formatted, calendar.get(Calendar.MILLISECOND), 3); TimeZone tz = calendar.getTimeZone(); int offset = tz.getOffset(calendar.getTimeInMillis()); formatted.append(getTimeZonePadding(offset)); return formatted.toString(); }
From source file:ch.cyberduck.core.ftp.parser.HPTru64ParserTest.java
/** * http://trac.cyberduck.ch/ticket/2246//from w w w . j a v a2 s. co m */ @Test public void testParse() throws Exception { FTPFile parsed; parsed = parser.parseFTPEntry("drwxr-xr-x 7 ToysPKG advertise 8192 Jun 24 11:58 Private Label Mock"); assertNotNull(parsed); assertEquals(parsed.getName(), "Private Label Mock"); assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType()); assertEquals("ToysPKG", parsed.getUser()); assertEquals("advertise", parsed.getGroup()); assertEquals(8192, parsed.getSize()); assertEquals(Calendar.JUNE, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(24, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); parsed = parser.parseFTPEntry( "-rw-r--r-- 1 ToysPKG advertise24809879 Jun 25 10:54 TRU-Warning Guide Master CD.sitx"); assertNull(parsed); }
From source file:com.example.geomesa.transformations.QueryTutorial.java
/** * Creates a base filter that will return a small subset of our results. This can be tweaked to * return different results if desired. Currently it should return 16 results. * * @return// ww w. ja v a2 s. c o m * * @throws CQLException * @throws IOException */ static Filter createBaseFilter() throws CQLException, IOException { // Get a FilterFactory2 to build up our query FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); // We are going to query for events in Ukraine during the // civil unrest. // We'll start by looking at a particular day in February of 2014 Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, 2014); calendar.set(Calendar.MONTH, Calendar.FEBRUARY); calendar.set(Calendar.DAY_OF_MONTH, 2); calendar.set(Calendar.HOUR_OF_DAY, 0); Date start = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); Date end = calendar.getTime(); Filter timeFilter = ff.between(ff.property(GdeltFeature.Attributes.SQLDATE.getName()), ff.literal(start), ff.literal(end)); // We'll bound our query spatially to Ukraine Filter spatialFilter = ff.bbox(GdeltFeature.Attributes.geom.getName(), 22.1371589, 44.386463, 40.228581, 52.379581, "EPSG:4326"); // we'll also restrict our query to only articles about the US, UK or UN Filter attributeFilter = ff.like(ff.property(GdeltFeature.Attributes.Actor1Name.getName()), "UNITED%"); // Now we can combine our filters using a boolean AND operator Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter)); return conjunction; }
From source file:ch.cyberduck.core.ftp.parser.NetwareFTPEntryParserTest.java
/** * #1996//from w ww . j av a 2s .co m */ @Test public void testDateYearParser() { FTPFile parsed; parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 24038 May 05 17:57 CIMSscheduler_log_May02_4.txt"); assertNotNull(parsed); assertEquals(parsed.getName(), "CIMSscheduler_log_May02_4.txt"); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals("wtubbs", parsed.getUser()); assertEquals(24038, parsed.getSize()); assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(5, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 9965 May 01 18:15 CIMSscheduler_log_May01.txt"); assertNotNull(parsed); assertEquals(parsed.getName(), "CIMSscheduler_log_May01.txt"); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals("wtubbs", parsed.getUser()); assertEquals(9965, parsed.getSize()); assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); }
From source file:cr.ac.siua.tec.utils.impl.ConstancyPDFGenerator.java
/** * Fills the PDF file (constancia.pdf) with the ticket values and returns base64 encoded string. */// w w w .jav a2 s .co m @Override public String generate(HashMap<String, String> formValues) { String originalPdf = PDFGenerator.RESOURCES_PATH + "constancia.pdf"; try { PDDocument _pdfDocument = PDDocument.load(originalPdf); PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); //Set some fields manually. Calendar cal = Calendar.getInstance(); int day = cal.get(Calendar.DAY_OF_MONTH); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); String date = String.valueOf(day) + " de " + monthsMap.get(month) + " del ao " + String.valueOf(year) + "."; acroForm.getField("Fecha").setValue(date); formValues.remove("Queue"); formValues.remove("Motivo"); formValues.remove("Requestors"); //Iterates through remaining custom fields. for (Map.Entry<String, String> entry : formValues.entrySet()) { acroForm.getField(entry.getKey()).setValue(entry.getValue()); } return encodePDF(_pdfDocument); } catch (IOException e) { e.printStackTrace(); System.out.println("Excepcin al llenar el PDF."); return null; } }
From source file:gov.utah.dts.det.ccl.documents.reporting.reports.AbstractDimensionReport.java
protected Input getStartDateInput() { return new Input(DATE_RANGE_START_KEY, "Start Date", DateUtils.truncate(new Date(), Calendar.MONTH), Date.class, true, InputDisplayType.DATE); }
From source file:com.lfv.yada.net.server.ServerLogger.java
public ServerLogger(int groupId, String logpath) { // Create a logger for this class if (logpath == null) { logpath = "data/logs/"; }//from w ww .j a va 2s . c o m mylogpath = logpath; log = LogFactory.getLog(getClass()); log.info("ServerLogger: logpath=" + logpath); // Create a calendar startTime = System.currentTimeMillis(); calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.setTimeInMillis(startTime); String filename = "Grp" + groupId + "-" + calendar.get(Calendar.YEAR) + s2(calendar.get(Calendar.MONTH) + 1) + s2(calendar.get(Calendar.DAY_OF_MONTH)) + "-" + s2(calendar.get(Calendar.HOUR_OF_DAY)) + s2(calendar.get(Calendar.MINUTE)) + s2(calendar.get(Calendar.SECOND)) + ".log"; try { printer = new PrintStream(new FileOutputStream(logpath + "/" + filename), true); log.info("Creating log " + logpath + "/" + filename); } catch (FileNotFoundException ex) { log.warn("Log file " + filename + " could not be created, logger has been disabled!", ex); printer = null; } }
From source file:com.cemeterylistingswebtest.test.domain.SubscriberTest.java
@Test public void create() { System.out.println("Subscriber Test"); repo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); 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(); //userRepo.save(user); //userRoleID = user.getUserRoleID(); Subscriber newSub = new Subscriber.Builder().setEmail("manfredOsulivan@horseRaddish.com") .setFirstName("Manfred").setSurname("Osulivan").setPwd("jesus").setUsername("ManiFredOssy") .setSubscriptionDate(javaSqlDate).setUserRoleID(user).build(); repo.save(newSub);/*w w w. j a v a 2 s . co m*/ id = newSub.getSubscriberID(); }