List of usage examples for org.joda.time DateTime getYear
public int getYear()
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** * ??? ?? ?? // w w w. ja va 2 s. c o m * * @param moment the moment * @param monthOfYear the month of year * @return the date time */ public static DateTime trimToMonth(DateTime moment, int monthOfYear) { return asDate(moment.getYear(), monthOfYear, 1); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** * ?? //?? ?? .//from ww w. j a v a 2 s . com * * @param moment the moment * @param dayOfMonth the day of month * @return the date time */ public static DateTime trimToDay(DateTime moment, int dayOfMonth) { return asDate(moment.getYear(), moment.getMonthOfYear(), dayOfMonth); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ? ? ? . */ public static List<ITimePeriod> foreachYears(ITimePeriod period) { assert period != null; if (isTraceEnabled) log.trace("[{}]? Year ...", period); List<ITimePeriod> years = Lists.newArrayList(); if (period.isAnytime()) return years; assertHasPeriod(period);/*from www . jav a2 s .co m*/ if (Times.isSameYear(period.getStart(), period.getEnd())) { years.add(new TimeRange(period)); return years; } years.add(new TimeRange(period.getStart(), Times.endTimeOfYear(period.getStart()))); DateTime current = Times.startTimeOfYear(period.getStart()).plusYears(1); int endYear = period.getEnd().getYear(); ITimeCalendar calendar = TimeCalendar.getDefault(); while (current.getYear() < endYear) { years.add(Times.getYearRange(current, calendar)); current = current.plusYears(1); } if (current.compareTo(period.getEnd()) < 0) { years.add(new TimeRange(Times.startTimeOfYear(current), period.getEnd())); } return years; }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ? ? . */ public static List<ITimePeriod> foreachHalfyears(ITimePeriod period) { assert period != null; if (isTraceEnabled) log.trace("[{}]? Halfyear ...", period); List<ITimePeriod> halfyears = Lists.newArrayList(); if (period.isAnytime()) return halfyears; assertHasPeriod(period);// w w w. j ava2 s . com if (Times.isSameHalfyear(period.getStart(), period.getEnd())) { halfyears.add(new TimeRange(period)); return halfyears; } DateTime current = Times.endTimeOfHalfyear(period.getStart()); halfyears.add(new TimeRange(period.getStart(), current)); int endHashCode = period.getEnd().getYear() * 10 + Times.halfyearOf(period.getEnd()).getValue(); current = current.plusDays(1); ITimeCalendar calendar = TimeCalendar.getDefault(); while (current.getYear() * 10 + Times.halfyearOf(current).getValue() < endHashCode) { halfyears.add(Times.getHalfyearRange(current, calendar)); current = current.plusMonths(TimeSpec.MonthsPerHalfyear); } if (current.compareTo(period.getEnd()) < 0) { halfyears.add(new TimeRange(Times.startTimeOfHalfyear(current), period.getEnd())); } return halfyears; }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ? ? . */ public static List<ITimePeriod> foreachQuarters(ITimePeriod period) { assert period != null; if (isTraceEnabled) log.trace("[{}]? Quarter ...", period); List<ITimePeriod> quarters = Lists.newArrayList(); if (period.isAnytime()) return quarters; assertHasPeriod(period);//from w w w .ja va 2s. c o m if (Times.isSameQuarter(period.getStart(), period.getEnd())) { quarters.add(new TimeRange(period)); return quarters; } DateTime current = Times.endTimeOfQuarter(period.getStart()); quarters.add(new TimeRange(period.getStart(), current)); int endHashCode = period.getEnd().getYear() * 10 + Times.quarterOf(period.getEnd()).getValue(); current = current.plusDays(1); ITimeCalendar calendar = TimeCalendar.getDefault(); while (current.getYear() * 10 + Times.quarterOf(current).getValue() < endHashCode) { quarters.add(Times.getQuarterRange(current, calendar)); current = current.plusMonths(TimeSpec.MonthsPerQuarter); } if (current.compareTo(period.getEnd()) < 0) quarters.add(new TimeRange(Times.startTimeOfQuarter(current), period.getEnd())); return quarters; }
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; }/*w w w . j a v a 2 s . c o 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 w ww.j av a2s. co 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 w ww . j a v a 2 s . c om*/ * @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:mekhq.campaign.universe.Faction.java
License:Open Source License
public boolean validIn(DateTime time) { return validIn(time.getYear()); }