datetime-format

java.text.ParseException while trying to parse a date in java

一笑奈何 提交于 2019-12-24 14:01:54
问题 I can not parse the string "16 Apr 2014 17:00" as a string. I've trying to use DateUtils in apachecommons library. here is the test code with the exception package com.buraktas; import java.text.ParseException; import java.util.Date; import org.apache.commons.lang3.time.DateUtils; import org.junit.Test; public class ParseDateTest { @Test public void test() throws ParseException { String date = "18 Apr 2014 20:00"; Date parseDate = DateUtils.parseDate(date, "dd MMM yyyy HH:mm"); System.out

How to save DateFormat with SharedPreferences in Flutter?

强颜欢笑 提交于 2019-12-24 10:57:53
问题 I tried to count the number of pressed button for each hours. To do this When I pressed the button, I save the current time in a variable to have a reference of the hours of the pressed button, if I press a second time the button, I want to compare the current time with the previous time saved to know if the hours has changed. If there is a different time I reset the counter to 0, else I increase the counter. Like this I can know how much I pressed the button for each hours. There may be a

Remove 0, if return 0 year or 0 month DateFormat

非 Y 不嫁゛ 提交于 2019-12-24 09:51:07
问题 $createdTime = Carbon::parse($specialist->created_at) ->diff(Carbon::now()) ->format('%y yr, %m mo and %d days'); This returns 0 yr, 0 mo and 8 days . I want to return only 8 days . Or if 1 yr, 0 mo and 8 days , return 1 yr and 8 days 回答1: Since diff() returns a DateInterval instance you could run conditional checks to get your expected result. $createdTime = Carbon::parse($specialist->created_at) ->diff(Carbon::now()); $final_string = ''; $year = ''; $month = ''; $days = ''; if ($createdTime

How use the function NOW() in PHP

柔情痞子 提交于 2019-12-24 07:32:55
问题 I have a temporary table SQL. I have a filed that give me the name of the user that modified any information by get_current_user . I added another field type=DATETIME to recovre the date and the hour of the user modifcation. In PHP I added it like all my function, but it got an error. The code is the following: $sql = "INSERT INTO `...`.`correspondants_bis` (`code_client` , `name`, `surname` ,`phone`, `fax`, `email`, `added_by`, `Date`, `condition`) VALUES ('" . $correspondent->getCodeClient(

# How to use the DateTime class (Dealing with Conversions, Formatting, Diffs, and Time zones) [duplicate]

戏子无情 提交于 2019-12-24 06:47:43
问题 This question already has answers here : Convert one date format into another in PHP (15 answers) How to calculate the difference between two dates using PHP? (32 answers) Timezone conversion in php (8 answers) Adding three months to a date in PHP (10 answers) Closed 11 months ago . Everyone has to deal with date/time formatting, time zones, weird time formats, etc. at some point in programming. PHP has few ways to deal with these problems, the most notable of which is PHP's built in DateTime

Extract timezone from ISO8601 date time string

牧云@^-^@ 提交于 2019-12-24 06:00:36
问题 How to extract time zone from ISO-8601 date string in Java 8. e.g: String timestamp1 = "2014-02-15T01:02:03Z" ; String timestamp2 = "2017-10-27T16:22:27.605-05:30"; Thanks. 回答1: Use ZonedDateTime: ZonedDateTime.parse("2017-10-27T16:22:27.605-05:30").getZone() to get an instance of ZoneId. Alternatively you can use getOffset() to obtain ZoneOffset,which is more handy if you need to access the timezone offset in a numeric form. 来源: https://stackoverflow.com/questions/46216099/extract-timezone

Unable to convert varchar to datetime in MySql

大憨熊 提交于 2019-12-24 03:29:38
问题 In my MySql table there's a column called _time of type varchar. The values it holds are in the format: year month day hour minute without the whitespaces: 201409201945 I want to convert it to datetime so I'm doing this: ALTER TABLE `my_table` CHANGE COLUMN `_time` `date_time` DATETIME NOT NULL; And it throws this error for some reason: Error Code: 1292. Incorrect datetime value: '201409201945' for column '_date_time' at row 1 0.036 sec 回答1: The three steps @Arkain mentioned would be with the

How to get the data time pattern with time zone based on the locale?

痞子三分冷 提交于 2019-12-24 02:16:04
问题 The following code is what I already have: DateFormat f = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Java_Locale); SimpleDateFormat sf = (SimpleDateFormat) f; String pattern = sf.toPattern(); With the above code, I am able to get the PROPER date/time pattern based on the locale. For example: "M/d/yy h:mm a" for US English, "yy-M-d ah:mm" for Chinese. However, this pattern does not have the time zone information. I hope to be able to add time zone into the pattern. For

Azure Data Factory : querying _ts (epoch) field in CosmosDB source

孤街浪徒 提交于 2019-12-24 01:07:29
问题 I am trying to copy data from Azure CosmosDB into Azure SQL Database. In the Azure CosmosDB source, the query is as follows : select * from c where c.DefinitionTime >= '@{formatDateTime(pipeline().parameters.windowStart, 'yyyy-MM-ddTHH:mm:ssZ' )}' AND c.DefinitionTime < '@{formatDateTime(pipeline().parameters.windowEnd, 'yyyy-MM-ddTHH:mm:ssZ' )}' In CosmosDB, "DefinitionTime" is stored as a string. To the run the above query, I have to update "DefinitionTime" with range-indexing which is one

How to change format from 12hrs to 24 hrs in html5 datetime picker?

怎甘沉沦 提交于 2019-12-24 00:29:02
问题 I am using datetime picker from Html5. <input id="datetime" type="datetime-local"> But It is containing 12 Hrs time with A.M or P.M, But I want to set 24 hrs place of A.M, P.M. I am refering this link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local My problem is only I want to set 24 hrs in time. 回答1: You can use input type="time" but It depends on the time format of the user's operating system when the web browser was launched. You can change your OS time