localdatetime获取本周、上周、本月、上月、本季度、上季度、本年、去年工具类

Java 8时间API实战:精准计算本周、本月、本季度、本年的首末日 在Java后端开发中,日期时间处理是基础且高频的需求,尤其在统计报表、数据归档等业务场景下,精准获取时间周期的首末日至关重要。Java 8引入的java.time API(JSR-310)以其线程安全、设计清晰的特性,彻底改变了以往依赖Calendar等易错API的局面。其核心类LocalDate和TemporalAdjusters提供了强大的日期调整能力,通过声明式编程,开发者可以简洁、优雅地实现周期计算。这一技术方案不仅提升了代码的可维护性和健壮性,更直接服务于财务系统、运营后台等需要按周、月、季度、年 阅读详情
 System.out.println("今天开始时间:" + todayStartTime());
        System.out.println("今天结束时间:" + todayEndTime());
        System.out.println("昨天开始时间:" + yesterdayStartTime());
        System.out.println("昨天结束时间:" + yesterdayEndTime());
        System.out.println("最近7天开始时间:" + last7DaysStartTime());
        System.out.println("最近7天结束时间:" + last7DaysEndTime());
        System.out.println("最近30天开始时间:" + last30DaysStartTime());
        System.out.println("最近30天天结束时间:" + last30DaysEndTime());
        System.out.println("最近一年开始时间:" + last1YearStartTime());
        System.out.println("最近一年结束时间:" + last1YearEndTime());
        System.out.println("本周开始时间:" + weekStartTime());
        System.out.println("本周结束时间:" + weekEndTime());
        System.out.println("本月开始时间:" + monthStartTime());
        System.out.println("本月结束时间:" + monthEndTime());
        System.out.println("本季度开始时间:" + quarterStartTime());
        System.out.println("本季度结束时间:" + quarterEndTime());
        System.out.println("本半年开始时间:" + halfYearStartTime());
        System.out.println("本半年结束时间:" + halfYearEndTime());
        System.out.println("本年开始时间:" + yearStartTime());
        System.out.println("本年结束时间:" + yearEndTime());
        System.out.println("上周开始时间:" + lastWeekStartTime());
        System.out.println("上周结束时间:" + lastWeekEndTime());
        System.out.println("上月开始时间:" + lastMonthStartTime());
        System.out.println("上月结束时间:" + lastMonthEndTime());
        System.out.println("上季度开始时间:" + lastQuarterStartTime());
        System.out.println("上季度结束时间:" + lastQuarterEndTime());
        System.out.println("上半年开始时间:" + lastHalfYearStartTime());
        System.out.println("上半年结束时间:" + lastHalfYearEndTime());
        System.out.println("上一年开始时间:" + lastYearStartTime());
        System.out.println("上一年结束时间:" + lastYearEndTime());
        System.out.println("下周开始时间:" + nextWeekStartTime());
        System.out.println("下周结束时间:" + nextWeekEndTime());
        System.out.println("下月开始时间:" + nextMonthStartTime());
        System.out.println("下月结束时间:" + nextMonthEndTime());
        System.out.println("下季度开始时间:" + nextQuarterStartTime());
        System.out.println("下季度结束时间:" + nextQuarterEndTime());
        System.out.println("下半年开始时间:" + nextHalfYearStartTime());
        System.out.println("下半年结束时间:" + nextHalfYearEndTime());
        System.out.println("下一年开始时间:" + nextYearStartTime());
        System.out.println("下一年结束时间:" + nextYearEndTime());


import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.Instant;
import java.time.LocalTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
/**
 * 当地时间
 * @className LocalDateTimeUtils
 **/
public class LocalDateTimeUtils {
    /**
     * 当前时间
     *
     * @return
     */
    public static LocalDateTime now() {
        return LocalDateTime.now();
    }
    
    /**
     * Date 转 LocalDateTime
     *
     * @return
     */
    public static LocalDateTime convert(Date date) {
        return LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
    }
    
