List of usage examples for java.util Calendar clear
public final void clear()
Calendar
undefined. From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBoltTest.java
@Test public void testEnrichDataswift(@Mocked final LogRecord record) throws Exception { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2014, Calendar.JUNE, 10, 20, 22, 4); bolt.dateFields = Arrays.asList("interaction.created_at"); bolt.dateFormat = "EEE, dd MMM yyyy HH:mm:ss Z"; new Expectations() { {/*from w w w .ja va 2s.c om*/ record.getValue(bolt.dateFields.get(0)); result = "Tue, 10 Jun 2014 20:22:04 +0000"; record.setDate(calendar.getTime()); } }; bolt.process(record); }
From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBoltTest.java
@Test public void testEnrichGnip(@Mocked final LogRecord record) throws Exception { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2015, Calendar.JULY, 12, 0, 0, 52); bolt.dateFields = Arrays.asList("postedTime"); bolt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSX"; new Expectations() { {// w w w . j ava 2 s .c o m record.getValue(bolt.dateFields.get(0)); result = "2015-07-12T00:00:52.000Z"; record.setDate(calendar.getTime()); } }; bolt.process(record); }
From source file:com.github.notizklotz.derbunddownloader.download.AutomaticIssueDownloadAlarmManager.java
private Calendar calculateNextAlarm(int hourOfDay, int minute) { final Calendar nextAlarm = Calendar.getInstance(); nextAlarm.clear(); final Calendar now = Calendar.getInstance(); nextAlarm.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), hourOfDay, minute);/*from w ww . j ava 2s. co m*/ //Make sure trigger is in the future if (now.after(nextAlarm)) { nextAlarm.add(Calendar.DAY_OF_MONTH, 1); } //Do not schedule Sundays as the newspaper is not issued on Sundays if ((nextAlarm.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) { nextAlarm.add(Calendar.DAY_OF_MONTH, 1); } return nextAlarm; }
From source file:javasnack.cli.CliDbUnitCsvExportDemo.java
void setup(Connection conn) throws Exception { new T1().setup(conn); Calendar c = Calendar.getInstance(); c.clear(); c.set(2000, 11, 31, 23, 59, 59);//from w w w . j av a2s. c om long insertTIM = c.getTimeInMillis(); new T1(true, 10, new BigDecimal(20), 30.0, new Time(insertTIM), new Date(insertTIM), new Timestamp(insertTIM), "'Hello', \"World\"!").insertMe(conn); c.clear(); c.set(2001, 0, 1, 12, 30, 15); insertTIM = c.getTimeInMillis(); new T1(false, 20, new BigDecimal(30), 40.0, new Time(insertTIM), new Date(insertTIM), new Timestamp(insertTIM), "'Hello', \n\"World\"!").insertMe(conn); new T2().setup(conn); new T2(UnsignedByte.create0x00to0xFFString(), UnsignedByte.create0x00to0xFF(), UnsignedByte.create0x00to0xFF()).insertMe(conn); }
From source file:org.hyperic.hq.plugin.mysql_stats.MySqlStatsLogTrackPlugin.java
private long getTime(String line) { // # Time: 081222 11:13:53 // NOTE: this time format is horrible, hopefully it holds up String[] toks = line.split("\\s+"); String dateBuf = toks[2];// w w w . j a v a 2s. c o m Calendar cal = Calendar.getInstance(); cal.clear(); char[] dateToks = dateBuf.toCharArray(); int year = Integer.valueOf(dateToks[0] + "" + dateToks[1]).intValue(); year = year + 2000; cal.set(Calendar.YEAR, year); int month = Integer.valueOf(dateToks[2] + "" + dateToks[3]).intValue(); month--; cal.set(Calendar.MONTH, month); int day = Integer.valueOf(dateToks[4] + "" + dateToks[5]).intValue(); cal.set(Calendar.DAY_OF_MONTH, day); String timeBuf = toks[3]; String[] timeToks = timeBuf.split(":"); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeToks[0])); cal.set(Calendar.MINUTE, Integer.parseInt(timeToks[1])); cal.set(Calendar.SECOND, Integer.parseInt(timeToks[2])); return cal.getTimeInMillis(); }
From source file:org.activiti.designer.property.extension.field.CustomPropertyDatePickerField.java
@Override public String getSimpleValue() { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, calendarControl.getYear()); calendar.set(Calendar.MONTH, calendarControl.getMonth()); calendar.set(Calendar.DAY_OF_MONTH, calendarControl.getDay()); calendar.set(Calendar.HOUR_OF_DAY, calendarControl.getHours()); calendar.set(Calendar.MINUTE, calendarControl.getMinutes()); calendar.set(Calendar.SECOND, calendarControl.getSeconds()); return sdf.format(calendar.getTime()); }
From source file:org.activiti.crystalball.simulator.SimulateBottleneckTest.java
/** * run simulation for 30 days and generate report * /* www .j a va 2 s .c o m*/ * @param appContext * @throws Exception */ protected void runSimulation(AbstractApplicationContext appContext, String generatedImage) throws Exception { SimulationRun simRun = (SimulationRun) appContext.getBean(SimulationRun.class); Calendar c = Calendar.getInstance(); c.clear(); c.set(2013, 1, 1); Date startDate = c.getTime(); c.add(Calendar.DAY_OF_YEAR, 30); Date finishDate = c.getTime(); // run simulation for 30 days @SuppressWarnings("unused") List<ResultEntity> resultEventList = simRun.execute(startDate, finishDate); AbstractProcessEngineGraphGenerator generator = (AbstractProcessEngineGraphGenerator) appContext .getBean("reportGenerator"); RepositoryService simRepositoryService = (RepositoryService) appContext.getBean("simRepositoryService"); String processDefinitionId = simRepositoryService.createProcessDefinitionQuery() .processDefinitionKey(PROCESS_KEY).singleResult().getId(); generator.generateReport(processDefinitionId, startDate, finishDate, generatedImage); }
From source file:com.boozallen.cognition.ingest.storm.bolt.logging.LogRecordDateBoltTest.java
@Test public void testLogDate(@Injectable LogRecord record, @Injectable Logger logger) throws Exception { bolt.logger = logger;//from w w w. java2 s. c o m bolt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; bolt.level = Level.DEBUG; Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2014, Calendar.JUNE, 10, 20, 22, 4); new Expectations(bolt) { { record.getDate(); result = calendar.getTime(); bolt.log(logger, "2014-06-10T20:22:04.000Z"); } }; bolt.logDate(record); }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFTimeColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from w w w. java 2 s . c o m } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Calendar) { Calendar cal = (Calendar) value; Format fmt = getDefaultFormat(); Calendar withoutDate = Calendar.getInstance(); withoutDate.clear(); withoutDate.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY)); withoutDate.set(Calendar.MINUTE, cal.get(Calendar.MINUTE)); withoutDate.set(Calendar.SECOND, cal.get(Calendar.SECOND)); str = fmt.format(withoutDate.getTime()); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); g.drawString(firstLine, 4, leading + ascent + 4); } }
From source file:org.spring.data.gemfire.cache.SpringGemfireTemplateTests.java
protected Date createDate(final int year, final int month, final int dayOfMonth) { Calendar date = Calendar.getInstance(); date.clear(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, dayOfMonth); return date.getTime(); }