草庐IT

UTC_TIMESTAMP

全部标签

ios - Firebase:由 FIRServerValue.timestamp() 创建的下载时间戳与在线版本略有不同

我注意到由FIRServerValue.timestamp()创建的对象的下载时间戳与在线版本略有不同。我的代码:letmessagesRef=self.ref.child("messages").child(chatId)messagesRef.queryOrderedByChild("timestamp").queryLimitedToLast(500).observeEventType(.ChildAdded,withBlock:{(snapshot)->Voidinguardletobject=snapshot.valueas?[String:AnyObject]else{re

swift - 时间戳作为 "timestamp"保存到 Firestore 中是否正常?

我保存服务器值时间戳如下:letdata:[String:Any]=["userId":9,"name":"ElonMusk","timeCreated":ServerValue.timestamp()]letdoc=firestore.collection("orders").document()doc.setData(data){(error)in}在查看Firestore时,虽然我看到了这个:这正常吗?难道不应该有一个包含自Unix纪元以来的毫秒数的long吗? 最佳答案 您正在使用服务器时间戳的实时数据库概念,即Server

swift - swift语言中cloud Firestore server timestamp的等效数据类型是什么?

我有一个包含时间戳字段createdAt的数据模型。structBox{vartitle:StringvarcreatedAt:Timestampvardictionary:[String:Any]{return["title":title,"createdAt":createdAt]}//...但是,我无法分配Firestore服务器时间戳。swift中云Firestore服务器时间戳的等效数据类型是什么?我在这里漏掉了一点吗?letbox=Box(title:title,createdAt:FieldValue.serverTimestamp()); 最

java - 在 Java 中从毫秒转换为 UTC 时间

我正在尝试将毫秒时间(自1970年1月1日以来的毫秒数)转换为Java中的UTC时间。我已经看到很多其他使用SimpleDateFormat更改时区的问题,但我不确定如何将时间转换为SimpleDateFormat,到目前为止我只知道如何将它转换为字符串或日期.例如,如果我的初始时间值为1427723278405,我可以使用Stringdate=newSimpleDateFormat("MMMddhh:mm:sszyyyy",Locale.ENGLISH).format(newDate(epoch));或Dated=newDate(epoch);但每当我尝试将其更改为SimpleDat

java - ZonedDateTime 比较 : expected: [Etc/UTC] but was: [UTC]

我正在比较两个看似相等的日期,但它们包含不同名称的时区:一个是Etc/UTC,另一个是UTC。根据这个问题:IsthereadifferencebetweentheUTCandEtc/UTCtimezones?-这两个区域是相同的。但是我的测试失败了:importorg.junit.Test;importjava.sql.Timestamp;importjava.time.ZoneId;importjava.time.ZonedDateTime;importstaticorg.junit.Assert.assertEquals;publicclassTestZoneDateTime{@

Java ResultSet 如何在 UTC 中获取时间戳

数据库中有UTC数据,当我尝试获取数据时java.util.Calendarcal=Calendar.getInstance();cal.setTimeZone(TimeZone.getTimeZone("UTC"));java.sql.Timestampts=resultSet.getTimestamp(PUBLISH_TIME);cal.setTime(ts);这有什么问题吗? 最佳答案 java.util.Calendarcal=Calendar.getInstance();cal.setTimeZone(TimeZone.g

java - 如何从日历中获取 UTC 时间戳?

在Java中,当我使用Calendar.getInstance();时,我得到了当前时区的Calendar对象。但是java.sql.Timestamp通常以UTC时间存储,而不是本地时间。那么如何从Calendar实例中获取UTC时间呢?DateFormatdf=DateFormat.getTimeInstance();Calendarcal=Calendar.getInstance();Timestamptime=newTimestamp(cal.getTimeInMillis());//PrintslocaltimeSystem.out.println(df.format(new

java - 考虑到新引入的闰秒,一个 1 岁的(java)库如何正确执行 UTC 时间格式

自1.1.1970UTC以来以毫秒表示的时间戳是存储时间戳的常用方法,例如在Java中。例如:longtimestampUtc=System.currentTimeMillis();这样的时间戳可以用人类可读的时间格式来格式化,例如使用这段代码SimpleDateFormatdf=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss",Locale.US);df.setTimeZone(TimeZone.getTimeZone("UTC"));StringhumanTimeUtc=df.format(newDate(timestampUtc));System.

java - 如何使用 java.sql.Timestamp 作为真正的 java.util.Date 与 JPA

我对以毫秒为单位的日期管理有疑问。我理解需要使用TIMESTAMP来存储毫秒数:@Temporal(TIMESTAMP)@Column(name="DATE_COLUMN",nullable=false)@Overridepublicjava.util.DategetDate(){returnthis.date;}但是如果我无法将这个日期与另一个java.util.Date实例进行比较,除非我注意equals()调用的顺序,因为this.date实例是一个java.sql.时间戳。如何从JPA获取java.util.Date?因为来自JPA的日期,即使方法签名是一个java.util.

java - 甲骨文/JDBC : retrieving TIMESTAMP WITH TIME ZONE value in ISO 8601 format

关于该主题的某些部分已经说了很多(并写了SO),但不是全面、完整的方式,所以我们可以有一个“终极、全面”的解决方案供每个人使用。我有一个Oracle数据库,我在其中存储全局事件的日期+时间+时区,因此必须保留原始TZ,并根据要求交付给客户端。理想情况下,它可以通过使用标准ISO8601“T”格式很好地工作,这种格式可以使用“TIMESTAMPWITHTIMEZONE”列类型(“TSTZ”)很好地存储在Oracle中。类似'2013-01-02T03:04:05.060708+09:00'我需要做的就是从数据库中检索上述值并将其发送给客户端,无需任何操作。问题是Java缺乏对ISO860