    /**
     * LocalDateTime 转 Date
     *
     * @return
     */
    public static Date convert(LocalDateTime localDateTime) {
        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
    
    /**
     * 今天开始时间
     *
     * @return
     */
    public static LocalDateTime todayStartTime() {
        return LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
    }
    
    /**
     * 今天结束时间
     *
     * @return
     */
    public static LocalDateTime todayEndTime() {
        return LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
    }
    
    /**
     * 昨天开始时间
     *
     * @return
     */
    public static LocalDateTime yesterdayStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.DAYS), LocalTime.MIN);
    }
    
    /**
     * 昨天结束时间
     *
     * @return
     */
    public static LocalDateTime yesterdayEndTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.DAYS), LocalTime.MAX);
    }
    
    /**
     * 最近7天开始时间
     *
     * @return
     */
    public static LocalDateTime last7DaysStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(6L, ChronoUnit.DAYS), LocalTime.MIN);
    }
    
    /**
     * 最近7天结束时间
     *
     * @return
     */
    public static LocalDateTime last7DaysEndTime() {
        return LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
    }
    
    /**
     * 最近30天开始时间
     *
     * @return
     */
    public static LocalDateTime last30DaysStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(29L, ChronoUnit.DAYS), LocalTime.MIN);
    }
    
    /**
     * 最近30天结束时间
     *
     * @return
     */
    public static LocalDateTime last30DaysEndTime() {
        return LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
    }
    
    /**
     * 最近一年开始时间
     *
     * @return
     */
    public static LocalDateTime last1YearStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.YEARS).plus(1L, ChronoUnit.DAYS), LocalTime.MIN);
    }
    
    /**
     * 最近一年结束时间
     *
     * @return
     */
    public static LocalDateTime last1YearEndTime() {
        return LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
    }
    
    /**
     * 本周开始时间
     *
     * @return
     */
    public static LocalDateTime weekStartTime() {
        LocalDate now = LocalDate.now();
        return LocalDateTime.of(now.minusDays(now.getDayOfWeek().getValue() - 1), LocalTime.MIN);
    }
    
    /**
     * 本周结束时间
     *
     * @return
     */
    public static LocalDateTime weekEndTime() {
        LocalDate now = LocalDate.now();
        return LocalDateTime.of(now.plusDays(7 - now.getDayOfWeek().getValue()), LocalTime.MAX);
    }
    
    /**
     * 本月开始时间
     *
     * @return
     */
    public static LocalDateTime monthStartTime() {
        return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()), LocalTime.MIN);
    }
    
    /**
     * 本月结束时间
     *
     * @return
     */
    public static LocalDateTime monthEndTime() {
        return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
    }
    
    /**
     * 本季度开始时间
     *
     * @return
     */
    public static LocalDateTime quarterStartTime() {
        LocalDate now = LocalDate.now();
        Month month = Month.of(now.getMonth().firstMonthOfQuarter().getValue());
        return LocalDateTime.of(LocalDate.of(now.getYear(), month, 1), LocalTime.MIN);
    }
    
    /**
     * 本季度结束时间
     *
     * @return
     */
    public static LocalDateTime quarterEndTime() {
        LocalDate now = LocalDate.now();
        Month month = Month.of(now.getMonth().firstMonthOfQuarter().getValue()).plus(2L);
        return LocalDateTime.of(LocalDate.of(now.getYear(), month, month.length(now.isLeapYear())), LocalTime.MAX);
    }
    
    /**
     * 本半年开始时间
     *
     * @return
     */
    public static LocalDateTime halfYearStartTime() {
        LocalDate now = LocalDate.now();
        Month month = (now.getMonthValue() > 6) ? Month.JULY : Month.JANUARY;
        return LocalDateTime.of(LocalDate.of(now.getYear(), month, 1), LocalTime.MIN);
    }
    
    /**
     * 本半年结束时间
     *
     * @return
     */
    public static LocalDateTime halfYearEndTime() {
        LocalDate now = LocalDate.now();
        Month month = (now.getMonthValue() > 6) ? Month.DECEMBER : Month.JUNE;
        return LocalDateTime.of(LocalDate.of(now.getYear(), month, month.length(now.isLeapYear())), LocalTime.MAX);
    }
    
    /**
     * 本年开始时间
     *
     * @return
     */
    public static LocalDateTime yearStartTime() {
        return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN);
    }
    
    /**
     * 本年结束时间
     *
     * @return
     */
    public static LocalDateTime yearEndTime() {
        return LocalDateTime.of(LocalDate.now().with(TemporalAdjusters.lastDayOfYear()), LocalTime.MAX);
    }
    
    /**
     * 上周开始时间
     *
     * @return
     */
    public static LocalDateTime lastWeekStartTime() {
        LocalDate lastWeek = LocalDate.now().minus(1L, ChronoUnit.WEEKS);
        return LocalDateTime.of(lastWeek.minusDays(lastWeek.getDayOfWeek().getValue() - 1), LocalTime.MIN);
    }
    
    /**
     * 上周结束时间
     *
     * @return
     */
    public static LocalDateTime lastWeekEndTime() {
        LocalDate lastWeek = LocalDate.now().minus(1L, ChronoUnit.WEEKS);
        return LocalDateTime.of(lastWeek.plusDays(7 - lastWeek.getDayOfWeek().getValue()), LocalTime.MAX);
    }
    
    /**
     * 上月开始时间
     *
     * @return
     */
    public static LocalDateTime lastMonthStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.MONTHS).with(TemporalAdjusters.firstDayOfMonth()), LocalTime.MIN);
    }
    
    /**
     * 上月结束时间
     *
     * @return
     */
    public static LocalDateTime lastMonthEndTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.MONTHS).with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
    }
    
    /**
     * 上季度开始时间
     *
     * @return
     */
    public static LocalDateTime lastQuarterStartTime() {
        LocalDate now = LocalDate.now();
        Month firstMonthOfQuarter = Month.of(now.getMonth().firstMonthOfQuarter().getValue());
        Month firstMonthOfLastQuarter = firstMonthOfQuarter.minus(3L);
        int yearOfLastQuarter = firstMonthOfQuarter.getValue() < 4 ? now.getYear() - 1 : now.getYear();
        return LocalDateTime.of(LocalDate.of(yearOfLastQuarter, firstMonthOfLastQuarter, 1), LocalTime.MIN);
    }
    
    /**
     * 上季度结束时间
     *
     * @return
     */
    public static LocalDateTime lastQuarterEndTime() {
        LocalDate now = LocalDate.now();
        Month firstMonthOfQuarter = Month.of(now.getMonth().firstMonthOfQuarter().getValue());
        Month firstMonthOfLastQuarter = firstMonthOfQuarter.minus(1L);
        int yearOfLastQuarter = firstMonthOfQuarter.getValue() < 4 ? now.getYear() - 1 : now.getYear();
        return LocalDateTime.of(LocalDate.of(yearOfLastQuarter, firstMonthOfLastQuarter, firstMonthOfLastQuarter.maxLength()), LocalTime.MAX);
    }
    
    /**
     * 上半年开始时间
     *
     * @return
     */
    public static LocalDateTime lastHalfYearStartTime() {
        LocalDate now = LocalDate.now();
        int lastHalfYear = (now.getMonthValue() > 6) ? now.getYear() : now.getYear() - 1;
        Month firstMonthOfLastHalfYear = (now.getMonthValue() > 6) ? Month.JANUARY : Month.JULY;
        return LocalDateTime.of(LocalDate.of(lastHalfYear, firstMonthOfLastHalfYear, 1), LocalTime.MIN);
    }
    
    /**
     * 上半年结束时间
     *
     * @return
     */
    public static LocalDateTime lastHalfYearEndTime() {
        LocalDate now = LocalDate.now();
        int lastHalfYear = (now.getMonthValue() > 6) ? now.getYear() : now.getYear() - 1;
        Month lastMonthOfLastHalfYear = (now.getMonthValue() > 6) ? Month.JUNE : Month.DECEMBER;
        return LocalDateTime.of(LocalDate.of(lastHalfYear, lastMonthOfLastHalfYear, lastMonthOfLastHalfYear.maxLength()), LocalTime.MAX);
    }
    
    /**
     * 上一年开始时间
     *
     * @return
     */
    public static LocalDateTime lastYearStartTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.YEARS).with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN);
    }
    
    /**
     * 上一年结束时间
     *
     * @return
     */
    public static LocalDateTime lastYearEndTime() {
        return LocalDateTime.of(LocalDate.now().minus(1L, ChronoUnit.YEARS).with(TemporalAdjusters.lastDayOfYear()), LocalTime.MAX);
    }
    
    /**
     * 下周开始时间
     *
     * @return
     */
    public static LocalDateTime nextWeekStartTime() {
        LocalDate nextWeek = LocalDate.now().plus(1L, ChronoUnit.WEEKS);
        return LocalDateTime.of(nextWeek.minusDays(nextWeek.getDayOfWeek().getValue() - 1), LocalTime.MIN);
    }
    
    /**
     * 下周结束时间
     *
     * @return
     */
    public static LocalDateTime nextWeekEndTime() {
        LocalDate nextWeek = LocalDate.now().plus(1L, ChronoUnit.WEEKS);
        return LocalDateTime.of(nextWeek.plusDays(7 - nextWeek.getDayOfWeek().getValue()), LocalTime.MAX);
    }
    
    /**
     * 下月开始时间
     *
     * @return
     */
    public static LocalDateTime nextMonthStartTime() {
        return LocalDateTime.of(LocalDate.now().plus(1L, ChronoUnit.MONTHS).with(TemporalAdjusters.firstDayOfMonth()), LocalTime.MIN);
    }
    
    /**
     * 下月结束时间
     *
     * @return
     */
    public static LocalDateTime nextMonthEndTime() {
        return LocalDateTime.of(LocalDate.now().plus(1L, ChronoUnit.MONTHS).with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
    }
    
    /**
     * 下季度开始时间
     *
     * @return
     */
    public static LocalDateTime nextQuarterStartTime() {
        LocalDate now = LocalDate.now();
        Month firstMonthOfQuarter = Month.of(now.getMonth().firstMonthOfQuarter().getValue());
        Month firstMonthOfNextQuarter = firstMonthOfQuarter.plus(3L);
        int yearOfNextQuarter = firstMonthOfQuarter.getValue() > 9 ? now.getYear() + 1 : now.getYear();
        return LocalDateTime.of(LocalDate.of(yearOfNextQuarter, firstMonthOfNextQuarter, 1), LocalTime.MIN);
    }
    
    /**
     * 下季度结束时间
     *
     * @return
     */
    public static LocalDateTime nextQuarterEndTime() {
        LocalDate now = LocalDate.now();
        Month firstMonthOfQuarter = Month.of(now.getMonth().firstMonthOfQuarter().getValue());
        Month firstMonthOfNextQuarter = firstMonthOfQuarter.plus(5L);
        int yearOfNextQuarter = firstMonthOfQuarter.getValue() > 9 ? now.getYear() + 1 : now.getYear();
        return LocalDateTime.of(LocalDate.of(yearOfNextQuarter, firstMonthOfNextQuarter, firstMonthOfNextQuarter.maxLength()), LocalTime.MAX);
    }
    
    /**
     * 下半年开始时间
     *
     * @return
     */
    public static LocalDateTime nextHalfYearStartTime() {
        LocalDate now = LocalDate.now();
        int nextHalfYear = (now.getMonthValue() > 6) ? now.getYear() + 1 : now.getYear();
        Month firstMonthOfNextHalfYear = (now.getMonthValue() > 6) ? Month.JANUARY : Month.JULY;
        return LocalDateTime.of(LocalDate.of(nextHalfYear, firstMonthOfNextHalfYear, 1), LocalTime.MIN);
    }
    
    /**
     * 下半年结束时间
     *
     * @return
     */
    public static LocalDateTime nextHalfYearEndTime() {
        LocalDate now = LocalDate.now();
        int lastHalfYear = (now.getMonthValue() > 6) ? now.getYear() + 1 : now.getYear();
        Month lastMonthOfNextHalfYear = (now.getMonthValue() > 6) ? Month.JUNE : Month.DECEMBER;
        return LocalDateTime.of(LocalDate.of(lastHalfYear, lastMonthOfNextHalfYear, lastMonthOfNextHalfYear.maxLength()), LocalTime.MAX);
    }
    
    /**
     * 下一年开始时间
     *
     * @return
     */
    public static LocalDateTime nextYearStartTime() {
        return LocalDateTime.of(LocalDate.now().plus(1L, ChronoUnit.YEARS).with(TemporalAdjusters.firstDayOfYear()), LocalTime.MIN);
    }
    
    /**
     * 下一年结束时间
     *
     * @return
     */
    public static LocalDateTime nextYearEndTime() {
        return LocalDateTime.of(LocalDate.now().plus(1L, ChronoUnit.YEARS).with(TemporalAdjusters.lastDayOfYear()), LocalTime.MAX);
    }
    
    public static void main(String[] args) {
        System.out.println("当前时间:" + now());
        System.out.println("Date 转 LocalDateTime:" + convert(new Date()));
        System.out.println("LocalDateTime 转 Date:" + convert(LocalDateTime.now()));
        System.out.println("今天开始时间:" + todayStartTime());
        System.out.println("今天结束时间:" + todayEndTime());
        System.out.println("昨天开始时间:" + yesterdayStartTime());
        System.out.println("昨天结束时间:" + yesterdayEndTime());
        System.out.println("最近7天开始时间:" + last7DaysStartTime());
        System.out.println("最近7天结束时间:" + last7DaysEndTime());
        System.out.println("最近30天开始时间:" + last30DaysStartTime());
        System.out.println("最近30天天结束时间:" + last30DaysEndTime());
        System.out.println("最近一年开始时间:" + last1YearStartTime());
        System.out.println("最近一年结束时间:" + last1YearEndTime());
        System.out.println("本周开始时间:" + weekStartTime());
        System.out.println("本周结束时间:" + weekEndTime());
        System.out.println("本月开始时间:" + monthStartTime());
        System.out.println("本月结束时间:" + monthEndTime());
        System.out.println("本季度开始时间:" + quarterStartTime());
        System.out.println("本季度结束时间:" + quarterEndTime());
        System.out.println("本半年开始时间:" + halfYearStartTime());
        System.out.println("本半年结束时间:" + halfYearEndTime());
        System.out.println("本年开始时间:" + yearStartTime());
        System.out.println("本年结束时间:" + yearEndTime());
        System.out.println("上周开始时间:" + lastWeekStartTime());
        System.out.println("上周结束时间:" + lastWeekEndTime());
        System.out.println("上月开始时间:" + lastMonthStartTime());
        System.out.println("上月结束时间:" + lastMonthEndTime());
        System.out.println("上季度开始时间:" + lastQuarterStartTime());
        System.out.println("上季度结束时间:" + lastQuarterEndTime());
        System.out.println("上半年开始时间:" + lastHalfYearStartTime());
        System.out.println("上半年结束时间:" + lastHalfYearEndTime());
        System.out.println("上一年开始时间:" + lastYearStartTime());
        System.out.println("上一年结束时间:" + lastYearEndTime());
        System.out.println("下周开始时间:" + nextWeekStartTime());
        System.out.println("下周结束时间:" + nextWeekEndTime());
        System.out.println("下月开始时间:" + nextMonthStartTime());
        System.out.println("下月结束时间:" + nextMonthEndTime());
        System.out.println("下季度开始时间:" + nextQuarterStartTime());
        System.out.println("下季度结束时间:" + nextQuarterEndTime());
        System.out.println("下半年开始时间:" + nextHalfYearStartTime());
        System.out.println("下半年结束时间:" + nextHalfYearEndTime());
        System.out.println("下一年开始时间:" + nextYearStartTime());
        System.out.println("下一年结束时间:" + nextYearEndTime());
    }
    
}

