热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

本文整理了Java中org.joda.time.LocalDateTime.withDayOfMonth()方法的一些代码示例,展示了LocalDateTime.withDayOfMonth()的具体

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

LocalDateTime.withDayOfMonth介绍

[英]Returns a copy of this datetime with the day of month field updated.

LocalDateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of month changed.
[中]返回此datetime的副本,并更新月日字段。
LocalDateTime是不可变的,因此没有set方法。相反,此方法返回一个新实例,该实例的值为“已更改的月份天数”。

代码示例

代码示例来源:origin: plusonelabs/calendar-widget

/**
* Implemented based on this answer: http://stackoverflow.com/a/5451245/297710
*/
private DateTime fromAllDayMillis(long millis) {
String msgLog = "millis=" + millis;
DateTime fixed;
try {
DateTime utcDate = new DateTime(millis, DateTimeZone.UTC);
LocalDateTime ldt = new LocalDateTime()
.withYear(utcDate.getYear())
.withMonthOfYear(utcDate.getMonthOfYear())
.withDayOfMonth(utcDate.getDayOfMonth())
.withMillisOfDay(0);
int hour = 0;
while (zone.isLocalDateTimeGap(ldt)) {
Log.v("fixTimeOfAllDayEvent", "Local Date Time Gap: " + ldt + "; " + msgLog);
ldt = ldt.withHourOfDay(++hour);
}
fixed = ldt.toDateTime(zone);
msgLog += " -> " + fixed;
if (BuildConfig.DEBUG) {
Log.v("fixTimeOfAllDayEvent", msgLog);
}
} catch (org.joda.time.IllegalInstantException e) {
throw new org.joda.time.IllegalInstantException(msgLog + " caused by: " + e);
}
return fixed;
}

代码示例来源:origin: com.effektif/effektif-workflow-api

@Override
public LocalDateTime resolve(LocalDateTime base) {
LocalDateTime time = null;
if (HOUR_OF_DAY.equals(indexUnit)) {
time = base.withTime(index, 0, 0, 0);
if (!time.isAfter(base)) {
return time.plusDays(1);
}
} else if (DAY_OF_WEEK.equals(indexUnit)) {
time = base
.withDayOfWeek(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusWeeks(1);
}
} else if (DAY_OF_MONTH.equals(indexUnit)) {
time = base
.withDayOfMonth(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusMonths(1);
}
}
if (atHour!=null) {
time = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
}
return time;
}

代码示例来源:origin: effektif/effektif

@Override
public LocalDateTime resolve(LocalDateTime base) {
LocalDateTime time = null;
if (HOUR_OF_DAY.equals(indexUnit)) {
time = base.withTime(index, 0, 0, 0);
if (!time.isAfter(base)) {
return time.plusDays(1);
}
} else if (DAY_OF_WEEK.equals(indexUnit)) {
time = base
.withDayOfWeek(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusWeeks(1);
}
} else if (DAY_OF_MONTH.equals(indexUnit)) {
time = base
.withDayOfMonth(index)
.withTime(0, 0, 0, 0);
if (!time.isAfter(base)) {
time = time.plusMonths(1);
}
}
if (atHour!=null) {
time = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
}
return time;
}

代码示例来源:origin: plusonelabs/calendar-widget

/**
* from http://stackoverflow.com/a/5451245/297710
*/
private void reproducedTimeZoneOffsetTransitionException() {
final DateTimeZone dateTimeZOne= DateTimeZone.forID("CET");
LocalDateTime localDateTime = new LocalDateTime(dateTimeZone)
.withYear(2011)
.withMonthOfYear(3)
.withDayOfMonth(27)
.withHourOfDay(2);
// this is just here to illustrate I'm solving the problem;
// don't need in operational code
try {
DateTime myDateBroken = localDateTime.toDateTime(dateTimeZone);
fail("No exception for " + localDateTime + " -> " + myDateBroken);
} catch (IllegalArgumentException iae) {
Log.v(TAG, "Sure enough, invalid instant due to time zone offset transition: "
+ localDateTime);
}
if (dateTimeZone.isLocalDateTimeGap(localDateTime)) {
localDateTime = localDateTime.withHourOfDay(3);
}
DateTime myDate = localDateTime.toDateTime(dateTimeZone);
Log.v(TAG, "No problem with this date: " + myDate);
}

代码示例来源:origin: org.motechproject/motech-platform-commons-date

public static DateTime newDateTime(LocalDate localDate, int hour, int minute, int second) {
final DateTimeZone zOne= DateTimeSourceUtil.timeZone();
LocalDateTime localDateTime = new LocalDateTime(zone)
.withYear(localDate.getYear())
.withMonthOfYear(localDate.getMonthOfYear())
.withDayOfMonth(localDate.getDayOfMonth())
.withHourOfDay(hour)
.withMinuteOfHour(minute)
.withSecondOfMinute(second)
.withMillisOfSecond(0);
if (zone.isLocalDateTimeGap(localDateTime)) {
localDateTime = localDateTime.withHourOfDay(hour + 1);
}
return localDateTime.toDateTime();
}

推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • 如何用UE4制作2D游戏文档——计算篇
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了如何用UE4制作2D游戏文档——计算篇相关的知识,希望对你有一定的参考价值。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文介绍了Java高并发程序设计中线程安全的概念与synchronized关键字的使用。通过一个计数器的例子,演示了多线程同时对变量进行累加操作时可能出现的问题。最终值会小于预期的原因是因为两个线程同时对变量进行写入时,其中一个线程的结果会覆盖另一个线程的结果。为了解决这个问题,可以使用synchronized关键字来保证线程安全。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 标题: ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • 本文介绍了一种轻巧方便的工具——集算器,通过使用集算器可以将文本日志变成结构化数据,然后可以使用SQL式查询。集算器利用集算语言的优点,将日志内容结构化为数据表结构,SPL支持直接对结构化的文件进行SQL查询,不再需要安装配置第三方数据库软件。本文还详细介绍了具体的实施过程。 ... [详细]
  • 本文详细介绍了GetModuleFileName函数的用法,该函数可以用于获取当前模块所在的路径,方便进行文件操作和读取配置信息。文章通过示例代码和详细的解释,帮助读者理解和使用该函数。同时,还提供了相关的API函数声明和说明。 ... [详细]
  • Oracle seg,V$TEMPSEG_USAGE与Oracle排序的关系及使用方法
    本文介绍了Oracle seg,V$TEMPSEG_USAGE与Oracle排序之间的关系,V$TEMPSEG_USAGE是V_$SORT_USAGE的同义词,通过查询dba_objects和dba_synonyms视图可以了解到它们的详细信息。同时,还探讨了V$TEMPSEG_USAGE的使用方法。 ... [详细]
  • 网络请求模块选择——axios框架的基本使用和封装
    本文介绍了选择网络请求模块axios的原因,以及axios框架的基本使用和封装方法。包括发送并发请求的演示,全局配置的设置,创建axios实例的方法,拦截器的使用,以及如何封装和请求响应劫持等内容。 ... [详细]
  • 本文介绍了Java中Currency类的getInstance()方法,该方法用于检索给定货币代码的该货币的实例。文章详细解释了方法的语法、参数、返回值和异常,并提供了一个示例程序来说明该方法的工作原理。 ... [详细]
author-avatar
Lyceenne
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有