date

How to compare two java.time.Period in java 8?

半城伤御伤魂 提交于 2020-05-27 05:58:25
问题 How do I compare two Periods in java 8? E.g. Period one = Period.of(10,0,0); Period two = Period.of(8,0,0); here in this case one is greater than two. 回答1: It is true that the comparison of two Period objects does not make sense in a general case, due to the undefined standard length of a month. However, in many situations you can quite well live with an implementation similar to that which follows. The contract will be similar to the contract of compareTo() : public int

PHP string date + 1 day equals?

旧巷老猫 提交于 2020-05-26 10:28:51
问题 I have a date which is saved in a regular string. // format = DD-MM-YYYY $date = "10-12-2011"; How can I get the date-string +1 day so: 11-12-2011? 回答1: Similar post $date = date('d-m-Y', strtotime("+1 day", strtotime("10-12-2011"))); 回答2: If you're trying to overwrite $date, Aaron's answer works great. But if you need the new day saved into a separate variable as I did, this works: $date = strtotime('10-12-2011'); // your date $newDate = date('d-m-Y', strtotime("+1 day", $date)); // day

How to set time of java.util.Date instance to 00:00:00?

风流意气都作罢 提交于 2020-05-26 10:26:11
问题 I have a variable of the type java.util.Date . How can I set the time part to 00:00:00? I am not allowed to use an Apache Commons library or JodaTime. The java.util.Calendar is probably my only option. 回答1: To remove time from the Date object completely, you could use this: public static Date removeTime(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,

How to get time from YYYY-MM-dd'T'HH:mm:ss.sssZ

我与影子孤独终老i 提交于 2020-05-26 07:45:09
问题 Hi I want to get time as 11:40 from "2017-07-31T11:40:00.000Z" Below is the code I am using: let formatter = Foundation.DateFormatter() formatter.dateFormat = "YYYY-MM-dd'T'HH:mm:ss.sssZ" //2017-04-01T18:05:00.000 let date1 = formatter.date(from: data.arvTime) print("date:\(String(describing: date1))") let dateFormatterPrint = Foundation.DateFormatter() dateFormatterPrint.dateFormat = "HH:mm" let resultTime = dateFormatterPrint.string(from: date1!) print("time:\(String(describing: resultTime)

Pandas - Converting date column from dd/mm/yy hh:mm:ss to yyyy-mm-dd hh:mm:ss

岁酱吖の 提交于 2020-05-25 07:54:06
问题 I have a dataframe (df) that has a date column (column name : sale_date) that stores data in the below format dd/mm/yy hh:mm:ss I am trying to convert it to yyyy-mm-dd hh:mm:ss. Tried with the below but however it still does not convert it to the required format. df['sale_date'] = pd.to_datetime(df['sale_date']) Could anyone assist in converting the format of this date column. Thanks 回答1: If you know you will have a consistent format in your column, you can pass this to to_datetime : df['sale

Pandas - Converting date column from dd/mm/yy hh:mm:ss to yyyy-mm-dd hh:mm:ss

萝らか妹 提交于 2020-05-25 07:54:06
问题 I have a dataframe (df) that has a date column (column name : sale_date) that stores data in the below format dd/mm/yy hh:mm:ss I am trying to convert it to yyyy-mm-dd hh:mm:ss. Tried with the below but however it still does not convert it to the required format. df['sale_date'] = pd.to_datetime(df['sale_date']) Could anyone assist in converting the format of this date column. Thanks 回答1: If you know you will have a consistent format in your column, you can pass this to to_datetime : df['sale

pandas: subtracting current date from the date in a pandas table

限于喜欢 提交于 2020-05-23 17:47:24
问题 I am attempting to calculate the difference in days between todays and a pandas data consisting of historical data. Below is the intended code: df['diff'] = pd.to_datetime( df['date']) - pd.datetime.now().date() However, it produces the following error: TypeError: unsupported operand type(s) for -: 'DatetimeIndex' and 'datetime.date' The date column in the pandas table looks like this: 0 2018-12-18 1 2018-12-18 2 2018-12-18 3 2018-12-18 4 2018-12-18 How do I fix this error. Thanks in advance.

How to parse date string EEE MMM dd to yyyy-MM-dd in java [duplicate]

妖精的绣舞 提交于 2020-05-23 11:57:46
问题 This question already has answers here : Change date format in a Java string (18 answers) how to parse output of new Date().toString() (3 answers) Closed 8 months ago . I'm having the date in this pattern EEEEE MMMMM yyyy HH:mm:ss.SSSZ , I would like to convert this to yyyy-MM-dd format in java, I tried below approach but I'm getting this exception java.text.ParseException: Unparseable date: SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); String dateInString = "Sun Oct 01 00

How to parse date string EEE MMM dd to yyyy-MM-dd in java [duplicate]

不羁的心 提交于 2020-05-23 11:57:30
问题 This question already has answers here : Change date format in a Java string (18 answers) how to parse output of new Date().toString() (3 answers) Closed 8 months ago . I'm having the date in this pattern EEEEE MMMMM yyyy HH:mm:ss.SSSZ , I would like to convert this to yyyy-MM-dd format in java, I tried below approach but I'm getting this exception java.text.ParseException: Unparseable date: SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); String dateInString = "Sun Oct 01 00

SEARCH BEFORE/AFTER with Pythons imaplib

蹲街弑〆低调 提交于 2020-05-23 07:57:09
问题 I have a smaller IMAP-script written i Python(3.2). I my search-line looks like this: typ, data = M.search(None, 'FROM', '"MyName"') I get the expected results. However, if I change it to something like: typ, data = M.search(None, 'AFTER', '"01-Jan-2010"') (with or without quoted date, I get this error Traceback (most recent call last): File "./priv/imap.py", line 100, in <module> main() File "./priv/imap.py", line 93, in main print(to_json(fetch_result(M, args), args)) File "./priv/imap.py",