Java中 LocalDate、LocalTime、LocalDateTime三个时间工具类的使用介绍 Java中 LocalDate、LocalTime、LocalDateTime三个时间工具类的使用介绍 一、背景: 之前在做项目的过程中,对日期时间类没有一个系统的了解,总是在用的时候去搜索一下,解决问题即完事,久而久之,导致对这个概念特别模糊。直到近期,做项目的过程中使用了mybatis-plus框架... 阅读详情

相关推荐

Java时间类(十三) -- LocalDateTimeParseUtil工具类 -- 关于时间类之间转化的工具类

pattern为工具类定义的静态常量--多种时间格式。pattern为工具类定义的静态常量--多种时间格式。pattern为工具类定义的静态常量--多种时间格式。pattern为工具类定义的静态常量--多种时间格式。

PUYALEI的博客 953

LocalDateTime工具类

用了ideal和jdk1.8后,LocalDateTime的使用就少不了。有些功能用Date会使用,但在LocalDateTime里有些功能是略微有些不同。相比之下LocalDateTime的使用更加简洁,也就是一行代码的事所以也用不着写工具类。API文档 里面有时间工具类、加密、表格、文件、图片、zip、http、json、map、数组等等,功能多的背不过来,需要啥就去搜索一下有没有自己想要的,没有的话在自己去写。上面写的方法比较少, 因为发现了一个很强大的开源工具类jar包:hutool,分享给大家。.

