assertFunction("extract(year_of_week FROM " + TIMESTAMP_LITERAL + ")", BIGINT, 2001L); assertFunction("extract(doy FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getDayOfYear()); assertFunction("extract(week FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getWeekOfWeekyear()); assertFunction("extract(month FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getMonthOfYear()); assertFunction("extract(quarter FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getMonthOfYear() / 4 + 1); assertFunction("extract(day_of_year FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getDayOfYear()); assertFunction("extract(doy FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getDayOfYear()); assertFunction("extract(week FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getWeekOfWeekyear()); assertFunction("extract(month FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getMonthOfYear()); assertFunction("extract(quarter FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getMonthOfYear() / 4 + 1);
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression expression = getChildExpression(); if (!expression.evaluate(tuple, ptr)) { return false; } if ( ptr.getLength() == 0) { return true; //means null } long dateTime = inputCodec.decodeLong(ptr, expression.getSortOrder()); DateTime dt = new DateTime(dateTime); int week = dt.getWeekOfWeekyear(); PDataType returnType = getDataType(); byte[] byteValue = new byte[returnType.getByteSize()]; returnType.getCodec().encodeInt(week, byteValue, 0); ptr.set(byteValue); return true; }
/** * {@inheritDoc} */ public int getWeekOfWeekyear() { return this.instance.getWeekOfWeekyear(); }
public boolean sameWeekAs(final DateTime dateTime2) { return dateTime2 == null ? false : dateTime.getWeekOfWeekyear() == dateTime2.dateTime.getWeekOfWeekyear(); }
public Integer getWeekOfIntervalStart() { return startDate.getWeekOfWeekyear(); }
DateTime now = DateTime.now( DateTimeZone.forID( "America/Montreal" ) ); String output = ISODateTimeFormat.weekyearWeek().print( now ); int weekNumber = now.getWeekOfWeekyear();
/** * Get week number for date but compensate with configured first day of week. * Week officially starts on monday but when it's configured to start on sunday we have to compensate * because the day falls in the previous week. */ public static int getWeekNumberForDate(Date date, int configuredFirstDayOfWeek) { DateTime dateTime = new DateTime(date); return configuredFirstDayOfWeek == Calendar.SUNDAY ? dateTime.plusDays(1).getWeekOfWeekyear() : dateTime.getWeekOfWeekyear(); }
public boolean isInWeek(DateTime date) { return date.getWeekOfWeekyear() == week && date.getYear() == year; } }
@Override public int hashCode() { return Objects.hashCode( week.getYear(), week.getWeekOfWeekyear() ); }
public static Date parseYearWeek(String yearWeek) { DateTime dateTime = DateTimeFormat.forPattern("yy/ww").parseDateTime(yearWeek); if (dateTime.getWeekOfWeekyear() == 1 && dateTime.getMonthOfYear() == 12) { dateTime = DateTimeFormat.forPattern("yyyy/mm").parseDateTime((dateTime.getYear() + 1) + "/01"); } return dateTime.toDate(); }
public HabitRecord(long habitId, long habitReminderId, long recordTime) { this.id = 0; this.habitId = habitId; this.habitReminderId = habitReminderId; this.recordTime = recordTime; DateTime dt = new DateTime(recordTime); this.recordYear = dt.getYear(); this.recordMonth = dt.getMonthOfYear(); this.recordWeek = dt.getWeekOfWeekyear(); this.recordDay = dt.getDayOfMonth(); this.type = TYPE_FINISHED; }
public HabitRecord(long habitId, long habitReminderId) { this.id = 0; this.habitId = habitId; this.habitReminderId = habitReminderId; this.recordTime = System.currentTimeMillis(); DateTime dt = new DateTime(recordTime); this.recordYear = dt.getYear(); this.recordMonth = dt.getMonthOfYear(); this.recordWeek = dt.getWeekOfWeekyear(); this.recordDay = dt.getDayOfMonth(); this.type = TYPE_FINISHED; }
@Override public int isoWeek( DateTimeUnit dateTimeUnit ) { DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology ); return dateTime.getWeekOfWeekyear(); }
/** * Returns the current week of the year (1-52). */ public static String getWeekForHighlights() { DateTime dateTime = new DateTime(DateTimeZone.forTimeZone( TimeZone.getTimeZone("America/New_York"))); return String.valueOf(dateTime.getWeekOfWeekyear()); } }
public static boolean isTheSameWeek(DateTime dateTime1, DateTime dateTime2) { DateTime firstDateMovedByFirstDayOfWeek = dateTime1.minusDays(firstDayOffset()); DateTime secondDateMovedByFirstDayOfWeek = dateTime2.minusDays(firstDayOffset()); return (firstDateMovedByFirstDayOfWeek.getYear() == secondDateMovedByFirstDayOfWeek.getYear()) && (firstDateMovedByFirstDayOfWeek.getWeekOfWeekyear() == secondDateMovedByFirstDayOfWeek.getWeekOfWeekyear()); }
@JRubyMethod public RubyInteger cweek(ThreadContext context) { return RubyFixnum.newFixnum(context.runtime, dt.getWeekOfWeekyear()); }
@JRubyMethod public RubyInteger cweek(ThreadContext context) { return RubyFixnum.newFixnum(context.runtime, dt.getWeekOfWeekyear()); }
@Override public Integer exec(Tuple input) throws IOException { if (input == null || input.size() < 1 || input.get(0) == null) { return null; } return ((DateTime) input.get(0)).getWeekOfWeekyear(); }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String monthly = tuple.getString(1).substring(0, 6); Integer week = dtf.parseDateTime(tuple.getString(1)).getWeekOfWeekyear(); String weekly = tuple.getString(1).substring(0, 4) .concat(week.toString()); collector.emit(new Values(cfStatsDaily, tuple.getString(1))); collector.emit(new Values(cfStatsMonthly, monthly)); collector.emit(new Values(cfStatsWeekly, weekly)); } }
@Override public int isoWeek( DateTimeUnit dateTimeUnit ) { DateTime dateTime = toIso( dateTimeUnit ) .toJodaDateTime( ISOChronology.getInstance( DateTimeZone.getDefault() ) ); return dateTime.getWeekOfWeekyear(); }