List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:teamattendance.TeamAttendance.java
public Date[] getDates(String date) { String[] splitDate;/*from w ww . j a va2s .c o m*/ int[] theDate = new int[3]; if (date.compareToIgnoreCase("today") == 0) { DateTime today = new DateTime(); theDate[0] = today.getMonthOfYear(); theDate[1] = today.getDayOfMonth(); theDate[2] = today.getYear(); } else if (date.compareToIgnoreCase("yesterday") == 0) { DateTime today = new DateTime(); theDate[0] = today.getMonthOfYear(); theDate[1] = today.getDayOfMonth() - 1; theDate[2] = today.getYear(); } else { splitDate = date.split("/"); if (splitDate[2].length() == 2) splitDate[2] = "20" + splitDate[2]; theDate[2] = Integer.parseInt(splitDate[2]); theDate[1] = Integer.parseInt(splitDate[0]); theDate[0] = Integer.parseInt(splitDate[1]); } Date[] startEnd = { new Date(theDate[2] - 1900, theDate[0] - 1, theDate[1], 17, 0), new Date(theDate[2] - 1900, theDate[0] - 1, theDate[1], 22, 0) }; return startEnd; }
From source file:TimeDate.Date.java
public Date() { DateTime datr = new DateTime(); ano = datr.getYear();/*from ww w. j a v a 2 s . c om*/ mes = datr.getMonthOfYear(); dia = datr.getDayOfMonth(); diasdoano = datr.getDayOfYear(); semanasdoano = datr.getWeekyear(); locale = new Langs.Locale(); }
From source file:TimeDate.Date.java
public Date(int dias) { DateTime datr = new DateTime(); ano = datr.getYear();//www.j a va 2 s. c om mes = datr.getMonthOfYear(); dia = datr.getDayOfMonth(); Date aux = this.dateAfter(dias); ano = aux.getYear(); mes = aux.getMonth(); dia = aux.getDay(); diasdoano = aux.getDayYear(); semanasdoano = aux.getWeekYear(); locale = new Langs.Locale(); }
From source file:trendulo.ingest.MutationGenerator.java
License:Apache License
public static String timestampToDayString(long timestamp) { DateTime dateTime = new DateTime(timestamp, DateTimeZone.UTC); return String.format("%d%02d%02d", dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); }
From source file:trendulo.ingest.MutationGenerator.java
License:Apache License
public static String timestampToHourString(long timestamp) { DateTime dateTime = new DateTime(timestamp, DateTimeZone.UTC); return String.format("%d%02d%02d%02d", dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay()); }
From source file:TVShowTimelineMaker.testUtil.DateTimeMaker.java
public static DateTime randomDateTimeBetweenTimes(DateTime inAfterDay, DateTime inBeforeDay) { int startYear = inAfterDay.getYear(); int diffYear = inBeforeDay.getYear() - startYear; if ((diffYear + 1) <= 0) { int a = 1 + 2; }/*from ww w .j a v a2 s. c om*/ int newYear = startYear + rnd.nextInt(diffYear + 1); boolean alreadyDiffernt = false; int newMonth; if ((newYear != startYear) && (newYear != inBeforeDay.getYear())) { alreadyDiffernt = true; newMonth = 1 + rnd.nextInt(12); } else { if (diffYear == 0) { int startMonth = inAfterDay.getMonthOfYear(); int diffMonth = inBeforeDay.getMonthOfYear() - startMonth; newMonth = startMonth + rnd.nextInt(diffMonth + 1); } else if (newYear == startYear) { int startMonth = inAfterDay.getMonthOfYear(); int diffMonth = 12 - startMonth; newMonth = startMonth + rnd.nextInt(diffMonth + 1); } else { int startMonth = 1; int diffMonth = inBeforeDay.getMonthOfYear() - startMonth; newMonth = startMonth + rnd.nextInt(diffMonth + 1); } } int newDay; if (alreadyDiffernt || ((!((newMonth == inAfterDay.getMonthOfYear()) && (newYear == startYear))) && (!((newMonth == inBeforeDay.getMonthOfYear()) && (newYear == inBeforeDay.getYear()))))) { alreadyDiffernt = true; newDay = 1 + rnd.nextInt(28); } else { if ((startYear == inBeforeDay.getYear()) && (inAfterDay.getMonthOfYear() == inBeforeDay.getMonthOfYear())) { int startDay = inAfterDay.getDayOfMonth(); int diffDay = inBeforeDay.getDayOfMonth() - startDay; newDay = startDay + rnd.nextInt(diffDay + 1); } else if ((newMonth == inAfterDay.getMonthOfYear()) && (newYear == startYear)) { int startDay = inAfterDay.getDayOfMonth(); int diffDay = Math.max(0, 28 - startDay); newDay = startDay + rnd.nextInt(diffDay + 1); } else { int startDay = 1; int diffDay = inBeforeDay.getDayOfMonth() - startDay; newDay = startDay + rnd.nextInt(diffDay + 1); } } return new DateTime(newYear, newMonth, newDay, 12, 0, 0); }
From source file:TVShowTimelineMaker.timeConstraints.Relation.java
public boolean consistentWithConstraint(DateTime inFirstDay, DateTime inSecondDay) { if ((this.kind == RelationKind.IMMEDIATELY_BEFORE) || (this.kind == RelationKind.BEFORE)) { return inFirstDay.isBefore(inSecondDay.withHourOfDay(1)); } else if (this.kind == RelationKind.FIXED_TIME_BEFORE) { return inFirstDay.plus(this.time).equals(inSecondDay); } else if (this.kind == RelationKind.LESS_THEN_BEFORE) { DateTime tempEarliestPossibleDate = inSecondDay.minus(this.time).withHourOfDay(1); return inFirstDay.isAfter(tempEarliestPossibleDate) && inFirstDay.isBefore(inSecondDay.withHourOfDay(1)); } else if (this.kind == RelationKind.SAME_DAY_OF_YEAR) { return (inFirstDay.getMonthOfYear() == inSecondDay.getMonthOfYear()) && (inFirstDay.getDayOfMonth() == inSecondDay.getDayOfMonth()); } else if ((this.kind == RelationKind.SAME_TIME_AS) || (this.kind == RelationKind.BEFORE_SAME_DAY)) { return this.mSameTimeOfYearConstraint.consistentWithConstraint(inFirstDay, inSecondDay); } else if (this.kind == RelationKind.MORE_THEN_BEFORE) { DateTime earyer = inSecondDay.minus(this.time).withHourOfDay(1); return inFirstDay.isBefore(earyer); } else {// w w w . j av a2 s. c om return true; } }
From source file:TVShowTimelineMaker.timeConstraints.SameTimeOfYearConstraint.java
public boolean consistentWithConstraint(DateTime inFirstDay, DateTime inSecondDay) { return (inFirstDay.getMonthOfYear() == inSecondDay.getMonthOfYear()) && (inFirstDay.getDayOfMonth() == inSecondDay.getDayOfMonth()); }
From source file:TVShowTimelineMaker.timeline.YearlyDayEvent.java
public boolean addSuggestedDay(DateTime inDate) { return this.SuggestedDays.add(new DayOfYear(inDate.getMonthOfYear(), inDate.getDayOfMonth())); }
From source file:TVShowTimelineMaker.util.DayOfYear.java
public static DayOfYear fromDateTime(DateTime inDateTime) { return new DayOfYear(inDateTime.getMonthOfYear(), inDateTime.getDayOfMonth()); }