qq_29539827的博客 1745

并网逆变器学习笔记5---三电平DPWM

三电平DPWM

圆桌骑士的博客 1万+

LocalDateTime工具类:根据当前、周、月、季度、半年、年等维度获取时间

1. 简介   Java8提供了全新的日期处理包(java.time.*),根据Java8日期新特性封装日期时间工具类LocalDateTimeUtils。 2. 相关博客   Java 8 新特性:日期处理 3. 工具类方法目录 说明 方法名称 当前时间 LocalDateTimeUtils.now() Date 转 LocalDateTime LocalDateTimeUt...

C3Stones 9180

【医学影像】Deep Learning for Automatic Pneumonia Detection

写在前面的话: 这篇论文是北美放射学会(RSNA)在Kaggle平台上托管的肺炎区域检测挑战赛取得第二名成绩的解决方案。因为笔者需要用到其中的图像增强方案,因此本篇博客只介绍了数据集和图像增强,关于模型的改进和其它改进点没有涉及。 论文地址:https://arxiv.org/abs/2005.13899 代码地址:https://github.com/tatigabru/kaggle-rsna 比赛地址:https://www.kaggle.com/c/rsna-pneumonia-detection-c

chenzhoujian_的博客 1566

老款 NUC 复活计划:装 Ubuntu 部署 OpenClaw 本地 AI

