List of usage examples for org.joda.time DateTime getMonthOfYear
public int getMonthOfYear()
From source file:li.klass.fhem.adapter.devices.core.generic.detail.actions.devices.fht.HolidayShort.java
License:Open Source License
DateTime holiday1SwitchTimeFor(int hourOfDay, int minute) { int newMinute = (int) ((Math.round(minute / 10.0) * 10) % 60); if (newMinute == 0) { hourOfDay += minute > 30 ? 1 : 0; }/*from w w w .j a v a 2 s .co m*/ hourOfDay %= 24; DateTime now = dateService.now(); DateTime switchTime = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), hourOfDay, newMinute); if (holidayShortIsTomorrow(switchTime, now)) { switchTime = switchTime.plusDays(1); } return switchTime; }
From source file:lucee.commons.date.JodaDateTimeUtil.java
License:Open Source License
@Override public int getDaysInMonth(TimeZone tz, lucee.runtime.type.dt.DateTime date) { DateTime dt = new DateTime(date.getTime(), getDateTimeZone(tz)); return daysInMonth(dt.getYear(), dt.getMonthOfYear()); }
From source file:lucee.commons.date.JodaDateTimeUtil.java
License:Open Source License
@Override public String toString(lucee.runtime.type.dt.DateTime date, TimeZone tz) { //return jreUtil.toString(date, tz); /*DateTime dt = new DateTime(date.getTime(),getDateTimeZone(tz)); return "{ts '"+dt.getYear()+/*from ww w .j av a 2 s . c o m*/ "-"+dt.getMonthOfYear()+ "-"+dt.getDayOfMonth()+ " "+dt.getHourOfDay()+ ":"+dt.getMinuteOfHour()+ ":"+dt.getSecondOfMinute()+"'}";*/ StringBuilder sb = new StringBuilder(); DateTime dt = new DateTime(date.getTime(), getDateTimeZone(tz)); sb.append("{ts '"); jreUtil.toString(sb, dt.getYear(), 4); sb.append("-"); jreUtil.toString(sb, dt.getMonthOfYear(), 2); sb.append("-"); jreUtil.toString(sb, dt.getDayOfMonth(), 2); sb.append(" "); jreUtil.toString(sb, dt.getHourOfDay(), 2); sb.append(":"); jreUtil.toString(sb, dt.getMinuteOfHour(), 2); sb.append(":"); jreUtil.toString(sb, dt.getSecondOfMinute(), 2); sb.append("'}"); return sb.toString(); }
From source file:manageBeans.AddAuctionMB.java
/** * Creates an auction with a product/*from ww w . ja v a2 s . co m*/ * @param product * product to add to an auction * @return auction * the new created auction */ private Auction createAuction(Product product) { DateTime currentTime = new DateTime(); DateTime temp = new DateTime(endDate); DateTime end = new DateTime(temp.getYear(), temp.getMonthOfYear(), temp.getDayOfMonth(), endTime.getHours(), endTime.getMinutes()); // Calculate duration from start to end date Duration duration = new Duration(currentTime, end); long durationSeconds = duration.getStandardSeconds(); Auction auction = new Auction(); auction.setDuration(durationSeconds); auction.setInitPrice(price); // All auctions are published. TODO remove field from db auction.setPublished(true); Calendar calendar = Calendar.getInstance(); auction.setStartTime(calendar); auction.setProduct(product); auction.setUser(userFacade.getAuctionUser()); return auction; }
From source file:mobi.daytoday.DayToDay.DatePickerDialogFragment.java
License:Apache License
/** * Create and return the date picker dialog *//*from w w w. j a va 2 s .c o m*/ public Dialog onCreateDialog(Bundle arg) { String current = getArguments().getString("curDate"); DateTime dt; if ("".equals(current)) { dt = new DateTime(); Log.v(TAG, "year: " + dt.getYear() + " month: " + dt.getMonthOfYear() + " day: " + dt.getDayOfMonth()); } else { try { dt = DateWrap.parseDate(current); } catch (Exception e) { // just ignore it and use now dt = new DateTime(); } } return new DatePickerDialog(getActivity(), (OnDateSetListener) frag, dt.getYear(), dt.getMonthOfYear() - 1, dt.getDayOfMonth()); }
From source file:model.SqlInterface.java
/** * Used to generate the current tally of time spent today and this week. * /*from w w w . j a v a 2s . co m*/ * @param daySubTotal The current subtotal for today and this week. * * @return Time object containing the total time for today and this week. */ public DateTime getDayTimeTotal(DateTime daySubTotal) { String day = ""; String week = ""; DateTime date = new DateTime(); String dateString = "" + date.getYear() + date.getMonthOfYear() + date.getDayOfMonth(); ResultSet rs; try { rs = statementHandler.executeQuery("select * from timelord where date = '" + dateString + "';"); while (rs.next()) { day = rs.getString("dayTally"); week = rs.getString("weekTally"); System.out.println("SQL: " + day + " " + week); System.out.println("dayTally = " + rs.getString("dayTally")); System.out.println("weekTally = " + rs.getString("weekTally")); System.out.println("-----------------------------------------"); } rs.close(); } catch (SQLException e) { e.printStackTrace(); } DateTime time = new DateTime(0, 1, 1, 0, 0, 0, 0); try { time.plusHours(1); } catch (Exception e) { e.printStackTrace(); } return time; }
From source file:models.MailTransaction.java
License:Apache License
/** * @return the Timestamp as String in the Format "dd.MM.yyyy hh:mm" *///from w w w.j a va2 s. c o m public String getTsAsString() { DateTime dt = new DateTime(this.ts); String day = ""; String mon = ""; String hou = ""; String min = ""; // add a leading "0" if the value is under ten if (dt.getDayOfMonth() < 10) { day += "0"; } day += String.valueOf(dt.getDayOfMonth()); if (dt.getMonthOfYear() < 10) { mon += "0"; } mon += String.valueOf(dt.getMonthOfYear()); if (dt.getHourOfDay() < 10) { hou += "0"; } hou += String.valueOf(dt.getHourOfDay()); if (dt.getMinuteOfHour() < 10) { min += "0"; } min += String.valueOf(dt.getMinuteOfHour()); return day + "." + mon + "." + dt.getYear() + " " + hou + ":" + min; }
From source file:models.MBox.java
License:Apache License
/** * @return the timestamp as string in the format "yyyy-MM-dd hh:mm" <br/> * if its 0, then also 0 is returned *//*from w ww . j av a2s. c o m*/ @JsonIgnore public String getTSAsStringWithNull() { if (this.ts_Active == 0) { return "0"; } else if (this.ts_Active == -1) { return "-1"; } else { DateTime dt = new DateTime(this.ts_Active); StringBuilder timeString = new StringBuilder(); // add a leading "0" if the value is under ten timeString.append(dt.getYear()).append("-"); timeString.append(HelperUtils.addZero(dt.getMonthOfYear())); timeString.append("-"); timeString.append(HelperUtils.addZero(dt.getDayOfMonth())); timeString.append(" "); timeString.append(HelperUtils.addZero(dt.getHourOfDay())); timeString.append(":"); timeString.append(HelperUtils.addZero(dt.getMinuteOfHour())); return timeString.toString(); } }
From source file:module.mission.domain.Mission.java
License:Open Source License
private boolean isHoliday(final DateTime dateTime) { // TODO Possibly refactor this and place data in the repository... // also this does not yet account for mobile holidays and local // holidays depending on the persons working place. final int year = dateTime.getYear(); final int monthOfYear = dateTime.getMonthOfYear(); final int dayOfMonth = dateTime.getDayOfMonth(); return (monthOfYear == 1 && dayOfMonth == 1) || (monthOfYear == 4 && dayOfMonth == 25) || (monthOfYear == 5 && dayOfMonth == 1) || (monthOfYear == 6 && dayOfMonth == 10) || (monthOfYear == 8 && dayOfMonth == 15) || (monthOfYear == 10 && dayOfMonth == 5) || (monthOfYear == 11 && dayOfMonth == 1) || (monthOfYear == 12 && dayOfMonth == 1) || (monthOfYear == 12 && dayOfMonth == 8) || (monthOfYear == 12 && dayOfMonth == 25) || (year == 2011 && monthOfYear == 4 && dayOfMonth == 22) || (year == 2011 && monthOfYear == 6 && dayOfMonth == 13) || (year == 2011 && monthOfYear == 6 && dayOfMonth == 23); }
From source file:module.signed_workflow.domain.data.ActivitySignatureDataBean.java
License:Open Source License
/** * /* w w w . ja va2 s. c o m*/ * @return the SignatureId, this id should be unique and will identify the * signed document */ @Override public String generateSignatureId() { DateTime currentDateTime = new DateTime(); String signatureId = getWorkflowProcess().getProcessNumber() + "-" + activity.getSimpleName() + "-" + currentDateTime.getYear() + "-" + currentDateTime.getMonthOfYear() + "-" + currentDateTime.getDayOfMonth() + "_" + currentDateTime.getMillis() + "_" + randomNrForSigIdGeneration.nextInt(100000); signatureId = StringUtils.replaceChars(signatureId, ' ', '_'); return signatureId; }