javaiso8601的简单介绍

华为云服务器特价优惠火热进行中!

2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。

合作流程:
1、点击链接注册/关联华为云账号:点击跳转
2、添加客服微信号:cloud7591,确定产品方案、价格方案、服务支持方案等;
3、客服协助购买,并拉微信技术服务群,享受一对一免费技术支持服务;
技术专家在金蝶、华为、腾讯原厂有多年工作经验,并已从事云计算服务8年,可对域名、备案、网站搭建、系统部署、AI人工智能、云资源规划等上云常见问题提供更专业靠谱的服务,对相应产品提供更优惠的报价和方案,欢迎咨询。

今天给各位分享javaiso8601的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

微信号:cloud7591
如需了解更多,欢迎添加客服微信咨询。
复制微信号

本文目录一览:

程序包java.time不存在怎么解决?

jdk版本太低,java.time.LocalTime是java8新出的包。如果版本太低的话,比如jdk1.6,当然java.time不存在。换一个好版本的jdk!!\x0d\x0a\x0d\x0a为什么需要新的日期/日期API?\x0d\x0a在开始研究Java8日期/时间API之前,让我们先来看一下为什么我们需要这样一个新的API。在Java中,现有的与日期和时间相关的类存在诸多问题,其中有:\x0d\x0aJava的日期/时间类的定义并不一致,在java.util和java.sql的包中都有日期类,此外用于格式化和解析的类在java.text包中定义。\x0d\x0ajava.util.Date同时包含日期和时间,而java.sql.Date仅包含日期,将其纳入java.sql包并不合理。另外这两个类都有相同的名字,这本身就是一个非常糟糕的设计。\x0d\x0a对于时间、时间戳、格式化以及解析,并没有一些明确定义的类。对于格式化和解析的需求,我们有java.text.DateFormat抽象类,但通常情况下,SimpleDateFormat类被用于此类需求。\x0d\x0a所有的日期类都是可变的,因此他们都不是线程安全的,这是Java日期类最大的问题之一。\x0d\x0a日期类并不提供国际化,没有时区支持,因此Java引入了java.util.Calendar和java.util.TimeZone类,但他们同样存在上述所有的问题。\x0d\x0a在现有的日期和日历类中定义的方法还存在一些其他的问题,但以上问题已经很清晰地表明:Java需要一个健壮的日期/时间类。这也是为什么JodaTime在Java日期/时间需求中扮演了高质量替换的重要角色。\x0d\x0aJava8日期/时间API\x0d\x0aJava8日期/时间API是JSR-310的实现,它的实现目标是克服旧的日期时间实现中所有的缺陷,新的日期/时间API的一些设计原则是:\x0d\x0a不变性:新的日期/时间API中,所有的类都是不可变的,这对多线程环境有好处。\x0d\x0a关注点分离:新的API将人可读的日期时间和机器时间(unixtimestamp)明确分离,它为日期(Date)、时间(Time)、日期时间(DateTime)、时间戳(unixtimestamp)以及时区定义了不同的类。\x0d\x0a清晰:在所有的类中,方法都被明确定义用以完成相同的行为。举个例子,要拿到当前实例我们可以使用now()方法,在所有的类中都定义了format()和parse()方法,而不是像以前那样专门有一个独立的类。为了更好的处理问题,所有的类都使用了工厂模式和策略模式,一旦你使用了其中某个类的方法,与其他类协同工作并不困难。\x0d\x0a实用操作:所有新的日期/时间API类都实现了一系列方法用以完成通用的任务,如:加、减、格式化、解析、从日期/时间中提取单独部分,等等。\x0d\x0a可扩展性:新的日期/时间API是工作在ISO-8601日历系统上的,但我们也可以将其应用在非IOS的日历上。\x0d\x0a\x0d\x0a\x0d\x0aJava8日期/时间API包:\x0d\x0ajava.time包:这是新的Java日期/时间API的基础包,所有的主要基础类都是这个包的一部分,如:LocalDate,LocalTime,LocalDateTime,Instant,Period,Duration等等。所有这些类都是不可变的和线程安全的,在绝大多数情况下,这些类能够有效地处理一些公共的需求。\x0d\x0ajava.time.chrono包:这个包为非ISO的日历系统定义了一些泛化的API,我们可以扩展AbstractChronology类来创建自己的日历系统。\x0d\x0ajava.time.format包:这个包包含能够格式化和解析日期时间对象的类,在绝大多数情况下,我们不应该直接使用它们,因为java.time包中相应的类已经提供了格式化和解析的方法。\x0d\x0ajava.time.temporal包:这个包包含一些时态对象,我们可以用其找出关于日期/时间对象的某个特定日期或时间,比如说,可以找到某月的第一天或最后一天。你可以非常容易地认出这些方法,因为它们都具有“withXXX”的格式。\x0d\x0ajava.time.zone包:这个包包含支持不同时区以及相关规则的类。