老款 NUC 变身本地 AI 服务器指南 本文详细介绍了如何将老旧华硕 NUC 设备改造为本地 AI 服务器。主要内容包括: 硬件评估:列出老款 NUC 的最低配置要求(i3 6代/8GB内存/256GB SSD),并提供兼容性检查命令和性能预期表 系统准备:指导备份数据、下载 Ubuntu 22.04 LTS 和制作启动盘的方法(Windows/Linux双平台) 安装流程:从 BIOS 设置到 Ubuntu 安装的完整步骤,包括推荐的分区方案 系统优化:禁用不必要的服务、内核参数调优、Swap 配置和

博客 7606

Scala - 时间工具类 LocalDateTime 常用方法整理

Scala / Java LocalDateTime 常用方法整理。

BITDDD小栈 6297

Oracle EBS 寄销/VMI(1)-->基础设置

名词解释:     BPA:一揽子采购协议     BPR:一揽子发放     SR:来源补充规则     ASL:合格供应商列表     VMI: 供应商管理库存     寄售(Consignment)是把货物放在客户那里,客户要用的时候才付款的库存,一般是指卖方把

陈显平的专栏-Oracle EBS 1万+

jdk8 获取当天,本周,本月,本季度,本年起始时间工具类

package com.wanmi.sbc.util; import org.omg.Messaging.SYNC_WITH_TRANSPORT; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import ...

