List of usage examples for java.util Calendar clear
public final void clear()
Calendar
undefined. From source file:com.guodong.sun.guodong.fragment.ZhihuFragment.java
private void initFButton() { mFButton.attachToRecyclerView(mRecyclerView); mFButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w. j a v a2 s . co m*/ public void onClick(View v) { Calendar now = Calendar.getInstance(); // now.set(mYear, mMonth, mDay); DatePickerDialog dialog = DatePickerDialog.newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; Calendar temp = Calendar.getInstance(); temp.clear(); temp.set(year, monthOfYear, dayOfMonth); mZhihuPresenter.getZhihuData(temp.getTimeInMillis()); } }, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); dialog.setMaxDate(Calendar.getInstance()); Calendar minDate = Calendar.getInstance(); // 2013.5.20api minDate.set(2013, 4, 20); dialog.setMinDate(minDate); dialog.vibrate(true); dialog.show(getActivity().getFragmentManager(), "DatePickerDialog"); } }); }
From source file:org.activiti.crystalball.simulator.OptimizeBottleneckTest.java
/** * run simulation for 30 days and generate report * //from w w w .jav a 2 s . co m * @param appContext * @throws Exception */ protected void runSimulation(AbstractApplicationContext appContext, String instancesGeneratedImage, String dueDateGeneratedImage) throws Exception { SimulationRun simRun = (SimulationRun) appContext.getBean(SimulationRun.class); Calendar c = Calendar.getInstance(); c.clear(); c.set(2013, 1, 1); Date startDate = c.getTime(); // add 30 days to start day 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); RepositoryService simRepositoryService = (RepositoryService) appContext.getBean("simRepositoryService"); String processDefinitionId = simRepositoryService.createProcessDefinitionQuery() .processDefinitionKey(PROCESS_KEY).singleResult().getId(); // GENERATE REPORTS // instances report AbstractProcessEngineGraphGenerator generator = (AbstractProcessEngineGraphGenerator) appContext .getBean("reportGenerator"); generator.generateReport(processDefinitionId, startDate, finishDate, instancesGeneratedImage); // after due date report generator = (AbstractProcessEngineGraphGenerator) appContext.getBean("dueDateReportGenerator"); generator.generateReport(processDefinitionId, startDate, finishDate, dueDateGeneratedImage); }
From source file:py.una.pol.karaku.test.test.services.ReflectionConverterTest.java
@Test public void testReflexionFromEntityToDTO1Level() throws Exception { String string = "String1"; Calendar cal = Calendar.getInstance(); cal.clear(); Date date = cal.getTime();/*from ww w. j av a 2 s. c o m*/ Quantity quantity = Quantity.ZERO.times(100); EntityChild ec = new EntityChild(); ec.string = "ec1"; Entity e = new Entity(); e.uri = string; e.date = date; e.quantity = quantity; e.codigoInterno = "NOOO"; e.child = ec; DTO dto = make(Entity.class, DTO.class).toDTO(e, 0); assertEquals(string, dto.uri); assertEquals(date, dto.date); assertEquals(quantity, dto.quantity); assertFalse(dto.active); assertEquals("ec1", dto.child.string); }
From source file:org.shredzone.cilla.web.renderer.CalendarGenerator.java
/** * Gets the start date of the calendar that is to be displayed. *///w ww . j a v a 2s . co m public Calendar getDisplayCalendar() { Calendar cal = Calendar.getInstance(locale); cal.clear(); cal.set(calYear, calMonth - 1, 1); return cal; }
From source file:org.apache.olingo.fit.proxy.v3.InvokeTestITCase.java
@Test public void resetComputerDetailsSpecifications() { // 0. create a computer detail final Integer id = 101; final Calendar purchaseDate = Calendar.getInstance(); purchaseDate.clear(); purchaseDate.set(Calendar.YEAR, 1); purchaseDate.set(Calendar.MONTH, 0); purchaseDate.set(Calendar.DAY_OF_MONTH, 1); ComputerDetail computerDetail = container.newEntityInstance(ComputerDetail.class); computerDetail.setComputerDetailId(id); final PrimitiveCollection<String> sb = container.newPrimitiveCollection(String.class); sb.add("First spec"); computerDetail.setSpecificationsBag(sb); computerDetail.setPurchaseDate(new Timestamp(purchaseDate.getTimeInMillis())); container.getComputerDetail().add(computerDetail); container.flush();//from w ww . ja va 2 s . c o m computerDetail = container.getComputerDetail().getByKey(id).load(); assertNotNull(computerDetail); assertEquals(id, computerDetail.getComputerDetailId()); assertEquals(1, computerDetail.getSpecificationsBag().size()); assertTrue(computerDetail.getSpecificationsBag().contains("First spec")); assertEquals(purchaseDate.getTimeInMillis(), computerDetail.getPurchaseDate().getTime()); try { final PrimitiveCollection<String> cds = container.newPrimitiveCollection(String.class); cds.add("Second spec"); // 1. invoke action bound to the computer detail just created computerDetail.operations().resetComputerDetailsSpecifications(cds, new Timestamp(Calendar.getInstance().getTimeInMillis())).execute(); // 2. check that invoked action has effectively run computerDetail = container.getComputerDetail().getByKey(id).load(); assertNotNull(computerDetail); assertEquals(id, computerDetail.getComputerDetailId()); assertEquals(1, computerDetail.getSpecificationsBag().size()); assertTrue(computerDetail.getSpecificationsBag().contains("Second spec")); assertNotEquals(purchaseDate.getTimeInMillis(), computerDetail.getPurchaseDate()); } catch (Exception e) { fail("Should never get here"); } finally { // 3. remove the test product container.getComputerDetail().delete(computerDetail.getComputerDetailId()); container.flush(); } }
From source file:org.apache.kylin.common.util.BasicTest.java
@Test @Ignore("convenient trial tool for dev") public void test1() throws Exception { System.out.println(org.apache.kylin.common.util.DateFormat.formatToTimeStr(1433833611000L)); System.out.println(org.apache.kylin.common.util.DateFormat.formatToTimeStr(1433250517000L)); System.out.println(org.apache.kylin.common.util.DateFormat.stringToMillis("2015-06-01 00:00:00")); System.out.println(org.apache.kylin.common.util.DateFormat.stringToMillis("2015-05-15 17:00:00")); String bb = "\\x00\\x00\\x00\\x00\\x01\\x3F\\xD0\\x2D\\58\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00";//2013/07/12 07:59:37 String cc = "\\x00\\x00\\x00\\x00\\x01\\x41\\xBE\\x8F\\xD8\\x00\\x00\\x00\\x00\\x00\\x00\\x00";//2013/10/16 08:00:00 String dd = "\\x00\\x00\\x00\\x00\\x01\\x41\\xBE\\x8F\\xD8\\x07\\x00\\x18\\x00\\x00\\x00"; byte[] bytes = BytesUtil.fromReadableText(dd); long ttt = BytesUtil.readLong(bytes, 2, 8); System.out.println(time(ttt)); System.out.println("\\"); System.out.println("n"); System.out.println("The start key is set to " + null); long current = System.currentTimeMillis(); System.out.println(time(current)); Calendar a = Calendar.getInstance(); Calendar b = Calendar.getInstance(); Calendar c = Calendar.getInstance(); b.clear(); c.clear();//from w ww.ja v a 2s.c o m System.out.println(time(b.getTimeInMillis())); System.out.println(time(c.getTimeInMillis())); a.setTimeInMillis(current); b.set(a.get(Calendar.YEAR), a.get(Calendar.MONTH), a.get(Calendar.DAY_OF_MONTH), a.get(Calendar.HOUR_OF_DAY), a.get(Calendar.MINUTE)); c.set(a.get(Calendar.YEAR), a.get(Calendar.MONTH), a.get(Calendar.DAY_OF_MONTH), a.get(Calendar.HOUR_OF_DAY), 0); System.out.println(time(b.getTimeInMillis())); System.out.println(time(c.getTimeInMillis())); }
From source file:py.una.pol.karaku.test.test.services.ReflectionConverterTest.java
@Test public void testReflexionFromDTOToEntity() throws Exception { Calendar cal = Calendar.getInstance(); cal.clear(); Date date = cal.getTime();/*from w ww . j ava 2 s . c o m*/ DTO dto = new DTO(); dto.active = true; dto.date = date; dto.quantity = Quantity.ONE; dto.uri = "URI"; Entity e = make(Entity.class, DTO.class).toEntity(dto); assertTrue(e.isActive()); assertEquals(date, e.date); assertEquals(Quantity.ONE, e.quantity); assertEquals("URI", e.uri); DTOChild first = new DTOChild(); first.string = "FIRST"; DTOChild second = new DTOChild(); second.string = "SECOND"; dto.childs = ListHelper.getAsList(first, second); e = make(Entity.class, DTO.class).toEntity(dto); List<EntityChild> childs = e.childs; assertNotNull(childs); assertEquals(2, childs.size()); assertTrue(childs.get(0) instanceof EntityChild); assertTrue(childs.get(1) instanceof EntityChild); EntityChild ee1 = childs.get(0); EntityChild ee2 = childs.get(1); assertEquals(first.string, ee1.string); assertEquals(second.string, ee2.string); }
From source file:ejava.projects.edmv.xml.EDmvBindingTest.java
public void testCalendar() throws Exception { log.info("*** testCalendar ***"); DatatypeFactory dataFactory = DatatypeFactory.newInstance(); log.info("DataTypeFactory=" + dataFactory); XMLGregorianCalendar cal = dataFactory.newXMLGregorianCalendar(); log.info("XMLGregorianCalendar=" + cal.getClass()); cal.setMonth(GregorianCalendar.MARCH); String xml = cal.toXMLFormat(); log.debug("cal=" + xml); dataFactory.newXMLGregorianCalendar(xml); cal.setTimezone(0);//www. ja v a 2 s . c o m Calendar jCal = Calendar.getInstance(); jCal.clear(); jCal.set(Calendar.MONTH, Calendar.MARCH); DateFormat df = DateFormat.getDateInstance(); String dfString = df.format(jCal.getTime()); log.debug("calendar=" + dfString); String format = "--01"; try { XMLGregorianCalendar xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); format = "--01--"; xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); } catch (Exception ex) { log.error("failed to parse:" + format); fail("failed to parse:" + format); } }
From source file:org.wiztools.commons.DateUtil.java
/** * Test of getAsISODateString method, of class DateUtil. *///from w w w . j a va 2s . co m @Test public void testGetAsISODateString() { System.out.println("getAsISODateString"); Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, 1979); c.set(Calendar.MONTH, 1); // 1 means Feb. c.set(Calendar.DATE, 15); Date date = c.getTime(); String expResult = "1979-02-15"; String result = DateUtil.getAsISODateString(date); assertEquals(expResult, result); }
From source file:org.wiztools.commons.DateUtil.java
/** * Test of getFromISODateString method, of class DateUtil. *//* w w w . j a v a2 s. c om*/ @Test public void testGetFromISODateString() { System.out.println("getFromISODateString"); String dateStr = "1979-02-15"; Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, 1979); c.set(Calendar.MONTH, 1); // 1 means Feb. c.set(Calendar.DATE, 15); Date expResult = c.getTime(); Date result = DateUtil.getFromISODateString(dateStr); assertEquals(expResult, result); }