List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:influent.server.utilities.ConstrainedDateRange.java
License:MIT License
/** * Constructs a date range that is constrained to begin and end on instances of the specified * interval, and that is guaranteed to include the range specified. * /*from www . j a va 2 s . c o m*/ * @param start * @param interval * @param numBins */ public ConstrainedDateRange(DateTime start, FL_DateInterval interval, long numBins) { super(start.getMillis(), interval, numBins); DateTime constrained = start; // constrain to start of interval. switch (interval) { case SECONDS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), start.getHourOfDay(), start.getMinuteOfHour(), start.getSecondOfMinute(), DateTimeZone.UTC); break; case HOURS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), start.getHourOfDay(), 0, DateTimeZone.UTC); break; case DAYS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), 0, 0, DateTimeZone.UTC); break; case WEEKS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), 0, 0, DateTimeZone.UTC); final int days = start.getDayOfWeek() % 7; final long rewindMillis = days * DateTimeConstants.MILLIS_PER_DAY; constrained = new DateTime(constrained.getMillis() - rewindMillis, constrained.getZone()); break; case MONTHS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), 1, 0, 0, DateTimeZone.UTC); break; case QUARTERS: constrained = new DateTime(start.getYear(), 1 + 3 * ((start.getMonthOfYear() - 1) / 3), 1, 0, 0, DateTimeZone.UTC); break; case YEARS: constrained = new DateTime(start.getYear(), start.getMonthOfYear(), 1, 0, 0, DateTimeZone.UTC); break; } // add an extra partial interval at the end when not large enough. if (!start.equals(constrained)) { //System.out.println(start + " -> " + constrained); setStartDate(constrained.getMillis()); setNumBins(numBins + 1); } }
From source file:io.coala.xml.XmlUtil.java
License:Apache License
/** * @param date/* www . j a v a 2 s .c o m*/ * @return a JAXP {@link XMLGregorianCalendar} */ public static XMLGregorianCalendar toDateTime(final DateTime date) { final XMLGregorianCalendar result = getDatatypeFactory().newXMLGregorianCalendar(); result.setYear(date.getYear()); result.setMonth(date.getMonthOfYear()); result.setDay(date.getDayOfMonth()); result.setTime(date.getHourOfDay(), date.getMinuteOfHour(), date.getSecondOfMinute(), date.getMillisOfSecond()); result.setTimezone(date.getZone().toTimeZone().getRawOffset() / 1000 / 60); // result.setTimezone(DatatypeConstants.FIELD_UNDEFINED); return result; }
From source file:io.github.blindio.prospero.core.utils.JodaDateTimeWrapper.java
License:Apache License
public JodaDateTimeWrapper withTimeString(String timeString) { DateTime newTime = DateTime.parse(timeString, formatTime); return this.withTime(newTime.getHourOfDay(), newTime.getMinuteOfHour()); }
From source file:io.spikex.core.util.CronEntry.java
License:Apache License
public boolean isDefined(final DateTime tm) { boolean defined = false; int month = tm.getMonthOfYear(); int day = tm.getDayOfMonth(); int dow = tm.getDayOfWeek(); int hour = tm.getHourOfDay(); int minute = tm.getMinuteOfHour(); boolean dayDowMatch = true; if (!isEveryDay()) { dayDowMatch = isDayDefined(day); }/*from ww w . j av a2 s.c om*/ if (!isEveryDow()) { dayDowMatch = isDowDefined(dow); } if (!isEveryDay() && !isEveryDow()) { dayDowMatch = (isDayDefined(day) || isDowDefined(dow)); } if (isMonthDefined(month) && dayDowMatch && isHourDefined(hour) && isMinuteDefined(minute)) { defined = true; } // System.out.println("Defined " + defined + " - month: " + month + " day: " + day + " dow: " + dow // +" hour: " + hour + " minute: " + minute + " dayOrDowMatch: " + dayDowMatch); // System.out.println("dayDowMatch: " + dayDowMatch + " isMonthDefined: " + isMonthDefined(month) // + " isHourDefined: " + isHourDefined(hour) + " isMinuteDefined: " + isMinuteDefined(minute)); return defined; }
From source file:io.warp10.script.functions.TSELEMENTS.java
License:Apache License
@Override public Object apply(WarpScriptStack stack) throws WarpScriptException { Object obj = stack.peek();//from w ww . j a va2 s . c o m String tz = null; if (obj instanceof String) { tz = (String) obj; stack.pop(); } else if (!(obj instanceof Long)) { throw new WarpScriptException(getName() + " operates on a timestamp or a timestamp + timezone."); } DateTimeZone dtz = this.tzones.get(tz); if (null == dtz) { dtz = DateTimeZone.forID(null == tz ? "UTC" : tz); this.tzones.put(tz, dtz); } obj = stack.pop(); if (!(obj instanceof Long)) { throw new WarpScriptException(getName() + " operates on a timestamp or a timestamp + timezone."); } long ts = (long) obj; // Convert ts to milliseconds long tsms = ts / Constants.TIME_UNITS_PER_MS; DateTime dt = new DateTime(tsms, dtz); // Extract components into an array List<Long> elements = new ArrayList<Long>(); elements.add((long) dt.getYear()); elements.add((long) dt.getMonthOfYear()); elements.add((long) dt.getDayOfMonth()); elements.add((long) dt.getHourOfDay()); elements.add((long) dt.getMinuteOfHour()); elements.add((long) dt.getSecondOfMinute()); elements.add(ts % Constants.TIME_UNITS_PER_S); elements.add((long) dt.getDayOfYear()); elements.add((long) dt.getDayOfWeek()); elements.add((long) dt.getWeekOfWeekyear()); stack.push(elements); return stack; }
From source file:io.warp10.script.mapper.MapperMinuteOfHour.java
License:Apache License
@Override public Object apply(Object[] args) throws WarpScriptException { long tick = (long) args[0]; long[] locations = (long[]) args[4]; long[] elevations = (long[]) args[5]; long location = locations[0]; long elevation = elevations[0]; DateTime dt = new DateTime(tick / Constants.TIME_UNITS_PER_MS, this.dtz); return new Object[] { tick, location, elevation, dt.getMinuteOfHour() }; }
From source file:it.fabaris.wfp.widget.DateTimeWidget.java
License:Open Source License
/** * set the answer to the answer Widget//from w w w. j a v a 2s. c o m * getting in it from the FormEntryPrompt * otherwise create time widget with * the current time */ private void setAnswer() { if (mPrompt.getAnswerValue() != null) { DateTime ldt = new DateTime(((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime()); //mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); //LA DATA DI SINCRONIZZAZIONE ERA SETTATA CON UN MESE INDIETRO mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear(), ldt.getDayOfMonth(), mDateListener); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); } else { // create time widget with current time as of right now clearAnswer(); } }
From source file:it.fabaris.wfp.widget.TimeWidget.java
License:Open Source License
public TimeWidget(Context context, final FormEntryPrompt prompt) { super(context, prompt); mTimePicker = new TimePicker(getContext()); mTimePicker.setFocusable(!prompt.isReadOnly()); mTimePicker.setEnabled(!prompt.isReadOnly()); String clockType = android.provider.Settings.System.getString(context.getContentResolver(), android.provider.Settings.System.TIME_12_24); if (clockType == null || clockType.equalsIgnoreCase("24")) { mTimePicker.setIs24HourView(true); }//from w ww . j a va2 s. c o m // If there's an answer, use it. if (prompt.getAnswerValue() != null) { // create a new date time from date object using default time zone DateTime ldt = new DateTime(((Date) ((TimeData) prompt.getAnswerValue()).getValue()).getTime()); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); } else { // create time widget with current time as of right now clearAnswer(); } setGravity(Gravity.LEFT); addView(mTimePicker); }
From source file:jforex.liverun.Explorer30MinLive.java
License:Open Source License
public static void main(String[] args) throws Exception { // get the instance of the IClient interface final IClient client = ClientFactory.getDefaultInstance(); final ClimberProperties properties = new ClimberProperties(); // set the listener that will receive system events client.setSystemListener(new ISystemListener() { @Override//from w w w .ja v a 2 s .co m public void onStart(long processId) { LOGGER.info("Strategy started: " + processId); try { strategyRunningSignal.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onStop(long processId) { LOGGER.info("Strategy stopped: " + processId); if (client.getStartedStrategies().size() == 0) { // System.exit(0); strategyRunningSignal.delete(); } } @Override public void onConnect() { LOGGER.info("Connected"); } @Override public void onDisconnect() { LOGGER.info("Disconnected at " + FXUtils.getFormatedTimeCET(System.currentTimeMillis()) + " CET"); } }); if (args.length < 1) { LOGGER.error("One argument needed: name of config file"); System.exit(1); } try { properties.load(new FileInputStream(args[0])); } catch (IOException e) { LOGGER.error("Can't open or can't read properties file " + args[0] + "..."); System.exit(1); } properties.validate(LOGGER); FXUtils.setDbToUse(properties.getProperty("dbToUse")); LOGGER.info("Connecting..."); // connect to the server using jnlp, user name and password // connection is needed for data downloading int attempt = 0; while (attempt++ < 15 && !client.isConnected()) { client.connect( properties.getProperty("environment_url", "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp"), properties.getProperty("username"), properties.getProperty("password")); // wait for it to connect int i = 30; // wait max thirty seconds while (i > 0 && !client.isConnected()) { Thread.sleep(1000); i--; } // not successful, try again in 30 sec if (!client.isConnected()) { LOGGER.info("Connection attempt " + attempt + " not successful, wil re-try in 30 secs..."); Thread.sleep(30 * 1000); } } if (!client.isConnected()) { LOGGER.error("Failed to connect Dukascopy servers after " + attempt + " attempts, exiting"); System.exit(1); } // set instruments that will be used in testing. To set different // timeframe per pair format is <pair>,<timeframe>;<pair>,<timeframe>... // StringTokenizer st = new // StringTokenizer(properties.getProperty("pairsToCheck"), ";"); // Set<Instrument> instruments = new HashSet<Instrument>(); // while(st.hasMoreTokens()) { // String nextPair = st.nextToken(); // StringTokenizer st2 = new StringTokenizer(nextPair, ","); // instruments.add(Instrument.fromString(st2.nextToken())); // } // get all instruments having a subscription Set<Instrument> instruments = new HashSet<Instrument>(); ResultSet dbInstruments = FXUtils.dbGetAllSubscribedInstruments(properties); while (dbInstruments.next()) { instruments.add(Instrument.fromString(dbInstruments.getString("ticker"))); } LOGGER.info("Subscribing instruments..."); client.setSubscribedInstruments(instruments); // setting initial deposit client.setCacheDirectory(new File(properties.getProperty("cachedir"))); attempt = 0; requestedCallSignal = new File("requestedCall.bin"); requestedCallSignal.createNewFile(); DateTime current = new DateTime(); long strategyID = client.startStrategy(new PaceStatsCollector(properties)); while (!requestedBarDone() && ((current.getMinuteOfHour() >= 56 || current.getMinuteOfHour() <= 4) || (current.getMinuteOfHour() >= 6 && current.getMinuteOfHour() <= 14) || (current.getMinuteOfHour() >= 16 && current.getMinuteOfHour() <= 24) || (current.getMinuteOfHour() >= 26 && current.getMinuteOfHour() <= 34) || (current.getMinuteOfHour() >= 36 && current.getMinuteOfHour() <= 44) || (current.getMinuteOfHour() >= 46 && current.getMinuteOfHour() <= 54))) { Thread.sleep(30000); current = new DateTime(); attempt++; } client.stopStrategy(strategyID); if (requestedCallSignal.exists()) { requestedCallSignal.delete(); LOGGER.info("Unsuccessful run after " + attempt + " attempts"); } else LOGGER.info("Successful run after " + attempt + " attempts"); if (strategyRunningSignal.exists()) strategyRunningSignal.delete(); System.exit(0); }
From source file:jtodo.ui.TaskEditorWindow.java
License:Open Source License
private void fillInValues() { logger.log(Level.INFO, "Automatically filling in the values for the task"); fieldName.setText(task.getName());//from ww w . j a v a 2 s . c o m fieldDescription.setText(task.getDescription()); comboBoxPriority.setSelectedItem(task.getPriority()); if (task.isDeadlineActive()) { DateTime dateTime = task.getDeadline().getDateTime(); comboBoxDay.setSelectedIndex(dateTime.getDayOfMonth() - 1); comboBoxMonth.setSelectedIndex(dateTime.getMonthOfYear() - 1); fieldYear.setText("" + dateTime.getYear()); comboBoxTime.setSelectedItem(dateTime.getHourOfDay() + ":" + dateTime.getMinuteOfHour()); checkBoxDeadlineActive.setSelected(true); } else { checkBoxDeadlineActive.setSelected(false); setDateSelectionEnabledIfCheckBoxActive(); } }