guanfengliang的专栏 3323

第八章 Vite4+Vue3+Vtkjs 完整demo演示

vtk.js是一个基于WebGL的开源3D可视化库,它可以在Web浏览器中呈现高质量的3D图形。vtk.js提供了一个易于使用的API,可以用于创建各种类型的3D可视化,包括科学、医学、工程和地球科学等领域。vtk.js支持多种数据格式,包括VTK、DICOM、STL等,可以轻松地将数据导入到可视化中。此外,vtk.js还支持交互式可视化,用户可以通过鼠标和键盘进行交互,探索和分析数据。采用的vite4+pinia搭建的Vue3项目。

Wait.End的博客 2234

π0.5部署实战(一) ------ 在Thor上使用NVFP4量化

此篇文章是pi05模型在thor上部署系列文章的第一篇.主要介绍如何对pi05 2.6B LLM(Gemma)使用nvfp4进行量化.所有操作使用开源工具可以先参考进行环境的准备和安装,在上完成以下操作.

happyAnger6的专栏 400

Java 8时间处理实战:精准计算本周、本月、本季度、本年首末日

在Java后端开发和数据分析中,日期时间处理是高频且基础的技术需求,尤其涉及按周、月、季度等周期进行数据统计与查询时,准确计算时间边界至关重要。Java 8引入的`java.time` API(JSR-310)提供了一套全新的日期时间库,其核心类如`LocalDate`具有不可变和线程安全的特性,从设计上解决了旧版`Date`和`Calendar`类的诸多缺陷。通过`TemporalAdjusters`这一时间调节器工具类,开发者能以声明式、高可读性的方式,精准地将日期调整到特定时间周期的起始或结束位置,例

weixin_34184158的博客 437

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

LocalDateTime工具类:根据当前、周、月、季度、半年、年等维度获取时间&hutool工具包获取农历日期,生肖,传统节日