有人知道怎么把ISO8601标准的时间转化成Java对象吗

般情况直接用replace("2011-9-9","-","/")行,

涉及数据转换用两:

CStr(变量) 其类型转字符串型

CDate(变量) 其类型转期型

:原变量date1期型,

date1=date

obj=replace(cstr(date1),"-","/")

obj要格式.

另外借用自定义函数转换.

Function FormatDate(sDateTime, sReallyDo)

Dim sJorkin

sJorkin = GetLocale()

If Not IsDate(sDateTime) Then sDateTime = Now()

sDateTime = CDate(sDateTime)

Select Case UCase(sReallyDo "")

Case "0", "1", "2", "3", "4"

FormatDate = FormatDateTime(sDateTime, sReallyDo)

Case "00"

FormatDate = FormatDate(sDateTime, "YYYY-MM-DD hh:mm:ss")

Case "01"

FormatDate = FormatDate(sDateTime, "YYYYMM月DD")

Case "02"

FormatDate = FormatDate(sDateTime, "YYYY-MM-DD")

Case "03"

FormatDate = FormatDate(sDateTime, "hh:mm:ss")

Case "04"

FormatDate = FormatDate(sDateTime, "hh:mm")

Case "ISO8601", "GOOGLE", "SITEMAP" '//ISO8601格式, 般用于GoogleSiteMap, "+08:00" 区.

FormatDate = FormatDate(sDateTime, "YYYY-MM-DDThh:mm:ss.000+08:00")

Case "RFC822", "RSS", "FEED" '//RFC822格式, 般用于RSS, "+0800" 区.

SetLocale("en-gb")

FormatDate = FormatDate(sDateTime, "ew, DD eMM YYYY hh:mm:ss +0800")

SetLocale(sJorkin)

Case "RND", "RAND", "RANDOMIZE" '//随机字符串

Randomize

sJorkin = Rnd()

FormatDate = FormatDate(sDateTime, "YYYYMMDDhhmmss") _

Fix((9 * 10^6 -1) * sJorkin) + 10^6

Case Else

FormatDate = sReallyDo

FormatDate = Replace(FormatDate, "YYYY", Year(sDateTime))

FormatDate = Replace(FormatDate, "DD", Right("0" Day(sDateTime), 2))

FormatDate = Replace(FormatDate, "hh", Right("0" Hour(sDateTime), 2))

FormatDate = Replace(FormatDate, "mm", Right("0" Minute(sDateTime), 2))

FormatDate = Replace(FormatDate, "ss", Right("0" Second(sDateTime), 2))

FormatDate = Replace(FormatDate, "YY", Right(Year(sDateTime), 2))

FormatDate = Replace(FormatDate, "D", Day(sDateTime))

FormatDate = Replace(FormatDate, "h", Hour(sDateTime))

FormatDate = Replace(FormatDate, "m", Minute(sDateTime))

FormatDate = Replace(FormatDate, "s", Second(sDateTime))

If InStr(1, FormatDate, "EW", 1) 0 Then

SetLocale("en-gb")

FormatDate = Replace(FormatDate, "EW", UCase(WeekdayName(Weekday(sDateTime), False)))

FormatDate = Replace(FormatDate, "eW", WeekdayName(Weekday(sDateTime), False))

FormatDate = Replace(FormatDate, "Ew", UCase(WeekdayName(Weekday(sDateTime), True)))

FormatDate = Replace(FormatDate, "ew", WeekdayName(Weekday(sDateTime), True))

SetLocale(sJorkin)

Else

FormatDate = Replace(FormatDate, "W", WeekdayName(Weekday(sDateTime), False))

