datetime-format

How to show Firestore serverTimestamp correctly depending on local

北慕城南 提交于 2019-12-11 14:20:57
问题 I cant get this right and wonder how to show the Firestore FieldValue.serverTimestamp() formatet individual depending on what local the device has. The Firestore timestamp look like this Sat Mar 10 19:42:32 GMT+01:00 2018 try { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS", Locale.getDefault()); Date parsedDate = dateFormat.parse("Sat Mar 10 19:42:32 GMT+01:00 2018"); txtCreationDate.setText(new Date(parsedDate.getTime()).toString()); } catch (ParseException e)

Scala, SQL Server - How to insert the current timestamp as datetime in SQL server using Scala?

删除回忆录丶 提交于 2019-12-11 12:50:11
问题 I want to insert the current timestamp as datetime data type into sql server using Scala. So far I have tried this: import java.time.LocalDateTime import java.time.format.DateTimeFormatter var currentTimeStamp = LocalDateTime.now() val datetimeFormat = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm a") var insertTimestamp = currentTimeStamp.format(datetimeFormat) myInsertStatement.setInt(1, insertTimestamp) This gives me insertTimestamp in the format "MM/dd/yyyy HH:mm a" but this is a string.

Compare and filter data with date in MM/DD/YYYY format from current date using using new Date() while subtracting new Date() from user input value

时光怂恿深爱的人放手 提交于 2019-12-11 09:36:16
问题 Trying to compare the new Date(today's date) in 2015-02-21T21:48:48.137Z format with date in MM/DD/YYYY format which is my json data. I would like to filter all the data before today's days based on user input based on number of day's user enters(getting data before no certain number of days)..I can get the number of days and subtract it from todays date. Don't know how to compare this date with Json date value in MM/DD/YYYY format.Should i parse the Date() in order to compare with JSON data

Transform chr into date format for scale_x_date (ggplot2)

守給你的承諾、 提交于 2019-12-11 08:38:41
问题 I'm trying to plot 'time of day' per week during 2000-2011. This is a follow-up to my earlier question Aggregating mean “%H%M” in “week” I would like to be able to use scale_x_date of ggplot2, but I'm having a hard time to transform my Group.1 chr which is %W/%g back to a Date format to be able to use this particular scale. I have tried a few different things, including the script below, but I don't end-up with what I am expecting...? out$Group.1<-as.Date(out$Group.1, "%W/%g") out$Group.1 [1]

DateTime Asp.NET

ε祈祈猫儿з 提交于 2019-12-11 08:22:26
问题 I'm trying to save a date in database with ASP.NET. The datatype of Date in the database is datetime . I want to save it as for example (23/02/2014 00:00:00) That is, I want to save Date, Month and Year, and then have time always be 00:00:00. I also want to have zeros before month and/or day when they are only one number. e.g. 02/06/2014 instead of 2/6/2014. This is possible when the datatype is varchar but how would I do this when the datatype is datetime ? 回答1: dateTime.ToString("dd/MM/yyyy

Changing time and dateformat to show correct format on shiny dashboard

女生的网名这么多〃 提交于 2019-12-11 08:11:11
问题 I've build this dashboard with multiple date and time columns however in the dashboard the "T" and "Z" popup in the display Any ideas on how to remove this? I tried as.character , as.factor , anytime but I'm not able to make it happen. Any other ideas are appreciated! 回答1: You can parse it in base R or with lubridate : tz <- Sys.timezone() date1 <- "2015-03-23T13:23:20Z" # With {base} strptime(date1, tz = tz, format = "%Y-%m-%dT%H:%M:%OSZ") [1] "2015-03-23 13:23:20 CET" #With lubridate

How to get Date in UTC+0 in Java?

一曲冷凌霜 提交于 2019-12-11 07:37:43
问题 I am using the following code to get the date in ISO-8601 format. For UTC the value returned does not contain offset. OffsetDateTime dateTime = OffsetDateTime.ofInstant( Instant.ofEpochMilli(epochInMilliSec), zoneId); return dateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); For other time formats the response returned looks like: 2016-10-30T17:00:00-07:00 In case of UTC the value returned is: 2016-10-30T17:00:00Z I want it to be: 2016-10-30T17:00:00+00:00 Note: Do not use UTC-0 as -00

Why does Google API set +01 offset no matter input?

…衆ロ難τιáo~ 提交于 2019-12-11 07:05:23
问题 I'm using Google's API Explorer for their Calendar API on this page. I am inserting an event { "end": { "dateTime": "2016-10-31T06:30:00Z" }, "start": { "dateTime": "2016-10-31T06:00:00Z" } } and have tried the following datetime formats: 2016-10-31T06:00:00Z 2016-10-31T06:00:00-00:00 2016-10-31T06:00:00+00:00 But no matter input format, Google chooses to add an hour when setting the datetime. The response is always: "start": { "dateTime": "2016-10-31T07:00:00+01:00" } I'm currently in

`DateTimeFormatter` to handle either a FULL STOP or COMMA in fractional second

自作多情 提交于 2019-12-11 06:40:59
问题 In the java.time classes, how do we specify a formatting pattern for a DateTimeFormatter that allows for either a FULL STOP ( . ) (period or dot) or a COMMA ( , ) as the delimiter of a fractional second? For example, the following works for parsing an input date value ending in either .0Z or ,0Z in 20090813145607.0Z and 20090813145607,0Z . String input = "20090813145607.0Z"; DateTimeFormatter f = DateTimeFormatter.ofPattern ( "uuuuMMddHHmmss[,S][.S]X" ); But for printing, the output contains

How to display Date like device date time format in Android

眉间皱痕 提交于 2019-12-11 06:19:55
问题 I have a date: var date = new DateTime(2017,6,14,13,0,0); and a textview to display it. I'd like to display as ' 14/06/2017 13:00 ' when I set Date and time of the device to ' Use 24-hour format ' and ' 16/06/2017 1:00 PM ' when I un-check ' Use 24-hour format '. How can I do? Thank you! 回答1: On Xamarin.Android it is a bit different than on Android as described in Muhammads answer: var date = new DateTime(2017, 6, 14, 13, 0, 0); var is24hour = Android.Text.Format.DateFormat.Is24HourFormat