List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. From source file:org.openmrs.module.radiology.order.RadiologyOrderValidatorTest.java
/** * helper method to create a valid RadiologyOrder * /*from w ww . j av a 2 s. c o m*/ * @return [RadiologyOrder] radiologyOrder, passes validation */ public RadiologyOrder getValidRadiologyOrder() { RadiologyOrder radiologyOrder = new RadiologyOrder(); radiologyOrder.setOrderer(new Provider()); radiologyOrder.setPatient(new Patient()); radiologyOrder.setConcept(new Concept(88)); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1); radiologyOrder.setDateActivated(cal.getTime()); radiologyOrder.setAutoExpireDate(new Date()); radiologyOrder.setUrgency(RadiologyOrder.Urgency.ROUTINE); radiologyOrder.setAction(RadiologyOrder.Action.NEW); return radiologyOrder; }
From source file:com.haulmont.cuba.core.sys.querymacro.DateEqualsMacroHandlerTest.java
public void testExpandMacro() throws Exception { Date date = new Date(); DateEqualsMacroHandler handler = new DateEqualsMacroHandler(); String res = handler.expandMacro("select distinct t from tm$Task t where t.id <> :param_exclItem " + "and @dateEquals(t.createTs, :component_genericFilter_nLxPpRlkOq29857) order by t.num desc"); handler.setQueryParams(/* w w w .java2 s .co m*/ Collections.<String, Object>singletonMap("component_genericFilter_nLxPpRlkOq29857", date)); Map<String, Object> params = handler.getParams(); System.out.println(res); System.out.println(params); assertEquals( "select distinct t from tm$Task t where t.id <> :param_exclItem and (t.createTs >= :component_genericFilter_nLxPpRlkOq29857 and t.createTs < :t_createTs_1) order by t.num desc", res); assertEquals(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), params.get("component_genericFilter_nLxPpRlkOq29857")); assertEquals(DateUtils.addDays(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), 1), params.get("t_createTs_1")); }
From source file:ch.cyberduck.core.ftp.parser.MicrosoftFTPEntryParserTest.java
@Test public void testParse() throws Exception { FTPFile parsed;//from w w w.j a v a 2s . c om // #3701 parsed = parser.parseFTPEntry("12-04-06 12:43PM 65335 fon1.kucuk.jpg"); assertNotNull(parsed); assertEquals("fon1.kucuk.jpg", parsed.getName()); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals(65335, parsed.getSize()); assertEquals(2006, parsed.getTimestamp().get(Calendar.YEAR)); assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(4, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); }
From source file:org.pau.assetmanager.viewmodel.chart.ResourceImageGenerator.java
private static void cleanTempFolder(File directory) { Calendar cal = Calendar.getInstance(); int daysBack = 1; cal.add(Calendar.DAY_OF_MONTH, daysBack * -1); long purgeTime = cal.getTimeInMillis(); File[] files = directory.listFiles(); for (File file : files) { if (file.lastModified() < purgeTime) { file.delete();/* ww w .j a v a 2 s .c o m*/ } } }
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/*from www .jav a 2s .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:edu.northwestern.bioinformatics.studycalendar.web.subject.ScheduleDay.java
public String getDetailTimelineClasses() { Calendar queriableDate = Calendar.getInstance(); queriableDate.setTime(getDate());/*from w w w. j a v a2 s . c o m*/ List<String> classes = new ArrayList<String>(6); classes.add("day"); classes.add(dateClass(getDate())); if (queriableDate.get(Calendar.DAY_OF_MONTH) == 1) classes.add("month-start"); if (queriableDate.get(Calendar.DAY_OF_YEAR) == 1) classes.add("year-start"); if (isToday()) classes.add("today"); if (!isEmpty()) classes.add("has-activities"); return StringUtils.join(classes.iterator(), ' '); }
From source file:com.dps.ring2park.dao.BookingDaoTest.java
@Test @Rollback//from w w w.ja v a2 s. com public void testUpdate() { BookingDao.persist(booking); Calendar calendar = Calendar.getInstance(); booking.setStartDate(calendar.getTime()); calendar.add(Calendar.DAY_OF_MONTH, 5); booking.setEndDate(calendar.getTime()); BookingDao.merge(booking); assertEquals(5, BookingDao.find(booking.getId()).getDays()); }
From source file:ch.cyberduck.core.ftp.parser.HPTru64ParserTest.java
/** * http://trac.cyberduck.ch/ticket/2246/* www . j av a 2 s . c o 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:ch.cyberduck.core.ftp.parser.NetwareFTPEntryParserTest.java
/** * #1996/* ww w . j a v a 2 s . 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: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/"; }/* w w w. j a va 2 s. 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; } }