FormatDate = Replace(FormatDate, "w", WeekdayName(Weekday(sDateTime), True))

End If

If InStr(1, FormatDate, "EMM", 1) 0 Then

SetLocale("en-gb")

FormatDate = Replace(FormatDate, "EMM", MonthName(Month(sDateTime), False))

FormatDate = Replace(FormatDate, "eMM", MonthName(Month(sDateTime), True))

SetLocale(sJorkin)

Else

FormatDate = Replace(FormatDate, "MM", Right("0" Month(sDateTime), 2))

FormatDate = Replace(FormatDate, "M", Month(sDateTime))

End If

End Select

End Function

%

'期格式化ISO8601格式

Response.Write(FormatDate("2008-03-06 08:03:06", "SITEMAP"))

'期格式化RFC822格式

Response.Write(FormatDate("2008-03-06 08:03:06", "RSS"))

'期格式化(英星期, 英月//)

Response.Write(FormatDate(Now(), "eW, EMM/DD/YYYY"))

'月秒随机数字符串

Response.Write(FormatDate(Now(), "RND"))

般情况直接用replace("2011-9-9","-","/")行,

涉及数据转换用两:

CStr(变量) 其类型转字符串型

CDate(变量) 其类型转期型

:原变量date1期型,

date1=date

obj=replace(cstr(date1),"-","/")

obj要格式.

另外借用自定义函数转换.

Function FormatDate(sDateTime, sReallyDo)

Dim sJorkin

sJorkin = GetLocale()

If Not IsDate(sDateTime) Then sDateTime = Now()

sDateTime = CDate(sDateTime)

Select Case UCase(sReallyDo "")

Case "0", "1", "2", "3", "4"

FormatDate = FormatDateTime(sDateTime, sReallyDo)

Case "00"

FormatDate = FormatDate(sDateTime, "YYYY-MM-DD hh:mm:ss")

Case "01"

FormatDate = FormatDate(sDateTime, "YYYYMM月DD")

Case "02"

FormatDate = FormatDate(sDateTime, "YYYY-MM-DD")

Case "03"

FormatDate = FormatDate(sDateTime, "hh:mm:ss")

Case "04"

FormatDate = FormatDate(sDateTime, "hh:mm")

Case "ISO8601", "GOOGLE", "SITEMAP" '//ISO8601格式, 般用于GoogleSiteMap, "+08:00" 区.

FormatDate = FormatDate(sDateTime, "YYYY-MM-DDThh:mm:ss.000+08:00")

Case "RFC822", "RSS", "FEED" '//RFC822格式, 般用于RSS, "+0800" 区.

SetLocale("en-gb")

FormatDate = FormatDate(sDateTime, "ew, DD eMM YYYY hh:mm:ss +0800")

SetLocale(sJorkin)

Case "RND", "RAND", "RANDOMIZE" '//随机字符串

Randomize

sJorkin = Rnd()

FormatDate = FormatDate(sDateTime, "YYYYMMDDhhmmss") _

Fix((9 * 10^6 -1) * sJorkin) + 10^6

Case Else

FormatDate = sReallyDo

FormatDate = Replace(FormatDate, "YYYY", Year(sDateTime))

FormatDate = Replace(FormatDate, "DD", Right("0" Day(sDateTime), 2))

FormatDate = Replace(FormatDate, "hh", Right("0" Hour(sDateTime), 2))

FormatDate = Replace(FormatDate, "mm", Right("0" Minute(sDateTime), 2))

FormatDate = Replace(FormatDate, "ss", Right("0" Second(sDateTime), 2))

FormatDate = Replace(FormatDate, "YY", Right(Year(sDateTime), 2))

FormatDate = Replace(FormatDate, "D", Day(sDateTime))

FormatDate = Replace(FormatDate, "h", Hour(sDateTime))

FormatDate = Replace(FormatDate, "m", Minute(sDateTime))

FormatDate = Replace(FormatDate, "s", Second(sDateTime))

If InStr(1, FormatDate, "EW", 1) 0 Then

SetLocale("en-gb")

FormatDate = Replace(FormatDate, "EW", UCase(WeekdayName(Weekday(sDateTime), False)))

FormatDate = Replace(FormatDate, "eW", WeekdayName(Weekday(sDateTime), False))