*** 一周的第一天** @param localDate 当地日期} /*** 一周的最后一天** @param localDate 当地日期} /*** 月的第一天** @param localDate 当地日期} /*** 月的最后一天** @param localDate 当地日期} /*** 每年的第一天** @param localDate 当地日期} /*** 每年的最后一天** @param localDate 当地日期。

qq_43842093的博客 4275

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Java获取当天,本周,本月,本季度,本年起始时间工具类

import java.time.*; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Locale; /** * jdk8 获取当天,本周,本月,本季度,本年起始时间工具类 LocalDateTime */ public class LocalDateTimeUtils { public static final String MinTime = "T00:00:00"..

命中的缘分的博客 1410

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Java 8 获取本(天周月季度年)的开始、结束时间

Java 8 获取本(天周月季度年)的开始、结束时间话不多说,直接上代码Java获取本周的开始时间与结束时间Java获取本月的开始时间与结束时间Java获取本季度的开始时间与结束时间Java获取本年的开始时间与结束时间结束语 话不多说,直接上代码 在上之前还是先简单的介绍一下哈:很多时候项目中我们都会遇到获取特定时间日期的问题,例如:获取当天、本周、本月、本季度、本年的开始时间月结束时间等。当然使...

张小洛的BOLG 9537

java获取 本周 本年 本月 本季

java获取本周本年 本月

雨木三更 1572

LocalDateTime 工具类

说明:此工具类结合网上一些资料加上自己根据业务需求整理而成 package*.utils; import com.alibaba.fastjson.JSON; import com.google.common.collect.Maps; import java.time.*; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; imp.

yedongfeng_1314的博客 302

java中获取当前时间、本周、本月、当前季度、年度的开始时间与结束时间

拿到返回值,将其以逗号分隔开就可以用了(参数的dateType值需要前端传,前端选择相应的时间,比如前端传3,那就是获取当前时间的本月开始时间与结束时间)项目中的大屏统计经常会用到根据时间去统计相关数据,所以就需要获取相应的开始时间与结束时间,以便在sql中能查询出对应区间的数据。代码直接复制就可以用,返回的数据就是开始时间与结束时间。

m0_61496760的博客 1936

Java时区国际化统一为东八区时间 使用localdate获取本周、上周、本月、上月、本季度、上季度、本年、去年工具类

【代码】java国际化时间统一为东八区时间 使用localdate获取本周、上周、本月、上月、本季度、上季度、本年、去年工具类。

codeSmart的博客 325

Java使用LocalDate获取当前时间的上一年、下一年、上个月、下个月、前一天,当天,本周,上周,本季度,上季度等(时间格式化)

【代码】Java使用LocalDate获取当前时间的上一年、下一年、上个月、下个月、前一天,当天,本周,上周,本季度,上季度等(时间格式化)

wasd986523的博客 2182

Java8 LocalDateTime 获取当前日周月年的起止时间

Java8 获取当天、本周、本月、本季度、本年度起止时间一、返回 LocalDateTime 格式的起止时间二、返回 String 格式的起止时间 一、返回 LocalDateTime 格式的起止时间 /** * @Description:返回 LocalDateTime 格式的日、周、月、季度、年起止时间 * @Author: lsiyan * @Date: 2020/8/21 22:47 */ import java.time.*; import java.time.temporal.Temp

Athena072213的博客 6275

JAVA 获取 本季度起始时间 本月起始时间 等等工具类

【代码】JAVA 获取 本季度起始时间 本月起始时间 等等工具类。

Dixcm的博客 542

Java (时间格式化) 使用LocalDate获取当前时间的上一年、下一年、上个月、下个月、前一天,当天,本周,上周,本季度,上季度等

【代码】Java (时间格式化) 使用LocalDate获取当前时间的上一年、下一年、上个月、下个月、前一天,当天,本周,上周,本季度,上季度等。

qq_41615095的博客 803

获取各个时间

String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};allWeekMinVO1.setWeekNumber("第"+String.valueOf(i+2)+"周");allWeekMinVO.setWeekNumber("第"+String.valueOf(i+1)+"季度");//因为数组下标从0开始,而返回的是数组的内容,是数组{1,2,3,4,5,6,7}中用1~7来表示,所以要减1。//获取本月的第一天的零点。

weixin_57322959的博客 299
上一篇: Java时区国际化解决方案
下一篇: Java时区国际化统一为东八区时间 使用localdate获取本周、上周、本月、上月、本季度、上季度、本年、去年工具类
狂野弘仁
博客等级 码龄8年 34粉丝 81原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值