List of usage examples for java.util Calendar HOUR
int HOUR
To view the source code for java.util Calendar HOUR.
Click Source Link
get
and set
indicating the hour of the morning or afternoon. From source file:com.krawler.spring.hrms.common.hrmsCommonDAOImpl.java
@Override public boolean editEmpProfileForRehOfFutureDates() { boolean success = false; try {/*w w w . ja v a 2 s . c o m*/ Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date today = calendar.getTime(); calendar.add(Calendar.DAY_OF_MONTH, 1); Date tmr = calendar.getTime(); String hql = "update Empprofile set termnd = ?, confirmdate = ?, relievedate = ? where joindate >= ? and joindate < ?"; int a = HibernateUtil.executeUpdate(hibernateTemplate, hql, new Object[] { false, null, null, today, tmr }); success = true; } catch (Exception e) { e.printStackTrace(); } finally { return success; } }
From source file:com.krawler.spring.hrms.common.hrmsCommonDAOImpl.java
@Override public boolean editUserForRehOfFutureDates() { boolean success = false; try {/*from w ww .j av a 2 s.c o m*/ Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date today = calendar.getTime(); calendar.add(Calendar.DAY_OF_MONTH, 1); Date tmr = calendar.getTime(); String hql = "update User set deleteflag = ? where userID IN (select userID from Empprofile where joindate >= ? and joindate < ?)"; int a = HibernateUtil.executeUpdate(hibernateTemplate, hql, new Object[] { 0, today, tmr }); success = true; } catch (Exception e) { e.printStackTrace(); } finally { return success; } }
From source file:com.nest5.businessClient.Initialactivity.java
private void makeDailyTable(int TABLE_TYPE) { dailyTable.removeAllViews();/*from w ww.jav a 2s. c o m*/ Double total = 0.0; DecimalFormat dec = new DecimalFormat("$###,###,###"); TextView tv = new TextView(mContext); tv.setBackgroundColor(Color.parseColor("#80808080")); tv.setHeight(2); TableRow tr1 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate1 = (TextView) tr1.findViewById(R.id.cell_date); TextView tItem1 = (TextView) tr1.findViewById(R.id.cell_item); TextView tAccount1 = (TextView) tr1.findViewById(R.id.cell_account); TextView tVal1 = (TextView) tr1.findViewById(R.id.cell_value); TextView tTot1 = (TextView) tr1.findViewById(R.id.cell_total); tDate1.setText("FECHA"); tAccount1.setText("CUENTA"); tItem1.setText("ITEM"); tVal1.setText("VALOR"); tTot1.setText("TOTAL"); tr1.setBackgroundColor(Color.CYAN); dailyTable.addView(tr1); dailyTable.addView(tv); //actualizar sales de hoy Calendar today = Calendar.getInstance(); Calendar tomorrow = Calendar.getInstance(); today.set(Calendar.HOUR, 0); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); tomorrow.roll(Calendar.DATE, 1); tomorrow.set(Calendar.HOUR, 0); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); init = today.getTimeInMillis(); end = tomorrow.getTimeInMillis(); Log.d("GUARDANDOVENTA", today.toString()); Log.d("GUARDANDOVENTA", tomorrow.toString()); Calendar now = Calendar.getInstance(); now.setTimeInMillis(System.currentTimeMillis()); Log.d(TAG, now.toString()); Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init)); salesFromToday = saleDataSource.getAllSalesWithin(init, end); List<Sale> usingSales = salesFromToday; switch (TABLE_TYPE) { case TABLE_TYPE_TODAY: usingSales = salesFromToday; break; case TABLE_TYPE_ALL: usingSales = saleList; break; } for (Sale currentSale : usingSales) { double totalLocal = 0.0; LinkedHashMap<Combo, Double> combos = currentSale.getCombos(); LinkedHashMap<Product, Double> products = currentSale.getProducts(); LinkedHashMap<Ingredient, Double> ingredients = currentSale.getIngredients(); Log.w("DAYILETABLES", " " + combos.size() + " " + products.size() + " " + ingredients.size()); Iterator<Entry<Combo, Double>> it = combos.entrySet().iterator(); Calendar date = Calendar.getInstance(); date.setTimeInMillis(currentSale.getDate()); String fecha = date.get(Calendar.MONTH) + "/" + date.get(Calendar.DAY_OF_MONTH) + "/" + date.get(Calendar.YEAR) + "\n" + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND); String account = currentSale.getPaymentMethod(); while (it.hasNext()) { TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Map.Entry<Combo, Double> pair = (Map.Entry<Combo, Double>) it.next(); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName() + " en Combo"); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Product, Double>> it2 = products.entrySet().iterator(); while (it2.hasNext()) { Map.Entry<Product, Double> pair = (Map.Entry<Product, Double>) it2.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Ingredient, Double>> it3 = ingredients.entrySet().iterator(); while (it3.hasNext()) { Map.Entry<Ingredient, Double> pair = (Map.Entry<Ingredient, Double>) it3.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); tDate.setText(fecha); tAccount.setText("-------"); tItem.setText("Ingreso por Ventas"); tVal.setText("----"); tTot.setText(dec.format(totalLocal)); tr.setBackgroundColor(Color.LTGRAY); dailyTable.addView(tr); TableRow tr2 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate2 = (TextView) tr2.findViewById(R.id.cell_date); TextView tItem2 = (TextView) tr2.findViewById(R.id.cell_item); TextView tAccount2 = (TextView) tr2.findViewById(R.id.cell_account); TextView tVal2 = (TextView) tr2.findViewById(R.id.cell_value); TextView tTot2 = (TextView) tr2.findViewById(R.id.cell_total); tDate2.setText(fecha); tAccount2.setText("-------"); tItem2.setText("Acumulado por Ventas"); tVal2.setText("----"); tTot2.setText(dec.format(total)); tr2.setBackgroundColor(Color.GRAY); dailyTable.addView(tr2); } }
From source file:ch.algotrader.service.LookupServiceTest.java
@Test public void testGetLastNBarsBySecurityAndBarSize() { SecurityFamily family1 = new SecurityFamilyImpl(); family1.setName("Forex1"); family1.setTickSizePattern("0<0.1"); family1.setCurrency(Currency.USD); Forex forex1 = new ForexImpl(); forex1.setSymbol("EUR.USD"); forex1.setBaseCurrency(Currency.EUR); forex1.setSecurityFamily(family1);//w w w. j ava2 s .c om this.session.save(family1); this.session.save(forex1); Bar bar1 = new BarImpl(); bar1.setDateTime(new Date()); bar1.setBarSize(Duration.MIN_1); bar1.setOpen(new BigDecimal(222)); bar1.setHigh(new BigDecimal(333)); bar1.setLow(new BigDecimal(111)); bar1.setClose(new BigDecimal(444)); bar1.setFeedType(FeedType.CNX.name()); bar1.setSecurity(forex1); Bar bar2 = new BarImpl(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR, -2); bar2.setDateTime(cal.getTime()); bar2.setBarSize(Duration.MIN_1); bar2.setOpen(new BigDecimal(555)); bar2.setHigh(new BigDecimal(666)); bar2.setLow(new BigDecimal(777)); bar2.setClose(new BigDecimal(888)); bar2.setFeedType(FeedType.BB.name()); bar2.setSecurity(forex1); this.session.save(bar1); this.session.save(bar2); this.session.flush(); int limit1 = 1; List<Bar> bars1 = lookupService.getLastNBarsBySecurityAndBarSize(limit1, forex1.getId(), Duration.MIN_1); Assert.assertEquals(1, bars1.size()); Assert.assertSame(bar1, bars1.get(0)); int limit2 = 2; List<Bar> bars2 = lookupService.getLastNBarsBySecurityAndBarSize(limit2, forex1.getId(), Duration.MIN_1); Assert.assertEquals(2, bars2.size()); Assert.assertSame(bar1, bars2.get(0)); Assert.assertSame(bar2, bars2.get(1)); }
From source file:com.emc.esu.test.EsuApiTest.java
@Test public void testGetShareableUrlAndDisposition() throws Exception { Assume.assumeFalse(isVipr);/* w ww. j a v a2 s. c om*/ // Create an object with content. String str = "Four score and twenty years ago"; ObjectId id = this.esu.createObject(null, null, str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); cleanup.add(id); String disposition = "attachment; filename=\"foo bar.txt\""; Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.esu.getShareableUrl(id, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content.toString()); }
From source file:com.emc.atmos.api.test.AtmosApiClientTest.java
@Test public void testGetShareableUrlAndDisposition() throws Exception { Assume.assumeFalse(isVipr);// w w w . j a v a 2s . c o m // Create an object with content. String str = "Four score and twenty years ago"; ObjectId id = this.api.createObject(str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); cleanup.add(id); String disposition = "attachment; filename=\"foo bar.txt\""; Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.api.getShareableUrl(id, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content); }
From source file:com.emc.esu.test.EsuApiTest.java
@Test public void testGetShareableUrlWithPathAndDisposition() throws Exception { Assume.assumeFalse(isVipr);//from w w w . ja v a2s . com // Create an object with content. String str = "Four score and twenty years ago"; ObjectPath op = new ObjectPath("/" + rand8char() + ".txt"); ObjectId id = this.esu.createObjectOnPath(op, null, null, str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); //cleanup.add( op ); String disposition = "attachment; filename=\"foo bar.txt\""; Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.esu.getShareableUrl(op, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content.toString()); }
From source file:com.emc.atmos.api.test.AtmosApiClientTest.java
@Test public void testGetShareableUrlWithPathAndDisposition() throws Exception { Assume.assumeFalse(isVipr);/* w ww .j a va2 s . com*/ // Create an object with content. String str = "Four score and twenty years ago"; ObjectPath op = new ObjectPath("/" + rand8char() + ".txt"); ObjectId id = this.api.createObject(op, str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); //cleanup.add( op ); String disposition = "attachment; filename=\"foo bar.txt\""; Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.api.getShareableUrl(op, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content); }
From source file:com.emc.esu.test.EsuApiTest.java
@Test public void testGetShareableUrlWithPathAndUTF8Disposition() throws Exception { Assume.assumeFalse(isVipr);// ww w .j a v a2 s .com // Create an object with content. String str = "Four score and twenty years ago"; ObjectPath op = new ObjectPath("/" + rand8char() + ".txt"); ObjectId id = this.esu.createObjectOnPath(op, null, null, str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); //cleanup.add( op ); // One cryllic, one accented, and one japanese character // RFC5987 String disposition = "attachment; filename=\"no UTF support.txt\"; filename*=UTF-8''" + URLEncoder.encode(".txt", "UTF-8"); Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.esu.getShareableUrl(op, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content.toString()); }
From source file:com.emc.atmos.api.test.AtmosApiClientTest.java
@Test public void testGetShareableUrlWithPathAndUTF8Disposition() throws Exception { // Create an object with content. Assume.assumeFalse(isVipr);/*w w w. ja v a2s . com*/ String str = "Four score and twenty years ago"; ObjectPath op = new ObjectPath("/" + rand8char() + ".txt"); ObjectId id = this.api.createObject(op, str.getBytes("UTF-8"), "text/plain"); Assert.assertNotNull("null ID returned", id); //cleanup.add( op ); // One cryllic, one accented, and one japanese character // RFC5987 String disposition = "attachment; filename=\"no UTF support.txt\"; filename*=UTF-8''" + URLEncoder.encode(".txt", "UTF-8"); Calendar c = Calendar.getInstance(); c.add(Calendar.HOUR, 4); Date expiration = c.getTime(); URL u = this.api.getShareableUrl(op, expiration, disposition); l4j.debug("Sharable URL: " + u); InputStream stream = (InputStream) u.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String content = br.readLine(); l4j.debug("Content: " + content); Assert.assertEquals("URL does not contain proper content", str, content); }