List of usage examples for java.util GregorianCalendar GregorianCalendar
GregorianCalendar(TimeZone zone, Locale locale, boolean flag)
From source file:views.StockGraph.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); GregorianCalendar start = new GregorianCalendar(2016, 0, 18); // Date start = new Date(2015, 0, 18); GregorianCalendar end = new GregorianCalendar(2016, 3, 1); // Date end = new Date(2016, 3, 1); StockDownloader downloader = new StockDownloader(); StockManager manager = new StockManager(); List<Stock> stocks = manager.getStocks(downloader.downloadStocks("AAPL", start, end, "w")); String price = ""; for (Stock s : stocks) { dataset.addValue(s.getClose(), price, s.getNumericalDate()); }//from w ww .ja v a 2 s. com return dataset; }
From source file:javaeetutorial.web.websocketbot.BotBean.java
public String respond(String msg) { String response = null;/*from w w w. j a v a 2 s . c om*/ String nbaresults; List<NBA> list = null; NBADecoder nbadecoder; /* Remove question marks */ msg = msg.toLowerCase().replaceAll("\\?", ""); if (msg.contains("how are you")) { response = "I'm doing great, thank you!"; } else if (msg.contains("how old are you")) { Calendar dukesBirthday = new GregorianCalendar(1995, Calendar.MAY, 23); Calendar now = GregorianCalendar.getInstance(); int dukesAge = now.get(Calendar.YEAR) - dukesBirthday.get(Calendar.YEAR); response = String.format("I'm %d years old.", dukesAge); } else if (msg.contains("when is your birthday")) { response = "My birthday is on May 23rd. Thanks for asking!"; } else if (msg.contains("") | msg.contains("?")) { String nbaUri = "http://op.juhe.cn/onebox/basketball/team?key=0564267c0eb0ed260583698c8ea0e605&dtype=json&team="; String divUri = "http://ltpapi.voicecloud.cn/analysis/?api_key=41g4M3f3b6C7L387G0c6XcEOcY5QwaMCWDRoYhGa&pattern=ws&&pattern=dp&format=plain&text="; String divresults = get(msg, divUri); String[] phrase = divresults.split("\\s"); for (int j = 0; j < phrase.length; j++) { nbaresults = get(phrase[j], nbaUri); nbadecoder = new NBADecoder(); list = nbadecoder.decode(nbaresults); if (list != null) { response += "?" + phrase[j]; for (NBA nba : list) { response += "\n" + nba.getPlaydate() + nba.getPlaytime() + ",?" + nba.getName1() + "VS" + "?" + nba.getName2() + "" + nba.getScore() + "" + nba.getLink(); response += "\n"; } } else { response = "???"; } } } else { response = "Sorry, I did not understand what you said. "; response += "You can ask me how I'm doing today; how old I am; or "; response += "what my favorite color is."; } try { Thread.sleep(1200); } catch (InterruptedException ex) { } return response; }
From source file:orz.neptune.prospring3.ch8.JdbcContactDaoSample.java
private static void insertTest(ContactDao contactDao) { Contact contact = new Contact(); contact.setFirstName("peng"); contact.setLastName("zhou"); contact.setBirthDate(new Date((new GregorianCalendar(1984, 1, 28)).getTime().getTime())); contactDao.insert(contact);//from w w w .j a v a 2 s . c om List<Contact> contacts = contactDao.findAll(); listContacts(contacts); }
From source file:ch.ralscha.extdirectspring.provider.RemoteProviderFormLoad.java
@ExtDirectMethod(value = ExtDirectMethodType.FORM_LOAD, group = "group3", event = "test") public FormInfo method1(@RequestParam(value = "d") double d) { FormInfo info = new FormInfo(); info.setBack(d);/*from w w w .ja va 2 s. c om*/ info.setAdmin(true); info.setAge(31); info.setBirthday(new GregorianCalendar(1980, Calendar.JANUARY, 15).getTime()); info.setName("Bob"); info.setSalary(new BigDecimal("10000.55")); return info; }
From source file:be.fedict.eid.applet.service.impl.tlv.DateOfProtectionDataConvertor.java
@Override public GregorianCalendar convert(byte[] value) throws DataConvertorException { LOG.debug("DateAndCountryOfProtection size: " + value.length); if (0 == value.length) { return null; }// w w w . j a v a 2 s.com String dateStr = new String(value); LOG.debug("DateAndCountryOfProtection: \"" + dateStr + "\""); try { int day = Integer.parseInt(dateStr.substring(0, 2)); int month = Integer.parseInt(dateStr.substring(3, 5)); int year = Integer.parseInt(dateStr.substring(6, 10)); GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day); return calendar; } catch (Exception e) { LOG.error("error parsing DateOfProtection: " + e.getMessage(), e); return null; } }
From source file:fr.xebia.demo.ws.rs.employee.EmployeeService.java
@GET @Path("/employees/{id}/") public Employee getEmployee(@PathParam("id") int id) { Employee employee = new Employee(); employee.setId(id);/* w w w .ja va2 s . c om*/ employee.setLastName("Doe"); employee.setFirstName("John"); employee.setGender(Gender.MALE); employee.setBirthdate(new Date(new GregorianCalendar(1976, 01, 05).getTimeInMillis())); logger.info("getEmployee(" + id + "): " + ToStringBuilder.reflectionToString(employee)); return employee; }
From source file:no.dusken.aranea.service.IssueServiceImpl.java
public List<Issue> getIssues(int year) { List<Issue> i = Collections.emptyList(); try {//from ww w. j a v a 2 s. co m Map<String, Object> map = new HashMap<String, Object>(); map.put("fromDate", new GregorianCalendar(year, 0, 1)); map.put("toDate", new GregorianCalendar(year, 11, 31)); i = genericDao.getByNamedQuery("issues_byyear", map); } catch (DataAccessException dae) { log.warn("Unable to get Issues", dae); } return i; }
From source file:BeanUtilsExampleV2.java
private Movie prepareData() { Movie movie = new Movie(); movie.setTitle("The Italian Job"); movie.setDateOfRelease(new GregorianCalendar(1969, 0, 1).getTime()); // sets the genre Map genre_map = new HashMap(); genre_map.put("THR", "Thriller"); genre_map.put("ACT", "Action"); movie.setGenre(genre_map);/*from ww w . ja v a 2 s. c om*/ // creates the Director Person director = new Person(); director.setName("Peter Collinson"); director.setGender(1); Map director_contacts = new HashMap(); director_contacts.put("Home", "99922233"); director_contacts.put("Mobile", "0343343433"); director.setContactNumber(director_contacts); movie.setDirector(director); // create the actors Actor actor1 = new Actor(); actor1.setName("Michael Caine"); actor1.setGender(1); actor1.setWorth(10000000); List actor1_movies = new ArrayList(); Movie movie2 = new Movie(); movie2.setTitle("The Fourth Protocol"); Movie movie3 = new Movie(); movie3.setTitle("Shiner"); actor1_movies.add(movie2); actor1_movies.add(movie3); actor1.setMovieCredits(actor1_movies); Actor actor2 = new Actor(); actor2.setName("Margaret Blye"); actor2.setGender(2); actor2.setWorth(20000000); List actors = new ArrayList(); actors.add(actor1); actors.add(actor2); movie.setActors(actors); return movie; }
From source file:ar.com.zauber.commons.xmpp.config.XmppConfDriver.java
/** test */ @Test/*from ww w . j a v a 2 s . c o m*/ public final void foo() { final String base = "classpath:ar/com/zauber/commons/xmpp/config/"; ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { base + "connection-xmmp-commons-spring.xml", base + "properties-test-xmpp-commons-spring.xml", }); final XMPPConnection connection = (XMPPConnection) ctx.getBean("commonsZauberXMPPConnection"); System.out.println(connection.getRoster().getEntries()); final Map<String, Object> model = new HashMap<String, Object>(); model.put("key", new String("asdad")); model.put("date", new GregorianCalendar(2009, 05, 20).getTime()); }
From source file:org.openmrs.web.patient.PatientDashboardGraphControllerTest.java
/** * Test getting a concept by name and by partial name. * /* w w w . ja va2 s. c o m*/ * @see PatientDashboardGraphController#showGraphData(Integer, Integer, ModelMap) */ @Test @Verifies(value = "return json data with observation details and critical values for the concept", method = "showGraphData(Integer, Integer, ModelMap)") public void shouldReturnJSONWithPatientObservationDetails() throws Exception { executeDataSet("org/openmrs/api/include/ObsServiceTest-initial.xml"); PatientDashboardGraphController controller = new PatientDashboardGraphController(); long firstObsDate = new GregorianCalendar(2006, Calendar.FEBRUARY, 9).getTimeInMillis(); long secondObsDate = new GregorianCalendar(2006, Calendar.FEBRUARY, 10).getTimeInMillis(); ModelMap map = new ModelMap(); controller.showGraphData(2, 1, map); PatientGraphData graph = (PatientGraphData) map.get("graph"); String expectedData = String.format( "{\"absolute\":{\"high\":50.0,\"low\":2.0},\"critical\":{\"high\":null,\"low\":null},\"name\":\"Some concept name\",\"normal\":{\"high\":null,\"low\":null},\"data\":[[%d,null],[%d,1.0]],\"units\":\"\"}", secondObsDate, firstObsDate); ObjectMapper mapper = new ObjectMapper(); JsonNode expectedJson = mapper.readTree(expectedData); JsonNode actualJson = mapper.readTree(graph.toString()); Assert.assertEquals(expectedJson.size(), actualJson.size()); for (Iterator<String> fieldNames = expectedJson.getFieldNames(); fieldNames.hasNext();) { String field = fieldNames.next(); Assert.assertEquals(expectedJson.get(field), actualJson.get(field)); } }