本文整理汇总了Java中org.joda.time.DateTime.getDayOfYear方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.getDayOfYear方法的具体用法?Java DateTime.getDayOfYear怎么用?Java DateTime.getDayOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.getDayOfYear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTheSameDay
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* 是否同一天 年月日是否一致
*
* @param date1
* @param date2
* @return
*/
public static boolean isTheSameDay(@Nullable Date date1,@Nullable Date date2) {
if(Check.isNullObjects(date1,date2)){
return false;
}
DateTime dateTime1 = new DateTime(date1);
DateTime dateTime2 = new DateTime(date2);
//年份是否一样
if (dateTime1.getYear() != dateTime2.getYear()) {
return false;
}
//日期是否一样
if (dateTime1.getDayOfYear() != dateTime2.getDayOfYear()) {
return false;
}
return true;
}
示例2: confirmNewEvent
import org.joda.time.DateTime; //导入方法依赖的package包/类
public OutputSpeech confirmNewEvent(String title, DateTime from, DateTime to, Locale locale) {
final String speechText;
if(from.getYear() == to.getYear() && from.getDayOfYear() == to.getDayOfYear()) {
speechText = messageService.de("event.new.confirm.sameday",
from.toString(DAY_FORMAT, locale),
from.toString(DATE_YEAR_FORMAT),
from.toString(TIME_FORMAT),
to.toString(TIME_FORMAT),
title);
} else {
speechText = messageService.de("event.new.confirm",
from.toString(DAY_FORMAT, locale),
from.toString(DATE_YEAR_FORMAT),
from.toString(TIME_FORMAT),
to.toString(DAY_FORMAT, locale),
to.toString(DATE_YEAR_FORMAT),
to.toString(TIME_FORMAT),
title);
}
return speechMessage(speechText);
}
示例3: getFirstDayOfYear
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* 获取某一天所在年的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfYear(Date date) {
DateTime dateTime = new DateTime(date.getTime());
int dayOfYear = dateTime.getDayOfYear();
DateTime firstDate = dateTime.minusDays(dayOfYear - 1);
firstDate = firstDate.withTime(0, 0, 0, 0);
return firstDate.toDate();
}
示例4: separateByDate
import org.joda.time.DateTime; //导入方法依赖的package包/类
private List<RevCommit> separateByDate(List<RevCommit> commits) {
List<RevCommit> separated = new ArrayList<>();
DateTime groupTime = null;
for (RevCommit commit: commits) {
DateTime commitTime = new DateTime(commit.getCommitterIdent().getWhen());
if (groupTime == null || commitTime.getYear() != groupTime.getYear()
|| commitTime.getDayOfYear() != groupTime.getDayOfYear()) {
groupTime = commitTime;
separated.add(null);
}
separated.add(commit);
}
return separated;
}
示例5: getTimeStampString
import org.joda.time.DateTime; //导入方法依赖的package包/类
private String getTimeStampString(Date dt) {
String out;
DateTime d1 = new DateTime(dt);
DateTime d2 = DateTime.now();
long difference = d2.getMillis() - d1.getMillis();
long minutes = TimeUnit.MILLISECONDS.toMinutes(difference);
long hours = TimeUnit.MILLISECONDS.toHours(difference);
long days = TimeUnit.MILLISECONDS.toDays(difference);
int daydif = d2.getDayOfYear() - d1.getDayOfYear();
boolean thisyear = (d1.getYear() == d2.getYear());
boolean ontem = (daydif == 1 && (days < 2));
if (minutes < 60) {
out = String.valueOf(minutes) + " min";
} else if (hours < 24 && !ontem) {
out = String.valueOf(hours) + " h";
} else {
SimpleDateFormat format = new SimpleDateFormat("d,MMM/yyyy-H:mm", new Locale("pt", "BR"));
format.setTimeZone(TimeZone.getDefault());
String aux = format.format(dt);
if (ontem) {
String[] split = aux.split("-");
out = "Ontem às " + split[split.length - 1];
} else {
if (thisyear) {
String year = String.valueOf(d2.getYear());
out = aux.replace(",", " de ");
out = out.replace("/" + year + "-", " às ");
} else {
out = aux.replace(",", " de ");
out = out.replace("/", " de");
out = out.replace("-", " às ");
}
}
}
return out;
}
示例6: allSlots
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* @return all intervals that fall within provided working hours
*/
private static Iterable<Interval> allSlots(Iterable<ExamRoom.OpeningHours> openingHours, ExamRoom room, LocalDate date) {
Collection<Interval> intervals = new ArrayList<>();
List<ExamStartingHour> startingHours = room.getExamStartingHours();
if (startingHours.isEmpty()) {
// Default to 1 hour slots that start at the hour
startingHours = createDefaultStartingHours(room.getLocalTimezone());
}
Collections.sort(startingHours);
DateTime now = DateTime.now().plusMillis(DateTimeZone.forID(room.getLocalTimezone()).getOffset(DateTime.now()));
for (ExamRoom.OpeningHours oh : openingHours) {
int tzOffset = oh.getTimezoneOffset();
DateTime instant = now.getDayOfYear() == date.getDayOfYear() ? now : oh.getHours().getStart();
DateTime slotEnd = oh.getHours().getEnd();
DateTime beginning = nextStartingTime(instant, startingHours, tzOffset);
while (beginning != null) {
DateTime nextBeginning = nextStartingTime(beginning.plusMillis(1), startingHours, tzOffset);
if (beginning.isBefore(oh.getHours().getStart())) {
beginning = nextBeginning;
continue;
}
if (nextBeginning != null && !nextBeginning.isAfter(slotEnd)) {
intervals.add(new Interval(beginning.minusMillis(tzOffset), nextBeginning.minusMillis(tzOffset)));
beginning = nextBeginning;
} else if (beginning.isBefore(slotEnd)) {
// We have some spare time in the end, take it as well
intervals.add(new Interval(beginning.minusMillis(tzOffset), slotEnd.minusMillis(tzOffset)));
break;
} else {
break;
}
}
}
return intervals;
}
示例7: isToday
import org.joda.time.DateTime; //导入方法依赖的package包/类
private boolean isToday(Event event) {
DateTime start = event.getStart();
DateTime now = DateTime.now();
return start.getDayOfYear() == now.getDayOfYear() && start.getYear() == now.getYear();
}
示例8: isTomorrow
import org.joda.time.DateTime; //导入方法依赖的package包/类
private boolean isTomorrow(Event event) {
DateTime start = event.getStart();
DateTime tomorrow = DateTime.now().plusDays(1);
return start.getDayOfYear() == tomorrow.getDayOfYear() && start.getYear() == tomorrow.getYear();
}