org.joda.time.DateTime.dayOfWeek()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中org.joda.time.DateTime.dayOfWeek()方法的一些代码示例,展示了DateTime.dayOfWeek()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.dayOfWeek()方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:dayOfWeek

DateTime.dayOfWeek介绍

[英]Get the day of week property which provides access to advanced functionality.
[中]获取星期几属性,该属性提供对高级功能的访问。

代码示例

代码示例来源:origin: stackoverflow.com

// © 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.
// import org.joda.time.*;
// import org.joda.time.format.*;

// Specify time zone rather than rely on default.
// Time Zone list… http://joda-time.sourceforge.net/timezones.html  (not quite up-to-date, read page for details)
DateTimeZone timeZone = DateTimeZone.forID( "Europe/Paris" );

DateTime now = new DateTime( timeZone );
if( now.dayOfWeek().get() == DateTimeConstants.MONDAY ) {
  System.out.println( "Today is a Monday." );
} else {
  System.out.println( "Nope, today is some other day of week." );
}

代码示例来源:origin: ihaolin/antares

/**
   * 获得当前周最后一天 周日
   * @param date 日期
   * @return 当前周最后一天
   */
  public static Date endDateOfWeek(Date date){
    DateTime dateTime = new DateTime(date);
    return dateTime.dayOfWeek().withMaximumValue().toDate();
  }
}

代码示例来源:origin: ihaolin/antares

/**
 * 获得当前周第一天,周一
 * @param date 日期
 * @return 当前周第一天
 */
public static Date startDateOfWeek(Date date){
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfWeek().withMinimumValue().toDate();
}

代码示例来源:origin: ihaolin/common

/**
 * 获得当前周第一天,周一
 * @param date 日期
 * @return 当前周第一天
 */
public static Date startDateOfWeek(Date date){
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfWeek().withMinimumValue().toDate();
}

代码示例来源:origin: me.hao0/common

/**
 * 获得当前周第一天,周一
 * @param date 日期
 * @return 当前周第一天
 */
public static Date startDateOfWeek(Date date){
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfWeek().withMinimumValue().toDate();
}

代码示例来源:origin: me.hao0/common

/**
   * 获得当前周最后一天 周日
   * @param date 日期
   * @return 当前周最后一天
   */
  public static Date endDateOfWeek(Date date){
    DateTime dateTime = new DateTime(date);
    return dateTime.dayOfWeek().withMaximumValue().toDate();
  }
}

代码示例来源:origin: ruediste/btrbck

@Override
  public DateTime truncate(DateTime time) {
    return time.dayOfWeek().roundFloorCopy();
  }
},

代码示例来源:origin: stackoverflow.com

DateTimeFormatter jodaFormatter = ISODateTimeFormat.dateTime();
DateTime jodaParsed = jodaFormatter
        .parseDateTime("2013-05-17T16:27:34.9+05:30");
Date date2 = jodaParsed.toDate();
System.out.println("Date & Day:" + jodaParsed.getDayOfMonth() + "-" + jodaParsed.getMonthOfYear() + "-" + jodaParsed.getYear() + " " + jodaParsed.getHourOfDay() + ":" + jodaParsed.getMinuteOfHour()+" "+jodaParsed.dayOfWeek().getAsText());

代码示例来源:origin: org.hsweb/hsweb-commons

/**
 * 获取当前周的周一和下周一
 *
 * @return 日期数组(索引0为周一,索引1为下周一)
 */
public static Date[] getMondayAndNextMonday() {
  DateTime dateTime = getDateOnly(new DateTime());
  DateTime monday = dateTime.dayOfWeek().withMinimumValue();
  DateTime nextMonday = monday.plusDays(7);
  return new Date[]{monday.toDate(), nextMonday.toDate()};
}

代码示例来源:origin: hs-web/hsweb-utils

/**
 * 获取指定时间的周一和周日
 *
 * @param dateTime DateTime对象
 * @return 日期数组(索引0为周一,索引1为周日)
 */
public static Date[] getMondayAndSunday(DateTime dateTime) {
  dateTime = getDateOnly(dateTime);
  DateTime monday = dateTime.dayOfWeek().withMinimumValue();
  DateTime sunday = monday.plusDays(6);
  return new Date[]{monday.toDate(), sunday.toDate()};
}

代码示例来源:origin: org.hsweb/hsweb-commons

/**
 * 获取指定时间的周一和周日
 *
 * @param dateTime DateTime对象
 * @return 日期数组(索引0为周一,索引1为周日)
 */