FormatDate = Replace(FormatDate, "Ew", UCase(WeekdayName(Weekday(sDateTime), True)))

FormatDate = Replace(FormatDate, "ew", WeekdayName(Weekday(sDateTime), True))

SetLocale(sJorkin)

Else

FormatDate = Replace(FormatDate, "W", WeekdayName(Weekday(sDateTime), False))

FormatDate = Replace(FormatDate, "w", WeekdayName(Weekday(sDateTime), True))

End If

If InStr(1, FormatDate, "EMM", 1) 0 Then

SetLocale("en-gb")

FormatDate = Replace(FormatDate, "EMM", MonthName(Month(sDateTime), False))

FormatDate = Replace(FormatDate, "eMM", MonthName(Month(sDateTime), True))

SetLocale(sJorkin)

Else

FormatDate = Replace(FormatDate, "MM", Right("0" Month(sDateTime), 2))

FormatDate = Replace(FormatDate, "M", Month(sDateTime))

End If

End Select

End Function

%

'期格式化ISO8601格式

Response.Write(FormatDate("2008-03-06 08:03:06", "SITEMAP"))

'期格式化RFC822格式

Response.Write(FormatDate("2008-03-06 08:03:06", "RSS"))

'期格式化(英星期, 英月//)

Response.Write(FormatDate(Now(), "eW, EMM/DD/YYYY"))

'月秒随机数字符串

Response.Write(FormatDate(Now(), "RND"))

ISO 8601:时间和日期的表示标准

日期和时间的表示格式,有专门的标准,这里介绍 ISO 8601 。

内容主要是来自维基百科。

ISO 8601 是全世界日期和时间相关的数据交换的国际标准。这个标准的目标是在全世界范围的通信中提供格式良好的、无歧义的时间和日期表示。

总体来说, ISO 8601 涵盖了日期、时间(24小时格式,包含UTC时差)、时区、以及它们组合的表示描述。在这个标准中,日期和时间都不能够使用没有数字含义的单词表示(这样的话,中国农历中的生肖年是没法表示的)。

在 ISO 8601 的表示中,日期和时间按照这样的顺序排列:大的单位(比如年)放在左边,小的单位依次往右排列。表示只能由阿拉伯数字和指定的特殊字符(比如"-", ":", "T", "W", "Z")等组成,这样的话,日常常用的描述性的单词(比如"January", "Thursday", or "New Year's Day")是不允许使用的。

General principles

Date and time values are ordered from the largest to smallest unit of time: year, month (or week), day, hour, minute, second, and fraction of second. The lexicographical order of the representation thus corresponds to chronological order, except for date representations involving negative years or time offset. This allows dates to be naturally sorted by, for example, file systems.

Each date and time value has a fixed number of digits that must be padded with leading zeros.

Representations can be done in one of two formats – a basic format with a minimal number of separators or an extended format with separators added to enhance human readability.

(year, month, week, and day) is the hyphen, while the colon is used as the separator between time values (hours, minutes, and seconds). For example, the 6th day of the 1st month of the year 2009 may be written as "2009-01-06" in the extended format or simply as "20090106" in the basic format without ambiguity.

For reduced precision, any number of values may be dropped from any of the date and time representations, but in the order from the most to the least significant. For example, "2004-05" is a valid ISO 8601 date, which indicates May (the fifth month) 2004. This format will never represent the 5th day of an unspecified month in 2004, nor will it represent a time-span extending from 2004 into 2005.

If necessary for a particular application, the standard supports the addition of a decimal fraction to the smallest time value in the representation.

整体用4位数字表示年份,如果要表示公元前的年份,需要在四位数字前面再加一个正负号表示。格式如下:

格式如下:

格式:

格式:

格式为:

时区修饰符有三种形式:什么都不加,表示本地时间;加Z后缀表示UTC时间;也可以加一个标识和UTC时间的时区偏移。格式如下:

时间和日期的组合可以表示为:

格式:

格式:

格式:

关于javaiso8601和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

发布于 2023-04-03 05:04:57
收藏
分享
海报
36
目录

    忘记密码?

    图形验证码

    复制成功
    微信号: cloud7591
    如需了解更多,欢迎添加客服微信咨询。
    我知道了