List of usage examples for java.util Calendar SECOND
int SECOND
To view the source code for java.util Calendar SECOND.
Click Source Link
get
and set
indicating the second within the minute. From source file:net.servicefixture.converter.XMLGregorianCalendarConverter.java
public String toString(Object source) { XMLGregorianCalendar src = (XMLGregorianCalendar) source; SimpleDateFormat formatter = new SimpleDateFormat(DateConverter.DATE_FORMAT); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, src.getYear()); cal.set(Calendar.MONTH, src.getMonth() - 1); cal.set(Calendar.DAY_OF_MONTH, src.getDay()); cal.set(Calendar.HOUR, src.getHour()); cal.set(Calendar.MINUTE, src.getMinute()); cal.set(Calendar.SECOND, src.getSecond()); cal.set(Calendar.MILLISECOND, src.getMillisecond()); return formatter.format(cal.getTime()); }
From source file:com.mothsoft.alexis.engine.numeric.TopicActivityDataSetImporter.java
@Override public void importData() { if (this.transactionTemplate == null) { this.transactionTemplate = new TransactionTemplate(this.transactionManager); }//from w ww . j a v a 2 s . c o m final List<Long> userIds = listUserIds(); final GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); int minute = calendar.get(Calendar.MINUTE); if (minute >= 45) { calendar.set(Calendar.MINUTE, 30); } else if (minute >= 30) { calendar.set(Calendar.MINUTE, 15); } else if (minute >= 15) { calendar.set(Calendar.MINUTE, 0); } else if (minute >= 0) { calendar.set(Calendar.MINUTE, 45); calendar.add(Calendar.HOUR_OF_DAY, -1); } final Date startDate = calendar.getTime(); calendar.add(Calendar.MINUTE, 15); calendar.add(Calendar.MILLISECOND, -1); final Date endDate = calendar.getTime(); for (final Long userId : userIds) { importTopicDataForUser(userId, startDate, endDate); } }
From source file:csns.model.academics.Assignment.java
public Assignment() { dueDate = Calendar.getInstance(); dueDate.add(Calendar.DATE, 7); dueDate.set(Calendar.HOUR_OF_DAY, 23); dueDate.set(Calendar.MINUTE, 59); dueDate.set(Calendar.SECOND, 59); dueDate.set(Calendar.MILLISECOND, 0); submissions = new ArrayList<Submission>(); fileExtensionSet = new HashSet<String>(); availableAfterDueDate = true;/*w w w. j a va 2 s .c o m*/ deleted = false; }
From source file:net.sourceforge.eclipsetrader.opentick.HistoryFeed.java
public void updateHistory(Security security, int interval) { try {// ww w. j a v a 2 s. c o m client.login(15 * 1000); } catch (Exception e) { log.error(e, e); } if (interval == IHistoryFeed.INTERVAL_DAILY) { log.info("Updating historical data for " + security); try { requestHistoryStream(security, 60 * 1000); } catch (Exception e) { log.error(e, e); } } if (interval == IHistoryFeed.INTERVAL_MINUTE) { String symbol = security.getHistoryFeed().getSymbol(); if (symbol == null || symbol.length() == 0) symbol = security.getCode(); String exchange = security.getHistoryFeed().getExchange(); if (exchange == null || exchange.length() == 0) exchange = "Q"; History history = security.getIntradayHistory(); history.clear(); BackfillClientAdapter adapter = new BackfillClientAdapter(security); client.addListener(adapter); Calendar from = Calendar.getInstance(); from.set(Calendar.HOUR, 0); from.set(Calendar.MINUTE, 0); from.set(Calendar.SECOND, 0); from.set(Calendar.MILLISECOND, 0); from.add(Calendar.DATE, -5); int startTime = (int) (from.getTimeInMillis() / 1000); Calendar to = Calendar.getInstance(); to.set(Calendar.MILLISECOND, 0); int endTime = (int) (to.getTimeInMillis() / 1000); log.info("Updating intraday data for " + security); adapter.started = System.currentTimeMillis(); try { adapter.historyStream = client.requestHistData(new OTDataEntity(exchange, symbol), startTime, endTime, OTConstants.OT_HIST_OHLC_MINUTELY, 1); while ((System.currentTimeMillis() - adapter.started) < 60 * 1000 && !adapter.isCompleted()) Thread.sleep(100); } catch (Exception e) { log.error(e, e); } client.removeListener(adapter); Collections.sort(security.getDividends(), new Comparator() { public int compare(Object o1, Object o2) { return ((Dividend) o1).getDate().compareTo(((Dividend) o2).getDate()); } }); Collections.sort(security.getSplits(), new Comparator() { public int compare(Object o1, Object o2) { return ((Split) o1).getDate().compareTo(((Split) o2).getDate()); } }); CorePlugin.getRepository().save(history); CorePlugin.getRepository().save(security); } }
From source file:Main.java
/** * Return the preferred size of this component. * * @return the preferred size of this component. *//* ww w . j a v a2s . c o m*/ public Dimension getPreferredSize() { if (null == _prefSize) { // This was originaly done every time. // and the count of instantiated objects was amazing _prefSize = new Dimension(); _prefSize.height = 20; FontMetrics fm = getFontMetrics(getFont()); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); _prefSize.width = fm.stringWidth(_fmt.format(cal.getTime())); Border border = getBorder(); if (border != null) { Insets ins = border.getBorderInsets(this); if (ins != null) { _prefSize.width += (ins.left + ins.right); } } Insets ins = getInsets(); if (ins != null) { _prefSize.width += (ins.left + ins.right) + 20; } } return _prefSize; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFCoverPageBaseGenerator.java
/** * /*from w w w . j a v a2 s .c o m*/ * This method Converts the String that is passed to it into a calendar * object. The argument will be set as the Year in the Calendar Object. * * @param year - * The String value to be converted to Calendar Object * @return calendar value corresponding to the year(String) passed. */ public Calendar getYearAsCalendar(String year) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.DATE, 0); calendar.set(Calendar.MONTH, 0); try { calendar.set(Calendar.YEAR, Integer.parseInt(year)); } catch (NumberFormatException ex) { calendar.set(Calendar.YEAR, 0); } return calendar; }
From source file:net.groupbuy.controller.admin.StaticController.java
/** * ???//from w w w.j a v a2 s . c o m */ @RequestMapping(value = "/build", method = RequestMethod.POST) public @ResponseBody Map<String, Object> build(BuildType buildType, Long articleCategoryId, Long productCategoryId, Date beginDate, Date endDate, Integer first, Integer count) { long startTime = System.currentTimeMillis(); if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (first == null || first < 0) { first = 0; } if (count == null || count <= 0) { count = 50; } int buildCount = 0; boolean isCompleted = true; if (buildType == BuildType.index) { buildCount = staticService.buildIndex(); } else if (buildType == BuildType.article) { ArticleCategory articleCategory = articleCategoryService.find(articleCategoryId); List<Article> articles = articleService.findList(articleCategory, beginDate, endDate, first, count); for (Article article : articles) { buildCount += staticService.build(article); } first += articles.size(); if (articles.size() == count) { isCompleted = false; } } else if (buildType == BuildType.product) { ProductCategory productCategory = productCategoryService.find(productCategoryId); List<Product> products = productService.findList(productCategory, beginDate, endDate, first, count); for (Product product : products) { buildCount += staticService.build(product); } first += products.size(); if (products.size() == count) { isCompleted = false; } } else if (buildType == BuildType.other) { buildCount = staticService.buildOther(); } long endTime = System.currentTimeMillis(); Map<String, Object> map = new HashMap<String, Object>(); map.put("first", first); map.put("buildCount", buildCount); map.put("buildTime", endTime - startTime); map.put("isCompleted", isCompleted); return map; }
From source file:DateUtils.java
/** * Get ISO 8601 timestamp./*ww w. ja va2s . com*/ */ public final static String getISO8601Date(long millis) { StringBuffer sb = new StringBuffer(19); Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(millis); // year sb.append(cal.get(Calendar.YEAR)); // month sb.append('-'); int month = cal.get(Calendar.MONTH) + 1; if (month < 10) { sb.append('0'); } sb.append(month); // date sb.append('-'); int date = cal.get(Calendar.DATE); if (date < 10) { sb.append('0'); } sb.append(date); // hour sb.append('T'); int hour = cal.get(Calendar.HOUR_OF_DAY); if (hour < 10) { sb.append('0'); } sb.append(hour); // minute sb.append(':'); int min = cal.get(Calendar.MINUTE); if (min < 10) { sb.append('0'); } sb.append(min); // second sb.append(':'); int sec = cal.get(Calendar.SECOND); if (sec < 10) { sb.append('0'); } sb.append(sec); return sb.toString(); }
From source file:com.projity.util.DateTime.java
public static void setCalendar(int year, int month, int day, Calendar cal) { cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from www . j a v a 2 s. c om*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); }
From source file:net.netheos.pcsapi.providers.hubic.SwiftTest.java
@Test public void testParseLastModified() { // Check we won't break if a header is missing : JSONObject json = new JSONObject(); Date timestamp = Swift.parseLastModified(json); assertNull(timestamp);/*from w ww . j a v a2 s. com*/ json.put("last_modified", "2014-02-12T16:13:49.346540"); // this is UTC timestamp = Swift.parseLastModified(json); assertNotNull(timestamp); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.setTime(timestamp); assertEquals(2014, cal.get(Calendar.YEAR)); assertEquals(Calendar.FEBRUARY, cal.get(Calendar.MONTH)); assertEquals(12, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(16, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(13, cal.get(Calendar.MINUTE)); assertEquals(49, cal.get(Calendar.SECOND)); assertEquals(346, cal.get(Calendar.MILLISECOND)); checkLastModified("2014-02-12T16:13:49.346540", cal.getTime()); checkLastModified("2014-02-12T16:13:49.3460", cal.getTime()); checkLastModified("2014-02-12T16:13:49.346", cal.getTime()); cal.set(Calendar.MILLISECOND, 340); checkLastModified("2014-02-12T16:13:49.34", cal.getTime()); cal.set(Calendar.MILLISECOND, 300); checkLastModified("2014-02-12T16:13:49.3", cal.getTime()); cal.set(Calendar.MILLISECOND, 0); checkLastModified("2014-02-12T16:13:49.", cal.getTime()); checkLastModified("2014-02-12T16:13:49", cal.getTime()); }