public static Date[] getMondayAndSunday(DateTime dateTime) {
  dateTime = getDateOnly(dateTime);
  DateTime monday = dateTime.dayOfWeek().withMinimumValue();
  DateTime sunday = monday.plusDays(6);
  return new Date[]{monday.toDate(), sunday.toDate()};
}

代码示例来源:origin: stackoverflow.com

// Not generally a good idea to focus on integers for working with date-time, but you asked for it.
DateTime someDateTime = new DateTime( 1234567898765L, DateTimeZone.UTC );

System.out.println( "Set Value of 1234567898765L is: " + someDateTime );
System.out.println( "Year is " + someDateTime.year().getAsText( locale ) );
System.out.println( "Month is " + someDateTime.monthOfYear().getAsText( locale ) );
System.out.println( "Day of month is " + someDateTime.dayOfMonth().getAsText( locale ) );
System.out.println( "Day of week is " + someDateTime.dayOfWeek().getAsText( locale ) );
System.out.println( "Day of year is " + someDateTime.dayOfYear().getAsText( locale ) );

代码示例来源:origin: dhis2/dhis2-core

@Override
public int daysInWeek()
{
  LocalDate localDate = new LocalDate( 1, 1, 1, chronology );
  return localDate.toDateTimeAtStartOfDay().dayOfWeek().getMaximumValue();
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

/**
 * Calculates, and returns, a date representing the first day of the week
 * relative to the current date.
 */
public Date startOfWeek() {
  return new Date(date.dayOfWeek().withMinimumValue());
}

代码示例来源:origin: org.apache.isis/applib

/**
 * Calculates, and returns, a date representing the first day of the week
 * relative to the current date.
 */
public Date startOfWeek() {
  return new Date(date.dayOfWeek().withMinimumValue());
}

代码示例来源:origin: qcadoo/mes

public List<DateTimeRange> getShiftWorkDateTimes(final Entity productionLine, final Shift shift, DateTime dateOfDay) {
  List<TimeRange> shiftWorkTime = Lists.newArrayList();
  List<DateTimeRange> shiftWorkDateTime = Lists.newArrayList();
  if (shift.worksAt(dateOfDay.dayOfWeek().get())) {
    shiftWorkTime = shift.findWorkTimeAt(dateOfDay.toLocalDate());
  }
  for (TimeRange range : shiftWorkTime) {
    shiftWorkDateTime.add(new DateTimeRange(dateOfDay, range));
  }
  shiftWorkDateTime = manageExceptions(shiftWorkDateTime, productionLine, shift, dateOfDay.toDate());
  return shiftWorkDateTime;
}

代码示例来源:origin: co.cask.wrangler/wrangler-core

/**
 * Extracts day of the week from the date.
 *
 * @param date to extract date of the week.
 * @return day of the week.
 */
public static String DAY_OF_WEEK_LONG(ZonedDateTime date) {
 validate(date, "DAY_OF_WEEK_LONG");
 DateTime dt = getDateTime(date);
 DateTime.Property value = dt.dayOfWeek();
 return value.getAsText();
}

代码示例来源:origin: se.vgregion.oppna-program-notessystem/oppna-program-notessystem-calendar-composite-types

/**
 * Capitalized string of the end day of week with sv_SE locale.
 *
 * @return Capitalized string of the day of week
 */
public String getEndDayOfWeek() {
  String dayOfWeek = interval.getEnd().dayOfWeek().getAsText(DEFAULT_LOCALE);
  return WordUtils.capitalize(dayOfWeek);
}

代码示例来源:origin: co.cask.wrangler/wrangler-core

/**
 * Extracts day of the week from the date.
 *
 * @param date to extract date of the week.
 * @return day of the week.
 */
public static String DAY_OF_WEEK_SHORT(ZonedDateTime date) {
 validate(date, "DAY_OF_WEEK_SHORT");
 DateTime dt = getDateTime(date);
 DateTime.Property value = dt.dayOfWeek();
 return value.getAsShortText();
}

代码示例来源:origin: se.vgregion.oppna-program-notessystem/oppna-program-notessystem-calendar-composite-types

/**
 * Capitalized and localized string of the day of week.
 *
 * @param locale to use on the returned string
 * @return Capitalized and localized string of the day of week
 */
public String getDayOfWeek(Locale locale) {
  String dayOfWeek = interval.getStart().dayOfWeek().getAsText(locale);
  return WordUtils.capitalize(dayOfWeek);
}

相关文章

DateTime类方法