date

NLS_DATE_FORMAT with JDBC

和自甴很熟 提交于 2021-02-16 19:00:40
问题 I tried to set NLS_DATE_FORMAT inside jdbc, it didn't seem to have any effect. My code : //... Connection conn = ods.getConnection(); Statement stat = conn.createStatement(); stat.execute("alter session set NLS_DATE_FORMAT='YYYY-DD-MM'"); ResultSet rs = stat.executeQuery("select date_column from test_table"); System.out.println(rs.getString(1)); // *** new format not effective here *** //... After some reading. I understand that NLS_DATE_FORMAT is hard coded in JDBC Drivers. is this correct ?

java.time DateTimeFormatter pattern for timezone offset

余生长醉 提交于 2021-02-16 04:19:49
问题 I am trying to parse: 2014-05-02-10.45.05.993280-5:00 where the -5:00 is the offset from UTC. Using a java.time DateTimeFormatter in Java 8. For the first bit I have the following: yyyy-MM-dd-HH.mm.ss.SSSSSS however, I can't figure out what the pattern should be to parse the offset also. If I had the offset with 4 digits (-05:00) I could use: yyyy-MM-dd-HH.mm.ss.SSSSSSxxx , but this doesn't work for 3 digits. Any ideas? 回答1: Use capital letter X instead of x, hence XXX. The difference is that

Convert “Jan.2008” to date variable

别来无恙 提交于 2021-02-16 04:07:30
问题 How would I convert the following character variables to dates? strDates <- c("Jan.2008", "Feb.2008") str(strDates) chr [1:2] "Jan.2008" "Feb.2008" dates <- as.Date(strDates, "%b %Y") str(dates) Date[1:2], format: NA NA Any assistance would be greatly appreciated 回答1: A Date requires a day element as well, so you can add that to the input string with paste : full.dates <- paste("01", strDates, sep = ".") Specify the template correctly, including separator tokens: as.Date(full.dates, "%d.%b.%Y

Convert “Jan.2008” to date variable

一曲冷凌霜 提交于 2021-02-16 04:04:46
问题 How would I convert the following character variables to dates? strDates <- c("Jan.2008", "Feb.2008") str(strDates) chr [1:2] "Jan.2008" "Feb.2008" dates <- as.Date(strDates, "%b %Y") str(dates) Date[1:2], format: NA NA Any assistance would be greatly appreciated 回答1: A Date requires a day element as well, so you can add that to the input string with paste : full.dates <- paste("01", strDates, sep = ".") Specify the template correctly, including separator tokens: as.Date(full.dates, "%d.%b.%Y

Safe handling of daylight savings (or any other theoretical non-constant offset) while calculating durations between DateTimes

眉间皱痕 提交于 2021-02-15 07:33:30
问题 I know this isn't the first time this topic has been brought up even in the past 24 hours, but I'm surprised that I have not come across one clear / best practices solution to this problem. The problem also seems to contradict what I thought was a no-brainer design decision to save all dates in UTC. I'll try to state the problem here: Given two DateTime objects, find the duration between them while accounting for daylight savings. Consider the following scenarios: UtcDate - LocalDate where

How do I include a timezone in my d3 time formatted data?

我是研究僧i 提交于 2021-02-13 17:26:49
问题 I"m using d3 v4. My x-axis data consists of time in milliseconds (since 1970). I would like to display this as eastern standard time, for example 08/09/17 5:20 PM EDT so I tried focus.select("text").text(d.value).append("tspan") .attr("x", 10).attr("dy", "1.5em").text(d3.timeFormat("%m/%d/%Y %H:%M %p %Z+5")(d.index_date)); but unfortunately it is instead displaying as 08/09/17 5:20 PM -0500 +% What's the proper way to format the date/time as EDT (US Eastern standard time)? 回答1: D3 v4 time

BASH: How to find no. of days (considering only “Network / Business Days”) between two dates (i.e. exclude weekends Saturday/Sunday)

蹲街弑〆低调 提交于 2021-02-12 11:33:30
问题 RHEL 7.5 BASH GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) In MS Excel , I'm able to use Network days to find no. of days between two dates. Wondering if it's possible using bash as first preference (--or any other pre-installed language on Linux supporting to solve this possibly using a one-liner - my second preference). I'm not sure if there exists any library or custom tool/utility in Linux which calculates this value. To calculate the number of workdays between two dates,

BASH: How to find no. of days (considering only “Network / Business Days”) between two dates (i.e. exclude weekends Saturday/Sunday)

半城伤御伤魂 提交于 2021-02-12 11:33:18
问题 RHEL 7.5 BASH GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) In MS Excel , I'm able to use Network days to find no. of days between two dates. Wondering if it's possible using bash as first preference (--or any other pre-installed language on Linux supporting to solve this possibly using a one-liner - my second preference). I'm not sure if there exists any library or custom tool/utility in Linux which calculates this value. To calculate the number of workdays between two dates,

Count consecutive days by group

人走茶凉 提交于 2021-02-11 17:51:09
问题 I am looking to add a field that counts the number of consecutive days within each group (captured by id field). I start with this: dt <- structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), date = c("1/01/2000", "2/01/2000", "2/01/2000", "5/01/2000", "6/01/2000", "7/01/2000", "8/01/2000", "13/01/2000", "14/01/2000", "18/01/2000", "19/01/2000", "21/01/2000", "25/01/2000", "26/01/2000", "30/01/2000", "31/01/2000")), .Names = c("id", "date"), row.names = c(NA,

Error writing java.util.date into Json file

邮差的信 提交于 2021-02-11 16:31:40
问题 I have a Json writer class EntrenadorWriter that writes the entity data produced from a RestFul service into a Json file. Then, the file is consumed by Json reader class. One of the fields that has to be written into the Json is a Java.util.Date Date. But I'm having serious trouble to write-read the Date. WriteTo method from Json writer class: @Override public void writeTo(Usuario t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object>