List of usage examples for java.util Calendar JANUARY
int JANUARY
To view the source code for java.util Calendar JANUARY.
Click Source Link
From source file:org.hibernate.search.test.dsl.embedded.DslEmbeddedSearchTest.java
@Test @TestForIssue(jiraKey = "HSEARCH-2070") public void testSearchDateWithoutFieldBridge() throws Exception { QueryBuilder qb = helper.queryBuilder(ContainerEntity.class); Query q = qb.range().onField("emb.date").above(initCalendar(2007, Calendar.JANUARY, 14).getTime()) .createQuery();/* www.j a v a 2 s. c om*/ assertQuery(q).matchesExactlyIds(1L); }
From source file:py.una.pol.karaku.test.test.FormatProviderTest.java
/** * */// w ww .ja va 2 s . c o m @Before public void setUp() { calendar = GregorianCalendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DATE, 1); calendar.set(Calendar.HOUR_OF_DAY, 6); calendar.set(Calendar.MINUTE, 30); calendar.set(Calendar.SECOND, 10); date = calendar.getTime(); veryLarge = this.getByString("1000000000000"); large = this.getByString("100000"); small = this.getByString("100"); verySmall = this.getByString("1"); decimal = this.getByString("0.111"); decimalUP = this.getByString("0.119"); smallDecimal = this.getByString("0.0111"); smallDecimalUP = this.getByString("0.0159"); }
From source file:org.polymap.kaps.ui.filter.VertraegeNutzungsartenFilter.java
protected Query<VertragComposite> createFilterQuery(final IFilterEditorSite site, final KapsRepository repository) { BooleanExpression jExpr = null;/*from www . j a va2 s . com*/ VertragComposite template = QueryExpressions.templateFor(VertragComposite.class); Integer jahr = Integer.parseInt((String) site.getFieldValue("Jahr")); if (jahr != null) { Calendar lowerCal = new GregorianCalendar(); lowerCal.set(Calendar.YEAR, jahr); lowerCal.set(Calendar.DAY_OF_MONTH, 1); lowerCal.set(Calendar.HOUR_OF_DAY, 0); lowerCal.set(Calendar.MINUTE, 0); lowerCal.set(Calendar.SECOND, 0); lowerCal.set(Calendar.MILLISECOND, 0); Calendar upperCal = new GregorianCalendar(); upperCal.setTime(lowerCal.getTime()); lowerCal.set(Calendar.MONTH, Calendar.JANUARY); upperCal.roll(Calendar.YEAR, true); upperCal.set(Calendar.MONTH, Calendar.JANUARY); jExpr = QueryExpressions.and(QueryExpressions.ge(template.vertragsDatum(), lowerCal.getTime()), QueryExpressions.lt(template.vertragsDatum(), upperCal.getTime())); } Set<Integer> nummern = Sets.newHashSet(); for (VertragComposite vertrag : repository().findEntities(VertragComposite.class, jExpr, 0, -1)) { NutzungComposite nutzung = null; for (FlurstueckComposite flurstueck : FlurstueckComposite.Mixin.forEntity(vertrag)) { if (nutzung == null) { nutzung = flurstueck.nutzung().get(); } else if (!nutzung.equals(flurstueck.nutzung().get())) { log.info("Found difference in " + vertrag.eingangsNr().get()); nummern.add(vertrag.eingangsNr().get()); continue; } } } BooleanExpression fExpr = null; for (Integer nummer : nummern) { BooleanExpression newExpr = QueryExpressions.eq(template.eingangsNr(), nummer); if (fExpr == null) { fExpr = newExpr; } else { fExpr = QueryExpressions.or(fExpr, newExpr); } } // wenn keine gefunden, ungltige Query erzeugen, damit auch keine // Vertrge gefunden werden if (fExpr == null) { fExpr = QueryExpressions.eq(template.identity(), "unknown"); } return repository().findEntities(VertragComposite.class, fExpr, 0, getMaxResults()); }
From source file:org.apache.hadoop.hive.ql.exec.vector.expressions.TestVectorTimestampExpressions.java
private Timestamp[] getAllBoundaries(int minYear, int maxYear) { ArrayList<Timestamp> boundaries = new ArrayList<Timestamp>(1); Calendar c = Calendar.getInstance(); c.setTimeInMillis(0); // c.set doesn't reset millis for (int year = minYear; year <= maxYear; year++) { c.set(year, Calendar.JANUARY, 1, 0, 0, 0); if (c.get(Calendar.YEAR) < 0 || c.get(Calendar.YEAR) >= 10000) { continue; }// w w w . j a v a2 s . c o m long exactly = c.getTimeInMillis(); /* one second before and after */ long before = exactly - 1000; long after = exactly + 1000; if (minYear != 0) { boundaries.add(new Timestamp(before)); } boundaries.add(new Timestamp(exactly)); if (year != maxYear) { boundaries.add(new Timestamp(after)); } } return boundaries.toArray(new Timestamp[0]); }
From source file:org.openmrs.web.servlet.SampleFlowsheetServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("Getting sample flowsheet"); response.setContentType("text/html"); HttpSession session = request.getSession(); String pid = request.getParameter("pid"); if (pid == null || pid.length() == 0) { session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.null"); return;//from ww w. ja v a 2 s .co m } if (!Context.isAuthenticated() || !Context.hasPrivilege(PrivilegeConstants.GET_PATIENTS) || !Context.hasPrivilege(PrivilegeConstants.GET_OBS)) { session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Privileges required: " + PrivilegeConstants.GET_PATIENTS + " and " + PrivilegeConstants.GET_OBS); session.setAttribute(WebConstants.OPENMRS_LOGIN_REDIRECT_HTTPSESSION_ATTR, request.getRequestURI() + "?" + request.getQueryString()); response.sendRedirect(request.getContextPath() + "/login.htm"); return; } ServletOutputStream out = response.getOutputStream(); Integer patientId = Integer.parseInt(pid); Patient patient = Context.getPatientService().getPatient(patientId); List<Obs> obsList = Context.getObsService().getObservationsByPerson(patient); if (obsList == null || obsList.size() < 1) { out.print("No observations found"); return; } out.println("<style>"); out.println(".header { font-family:Arial; font-weight:bold; text-align: center; font-size: 1.5em;}"); out.println( ".label { font-family:Arial; text-align:right; color:#808080; font-style:italic; font-size: 0.6em; vertical-align: top;}"); out.println(".value { font-family:Arial; text-align:left; vertical-align:top; }"); out.println("</style>"); out.println("<table cellspacing=0 cellpadding=3>"); Locale locale = Context.getLocale(); Calendar date = Calendar.getInstance(); date.set(1900, Calendar.JANUARY, 1); Calendar obsDate = Calendar.getInstance(); for (Obs obs : obsList) { obsDate.setTime(obs.getObsDatetime()); if (Math.abs(obsDate.getTimeInMillis() - date.getTimeInMillis()) > 86400000) { date = obsDate; out.println("<tr><td class=header colspan=2>" + Context.getDateFormat().format(date.getTime()) + "</td></tr>"); } StringBuilder s = new StringBuilder("<tr><td class=label>"); s.append(getName(obs, locale)); s.append("</td><td class=value>"); s.append(getValue(obs, locale)); s.append("</td></tr>"); out.println(s.toString()); } out.println("</table>"); }
From source file:adalid.commons.util.TimeUtils.java
public static synchronized Time getTime(java.util.Date date) { if (date == null) { return currentTime(); }/*w w w.j av a 2 s . c o m*/ Calendar c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); c.set(Calendar.YEAR, 1970); c.set(Calendar.MONTH, Calendar.JANUARY); c.set(Calendar.DAY_OF_MONTH, 1); return new Time(c.getTimeInMillis()); }
From source file:ws.michalski.sepa.pain.CreditTransaction.java
@Override public void validate() throws SEPAException { // Falls BIC nicht belegt, mit NOTPROVIDED belegen if (BIC == null || BIC.isEmpty()) { BIC = "NOTPROVIDED"; }// w w w . j av a 2s . c om // Falls Ausfhrungsdatum nicht belegt if (executionDate == null) { calendar.set(1999, Calendar.JANUARY, 1); executionDate = (GregorianCalendar) calendar; } // Anzahl Positionen setzen nbrOfTransaction = creditTransactionList.size(); // Kontrollsumme berechnen ctlSum = BigDecimal.ZERO; for (CreditTransactionItem cti : creditTransactionList) { ctlSum = ctlSum.add(cti.getAmount()); } // Felder prfen if (IBAN == null || IBAN.isEmpty()) { throw new SEPAException("IBAN Fehler"); } if (IBAN.length() > 34) { throw new SEPAException("IBAN Lnge > 34"); } if (BIC.length() != 8 && BIC.length() != 11) { throw new SEPAException("BIC nicht 8 bzw. 11 stellig"); } if (name == null || name.isEmpty()) { throw new SEPAException("Name ist nicht belegt."); } if (name.length() > 70) { throw new SEPAException("Name ist lnger 70."); } }
From source file:net.ajaskey.market.ta.methods.RegressionMethods.java
/** * This method serves as a constructor for the class. * *//* w ww. j a v a2s . c o m*/ public RegressionMethods() { this.baseCal = Calendar.getInstance(); this.baseCal.set(1900, Calendar.JANUARY, 1, 12, 0, 1); this.dataCount = 0; this.minDate = Calendar.getInstance(); this.maxDate = this.baseCal; }
From source file:org.techytax.util.DateHelper.java
public static FiscalPeriod getPeriodPreviousYear() { Calendar cal = new GregorianCalendar(); cal.setTime(new Date()); cal.add(Calendar.YEAR, -1);/*from ww w . ja v a 2s . com*/ cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); Date beginDatum = cal.getTime(); cal.set(Calendar.MONTH, Calendar.DECEMBER); cal.set(Calendar.DAY_OF_MONTH, 31); Date eindDatum = cal.getTime(); return new FiscalPeriod(beginDatum, eindDatum); }
From source file:com.mycompany.CRMFly.serviceLayer.ClientsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Clients client) { Long id = client.getId();/* w w w . j a v a 2 s. co m*/ Calendar calendar = new GregorianCalendar(); Integer monthDifference = 0; if (calendar.get(Calendar.MONTH) == Calendar.JANUARY || calendar.get(Calendar.MONTH) == Calendar.APRIL || calendar.get(Calendar.MONTH) == Calendar.JULY || calendar.get(Calendar.MONTH) == Calendar.OCTOBER) { monthDifference = 0; } else if (calendar.get(Calendar.MONTH) == Calendar.FEBRUARY || calendar.get(Calendar.MONTH) == Calendar.MAY || calendar.get(Calendar.MONTH) == Calendar.AUGUST || calendar.get(Calendar.MONTH) == Calendar.NOVEMBER) { monthDifference = -1; } else if (calendar.get(Calendar.MONTH) == Calendar.MARCH || calendar.get(Calendar.MONTH) == Calendar.JUNE || calendar.get(Calendar.MONTH) == Calendar.SEPTEMBER || calendar.get(Calendar.MONTH) == Calendar.DECEMBER) monthDifference = -2; // Integer dayDifference = -calendar.get(Calendar.DAY_OF_MONTH); calendar.add(Calendar.MONTH, monthDifference); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); // calendar.add(Calendar.DAY_OF_MONTH, dayDifference-1); Date beginningOfQuarter = calendar.getTime(); Double thisQuarterSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackOne = calendar.getTime(); Double QuarterBackOneSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackTwo = calendar.getTime(); Double QuarterBackTwoSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackThree = calendar.getTime(); Double QuarterBackThreeSum = 0.0; List<Contracts> contracts = clientsDAO.getContractsForClient(id); HashMap<Date, Double> sums = new HashMap<Date, Double>(); for (Contracts contract : contracts) { Date date = contract.getBegin_date(); if (date.after(beginningOfQuarter)) thisQuarterSum += contract.getTotalSum(); else if (date.after(QuarterBackOne)) QuarterBackOneSum += contract.getTotalSum(); else if (date.after(QuarterBackTwo)) QuarterBackTwoSum += contract.getTotalSum(); else if (date.after(QuarterBackThree)) QuarterBackThreeSum += contract.getTotalSum(); } sums.put(beginningOfQuarter, thisQuarterSum); sums.put(QuarterBackOne, QuarterBackOneSum); sums.put(QuarterBackTwo, QuarterBackTwoSum); sums.put(QuarterBackThree, QuarterBackThreeSum); return sums; }