date

Date and time in Android studio (Kotlin language)

|▌冷眼眸甩不掉的悲伤 提交于 2020-06-12 03:30:10
问题 My friends and I are developing an app in android studio using Kotlin. We are quite new in app development but we have decent prior programming skills. For one of our functionalities we need to get current date and time. We tried all kinds of imports and methods, but none seem to work with SDK lower than 26. With our app we target devices with minimum API 19. For example: package hr.com.wap.wap import android.support.v7.app.AppCompatActivity import android.os.Bundle import kotlinx.android

How to obtain CURDATE() / NOW() on a JPA named query?

為{幸葍}努か 提交于 2020-06-11 16:49:45
问题 I want to do a select from table where date = TODAY, on mysql that would be where date > CURDATE() , how do I do this on a JPA named query? 回答1: That depends on your JPA provider. Hibernate, for example, supports current_date() function: from MyEntity where myDateProperty > current_date() 回答2: From the spec: 4.6.16.3 Datetime Functions functions_returning_datetime:= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP The datetime functions return the value of current date, time, and timestamp on

Format a Date and returning a Date, not a String

北城余情 提交于 2020-06-11 07:38:05
问题 I need to get the Date of the current time with the following format "yyyy-MM-dd'T'HH:mm:ss" SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); I know how to format a Date using SimpleDateFormat. At the end I get a String. But I need to get the formatted Date, not String, and as far as I know, I cannot convert back a String to a Date, can I? If I just return the Date, it is a Date but it is not properly formatted: Timestamp ts = new Timestamp(new Date().getTime()); EDIT:

Get ISO string from a date without time zone

北城余情 提交于 2020-06-10 02:24:09
问题 My configuration is Lisbon time zone. When I do new Date() I get my current local date/time which is Fri Apr 28 2017 01:10:55 GMT+0100 (GMT Daylight Time) When I get the ISO string with toISOString() it will apply the time zone and I will get: 2017-04-28T00:10:55.964Z The problem is that some minutes ago the date time was like this (yesterday): 2017-04-27T23:45:05.654Z I tried moment.js (new to this) and I did something like this document.write(moment('2017-04-28').format()) But I get this

Displaying Room availability for a date range in SQL and PHP [duplicate]

人盡茶涼 提交于 2020-06-09 05:39:39
问题 This question already has answers here : When to use single quotes, double quotes, and backticks in MySQL (12 answers) Reference - What does this error mean in PHP? (36 answers) Closed 13 days ago . I am trying to display the results of a search query, which is supposed to display available rooms at a hotel between a date range. Ideally, the results from roomsearchTEST.php should display at the table at the bottom of searchavailabiltyTEST2.php (table id="tblrooms"). Currently nothing is

adding and substracting time in Javascript

…衆ロ難τιáo~ 提交于 2020-06-09 05:38:09
问题 I'm trying to add five minutes to the current time using milliseconds and am baffled why adding and subtracting give such different results: const now = new Date(); const gimmeFive = now + 300000; const takeFive = now - 300000; Respectively give: "Sun May 31 2020 23:06:48 GMT+0100 (British Summer Time)300000" 1590962508207 Why does subtraction work, but not addition? How can I add time? Added clarification per stack overflow prompt: while the Q here overlapped with Add 10 seconds to a Date,

Get the local date instead of UTC

纵饮孤独 提交于 2020-06-09 05:26:07
问题 The following script calculates me next Friday and next Sunday date. The problem : the use of .toISOString uses UTC time. I need to change with something that outputs local time. I'm very new to javascript so I can't find the right property to use instead of .toIsostring. What should I do ? function nextWeekdayDate(date, day_in_week) { var ret = new Date(date || new Date()); ret.setDate(ret.getDate() + (day_in_week - 1 - ret.getDay() + 7) % 7 + 1); return ret; } let nextFriday =

Date range by week number Golang

左心房为你撑大大i 提交于 2020-06-08 17:13:26
问题 With this simple function, I can get the week number. Now, with the number of the week, how can I get the date range, started on Sunday? import ( "fmt" "time" ) func main() { Week(time.Now().UTC()) } func Week(now time.Time) string { _, thisWeek := now.ISOWeek() return "S" + strconv.Itoa(thisWeek) } Any help is welcome. Thank you. 回答1: Foreword: Time.ISOWeek() returns you the week number that starts on Monday, so I will answer your question that also handles weeks starting on Monday. Alter it

Change date format dd-MM-yyyy to yyyy-MM-dd in Java [duplicate]

喜夏-厌秋 提交于 2020-06-08 13:47:51
问题 This question already has answers here : Change date format in a Java string (18 answers) Closed 2 years ago . I was trying to convert date string 08-12-2017 to 2017-12-08(LocalDate). Here is what I tried- String startDateString = "08-12-2017"; LocalDate date = LocalDate.parse(startDateString); System.out.println(date); Also tried using formatter, but getting same result, an DateTimeParseException. How can I get an output like 2017-12-08, without getting an exception? 回答1: Try this (see

Calculate days, hours and minutes between two instants

筅森魡賤 提交于 2020-06-08 10:12:47
问题 I have an instant formatted like this: DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT ) .withLocale( Locale.UK ) .withZone( ZoneId.of("UTC")); String instant = formatter.format(Instant.now()).toString(); and i want to calculate the days, hours and minutes (if possible) between the instant and Instant.now(), something like: // for days String daysBetween = Instant.now() - instant; can i do that ? 回答1: To calculate days , hours and/or minutes between two