List of usage examples for java.util Calendar DATE
int DATE
To view the source code for java.util Calendar DATE.
Click Source Link
get
and set
indicating the day of the month. From source file:com.erpi.mdxudf.GetDateInfo.java
public Object execute(Evaluator evaluator, Argument[] arguments) { synchronized (this) { if (udfName.equals("getDateString")) { // get input string as int Object oDays = arguments[0].evaluate(evaluator); String sDays = oDays.toString(); float fDays = Float.parseFloat(sDays); int iDays = (int) fDays; //int iDays = Integer.parseInt(sDays); // create Calendar starting at 1900/01/01 and bump by input days Calendar c = Calendar.getInstance(); c.set(1900, 00, 01);/*from ww w . j av a2 s . c o m*/ c.add(Calendar.DATE, iDays); // fomat date string SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); returnString = sdf.format(c.getTime()); } else { returnString = ""; } if (log.isDebugEnabled()) { log.debug(" returnString: " + returnString); } return returnString; } }
From source file:CNCServicesServlet.CNCServices.java
/** * Demo Call Buy Card Service/*ww w . j av a 2s .co m*/ */ private String BuyCard(HttpServletRequest request) { String txtData = ""; String txtAgentCode = request.getServletContext().getInitParameter("agentCode"); String txtAgentKey = request.getServletContext().getInitParameter("agentKey"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 7); Date date = cal.getTime(); SimpleDateFormat ft = new SimpleDateFormat("YYYYMMddhhmmssss"); BuyCardRequest bcr = new BuyCardRequest(txtAgentCode, "VT", ft.format(date).toString(), 10000, 2); String bcrString = bcr.toString(); ResponseRequest rr = new ResponseRequest(); try { txtData = Util.Encrypt(txtAgentKey, bcrString); Softpin soft = new Softpin(); String result = soft.getSoftpinSoap12().buyCard(txtAgentCode, txtData); JSONObject jsonObject = new JSONObject(result); String msg = jsonObject.isNull("msg") ? "" : jsonObject.getString("msg"); rr.setMsg(msg); String tranid = jsonObject.isNull("tranid") ? "" : jsonObject.getString("tranid"); rr.setTranid(tranid); String listCards = jsonObject.isNull("listCards") ? "" : jsonObject.getString("listCards"); Integer code = jsonObject.getInt("code"); rr.setCode(code); if (code == 1) { String listResult = Util.Decrypt(txtAgentKey, listCards); rr.setListCards(listResult); System.out.println("success"); } else { rr.setListCards(""); System.out.println("Error=" + msg); } } catch (Exception e) { rr.setListCards(""); System.out.println("error=" + e.getMessage()); } return rr.toString(); }
From source file:it.generatore.DateRandomGaussianGeneratorTest.java
@Test public void testGet() throws Exception { int i = 0;// w w w .j a v a2 s .co m int inFascia = 0; int fuoriFascia = 0; Calendar cal = GregorianCalendar.getInstance(); cal.setTimeInMillis(dateRandomGaussianGenerator.minDate); cal = DateUtils.truncate(cal, Calendar.DATE); System.out.println(sdf.format(cal.getTime())); Map<String, Integer> distribuzione = new HashMap<>(); while (++i <= 24 * 60) { cal.add(Calendar.MINUTE, 1); distribuzione.put(getHourKey(cal), 0); } System.out.println(distribuzione.keySet()); i = 0; while (++i <= NUMERO_RECORD) { String strDate = dateRandomGaussianGenerator.get(); //System.out.println("strDate:" + strDate); Matcher m = pattern.matcher(strDate); assertTrue(m.find()); strDate = m.group(1); // System.out.println("strDate:" + strDate); Date date = sdf.parse(strDate); cal.setTime(date); String hourKey = getHourKey(cal); Integer actualValue = distribuzione.get(hourKey); distribuzione.remove(hourKey); distribuzione.put(hourKey, actualValue + 1); if (cal.get(Calendar.HOUR_OF_DAY) >= 9 && cal.get(Calendar.HOUR_OF_DAY) <= 18) { inFascia++; } else { fuoriFascia++; } //System.out.println(strDate); } System.out.println("**** terminato. In fascia: " + inFascia + " fuoriFascia: " + fuoriFascia + " % in fascia: " + (inFascia / NUMERO_RECORD)); assertTrue(inFascia / NUMERO_RECORD >= 0.7d); assertTrue(fuoriFascia / NUMERO_RECORD <= 0.3d); assertTrue(inFascia + fuoriFascia == NUMERO_RECORD); }
From source file:net.duckling.ddl.service.share.impl.ShareFileAccessServiceImpl.java
@Override public String getRestOfVaildDays(ShareFileAccess s) { Calendar c = Calendar.getInstance(); c.setTime(s.getCreateTime());/*from w ww . j a v a2s . c om*/ c.add(Calendar.DATE, s.getValidOfDays()); Date now = new Date(); return AoneTimeUtils.getLastTime(c.getTimeInMillis() - now.getTime()); }
From source file:com.cemeterylistingswebtest.test.rest.LoginControllerTest.java
@Test(enabled = false) public void testCreate() { Long subID = new Long(17); 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(); Subscriber newSub = new Subscriber.Builder().setEmail("manfredOsulivan@horseRaddish.com") .setFirstName("Manfred").setSurname("Osulivan").setPwd("applesandsuch").setUsername("ManiFredOssy") .setSubscriptionDate(javaSqlDate).setUserRoleID(user).build(); HttpEntity<Subscriber> requestEntity = new HttpEntity<>(newSub, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/Subscriber/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); id = newSub.getSubscriberID();/* ww w .j av a 2 s .c o m*/ }
From source file:com.github.jgility.core.planning.AbstractPlan.java
/** * Instanziiert ein Objekt der abstrakten Klasse {@link AbstractPlan}. Der Startwert is das * aktuelle {@link Calendar}-Objekt. Das Ende ist auf 14-Tage datiert. *///from w ww. j a v a 2s . c o m public AbstractPlan() { Calendar calStart = new GregorianCalendar(); Calendar calEnd = new GregorianCalendar(); calEnd.add(Calendar.DATE, 14); start = calStart; end = calEnd; }
From source file:org.opensafety.hishare.model.factories.ParcelFactory.java
public Parcel createParcel(String parcelName, Integer daysToLive) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, daysToLive); Parcel newParcel = null;//from ww w . j a v a 2 s . c o m try { String password = encryption.createPassword(); byte[] salt = encryption.createSalt(); byte[] hashedPassword = encryption.hashPassword(password, salt); newParcel = new Parcel(createParcelId(), parcelName, calendar.getTime(), createPayloadLocation(), password, hashedPassword, salt); } catch (CryptographyException e) { log.error("Parcel Creation Failed", e); } return newParcel; }
From source file:net.sf.ipsedixit.integration.spring.AnnotatedClassAddCustomHandlerIntegrationTest.java
@Test public void hasWorked() { assertThat(stubDate.toString(), Matchers.containsString("Proxy for java.util.Date")); Date todaysDate = truncate(new Date(), Calendar.DATE); assertThat(today.getTime(), equalTo(todaysDate.getTime())); }
From source file:org.openmrs.module.kenyaemr.reporting.builder.hiv.DecliningCd4ReportBuilder.java
@Override protected void addColumns(CohortReportDescriptor report, PatientDataSetDefinition dsd) { Concept concept = Dictionary.getConcept(Dictionary.CD4_COUNT); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -180); Date onOrBefore = calendar.getTime(); addStandardColumns(report, dsd);//from ww w .j av a2 s . c o m dsd.addColumn("Previous CD4", new ObsForPersonDataDefinition("Previous CD4", TimeQualifier.LAST, concept, onOrBefore, null), "", new DataConverter() { @Override public Class<?> getInputDataType() { return Obs.class; } @Override public Class<?> getDataType() { return Double.class; } @Override public Object convert(Object input) { return ((Obs) input).getValueNumeric(); } }); dsd.addColumn("Current CD4", new ObsForPersonDataDefinition("Current CD4", TimeQualifier.LAST, concept, new Date(), null), "", new DataConverter() { @Override public Class<?> getInputDataType() { return Obs.class; } @Override public Class<?> getDataType() { return Double.class; } @Override public Object convert(Object input) { return ((Obs) input).getValueNumeric(); } }); }
From source file:com.cemeterylistingswebtest.test.rest.RegistrationControllerTest.java
@Test(enabled = false) public void testCreate() { System.out.println("Registration Testing"); 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(); Subscriber newSub = new Subscriber.Builder().setEmail("zaakir@gmail.com").setFirstName("zaakir") .setSurname("arendse").setPwd("123").setUsername("zak").setSubscriptionDate(javaSqlDate) .setUserRoleID(user).build(); HttpEntity<Subscriber> requestEntity = new HttpEntity<>(newSub, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/Registration/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); id = newSub.getSubscriberID();//from w w w . jav a2 s.c om }