List of usage examples for java.util Calendar MILLISECOND
int MILLISECOND
To view the source code for java.util Calendar MILLISECOND.
Click Source Link
get
and set
indicating the millisecond within the second. From source file:com.googlecode.jsfFlex.shared.util.JSONConverter.java
public static JSONArray convertJavaDateToASDateConstructorArguments(Calendar toConvert) { JSONArray dateConstructorArguments = new JSONArray(); dateConstructorArguments.put(toConvert.get(Calendar.YEAR)); dateConstructorArguments.put(toConvert.get(Calendar.MONTH)); dateConstructorArguments.put(toConvert.get(Calendar.DATE)); dateConstructorArguments.put(toConvert.get(Calendar.HOUR_OF_DAY)); dateConstructorArguments.put(toConvert.get(Calendar.MINUTE)); dateConstructorArguments.put(toConvert.get(Calendar.SECOND)); dateConstructorArguments.put(toConvert.get(Calendar.MILLISECOND)); return dateConstructorArguments; }
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); }// ww w . j av a2 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;//from ww w . j a v a 2 s.c o m deleted = false; }
From source file:com.chevres.rss.worker.feedupdater.RssHandler.java
@Override public void endElement(String uri, String localName, String qName) { if (this.currentArticle != null && this.articles != null) { try {//from ww w . java 2s .c o m if (qName.equals("content:encoded")) qName = "content"; switch (qName.toLowerCase()) { case "title": String title = this.stringBuilder.toString(); title = title.substring(0, Math.min(title.length(), 500)); this.currentArticle.setTitle(title); break; case "pubdate": String pubDate = this.stringBuilder.toString(); DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");//TODO a ameliorer Date date = formatter.parse(pubDate); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.MILLISECOND, 0); this.currentArticle.setPubDate(new java.sql.Timestamp(date.getTime())); break; case "link": String link = this.stringBuilder.toString(); this.currentArticle.setLink(link); break; case "description": String description = this.stringBuilder.toString(); this.currentArticle.setPreviewContent(description); break; case "content": String content = this.stringBuilder.toString(); this.currentArticle.setFullContent(content); break; } } catch (Exception e) { System.out.println(e.getMessage()); } } }
From source file:net.sourceforge.eclipsetrader.opentick.HistoryFeed.java
public void updateHistory(Security security, int interval) { try {/*w w w.j a va2 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:com.antsdb.saltedfish.sql.vdm.FuncDateFormat.java
private String format(String format, Timestamp time) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < format.length(); i++) { char ch = format.charAt(i); if (ch != '%') { buf.append(ch);// w w w. ja v a 2s .c o m continue; } if (i >= (format.length() - 1)) { buf.append(ch); continue; } char specifier = format.charAt(++i); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time.getTime()); if (specifier == 'a') { throw new NotImplementedException(); } else if (specifier == 'b') { throw new NotImplementedException(); } else if (specifier == 'c') { buf.append(calendar.get(Calendar.MONTH + 1)); } else if (specifier == 'd') { int day = calendar.get(Calendar.DAY_OF_MONTH); if (day < 10) { buf.append('0'); } buf.append(day); } else if (specifier == 'D') { throw new NotImplementedException(); } else if (specifier == 'e') { buf.append(calendar.get(Calendar.DAY_OF_MONTH)); } else if (specifier == 'f') { buf.append(calendar.get(Calendar.MILLISECOND * 1000)); } else if (specifier == 'H') { buf.append(calendar.get(Calendar.HOUR)); } else if (specifier == 'h') { buf.append(calendar.get(Calendar.HOUR) % 13); } else if (specifier == 'i') { buf.append(calendar.get(Calendar.MINUTE)); } else if (specifier == 'I') { buf.append(calendar.get(Calendar.HOUR) % 13); } else if (specifier == 'j') { buf.append(calendar.get(Calendar.DAY_OF_YEAR)); } else if (specifier == 'k') { buf.append(calendar.get(Calendar.HOUR)); } else if (specifier == 'l') { buf.append(calendar.get(Calendar.HOUR) % 13); } else if (specifier == 'm') { int month = calendar.get(Calendar.MONTH) + 1; if (month < 10) { buf.append('0'); } buf.append(calendar.get(Calendar.MONTH) + 1); } else if (specifier == 'M') { buf.append(calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())); } else if (specifier == 'p') { int hour = calendar.get(Calendar.HOUR); buf.append(hour < 12 ? "AM" : "PM"); } else if (specifier == 'r') { int hour = calendar.get(Calendar.HOUR); hour = hour % 13; if (hour < 10) { buf.append('0'); } buf.append(hour); buf.append(':'); int minute = calendar.get(Calendar.MINUTE); if (minute < 10) { buf.append('0'); } buf.append(minute); buf.append(':'); int second = calendar.get(Calendar.SECOND); if (second < 10) { buf.append('0'); } buf.append(second); buf.append(hour < 12 ? " AM" : " PM"); } else if (specifier == 's') { buf.append(calendar.get(Calendar.SECOND)); } else if (specifier == 'S') { buf.append(calendar.get(Calendar.SECOND)); } else if (specifier == 'T') { throw new NotImplementedException(); } else if (specifier == 'u') { buf.append(calendar.get(Calendar.WEEK_OF_YEAR)); } else if (specifier == 'U') { throw new NotImplementedException(); } else if (specifier == 'v') { throw new NotImplementedException(); } else if (specifier == 'V') { throw new NotImplementedException(); } else if (specifier == 'w') { throw new NotImplementedException(); } else if (specifier == 'W') { throw new NotImplementedException(); } else if (specifier == 'x') { throw new NotImplementedException(); } else if (specifier == 'X') { throw new NotImplementedException(); } else if (specifier == 'y') { buf.append(calendar.get(Calendar.YEAR) % 100); } else if (specifier == 'Y') { buf.append(calendar.get(Calendar.YEAR)); } else if (specifier == '%') { buf.append('%'); } else { buf.append(specifier); } } return buf.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 w w w. jav a2s. co m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); }
From source file:helper.util.DateHelper.java
/** * Take a local time calendar and represent it as a UTC day * (truncate to day, retain yy/mm/dd from original date) **//*from w w w. j av a 2s.co m*/ public static Calendar asUtcDay(Calendar localTimeCalendar) { Calendar utcDate = Calendar.getInstance(DateUtils.UTC_TIME_ZONE); utcDate.clear(); utcDate.set(localTimeCalendar.get(Calendar.YEAR), localTimeCalendar.get(Calendar.MONTH), localTimeCalendar.get(Calendar.DATE), 0, 0, 0); utcDate.set(Calendar.AM_PM, Calendar.AM); utcDate.set(Calendar.MILLISECOND, 0); utcDate.set(Calendar.HOUR, 0); return utcDate; }
From source file:com.linuxbox.enkive.statistics.gathering.past.PastGatherer.java
protected void setEndDate(int grain) { Calendar end = Calendar.getInstance(); end.set(Calendar.MILLISECOND, 0); end.set(Calendar.SECOND, 0);/*from w ww .j a va 2 s. c o m*/ end.set(Calendar.MINUTE, 0); if (grain == CONSOLIDATION_HOUR) { end.add(Calendar.HOUR_OF_DAY, -hrKeepTime); } else if (grain == CONSOLIDATION_DAY) { end.set(Calendar.HOUR_OF_DAY, 0); end.add(Calendar.DATE, -dayKeepTime); } else if (grain == CONSOLIDATION_WEEK) { end.set(Calendar.HOUR_OF_DAY, 0); while (end.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { end.add(Calendar.DATE, -1); } end.add(Calendar.WEEK_OF_YEAR, -weekKeepTime); } else if (grain == CONSOLIDATION_MONTH) { end.set(Calendar.HOUR_OF_DAY, 0); end.set(Calendar.DAY_OF_MONTH, 1); end.add(Calendar.MONTH, -monthKeepTime); } this.endDate = end.getTime(); }