date-formatting

date format with timezone

北城余情 提交于 2021-02-19 07:07:50
问题 How do I format a date in python to look like this: weekday:month:day(number):HH:MM:SS(military):EST/CST/PST:YYYY ? I am familiar with strftime(), but I am unsure how I would handle the HH:MM:SS and EST/CST/PST. example of how I am trying to get the date to look: Sun Mar 10 15:53:00 EST 2013 回答1: Use strftime to output a formatted string representation: print time.strftime("%a %b %d %H:%M:%S %Z %Y") A list of the format codes can be found here 回答2: from time import gmtime, strftime print

date format with timezone

独自空忆成欢 提交于 2021-02-19 07:07:49
问题 How do I format a date in python to look like this: weekday:month:day(number):HH:MM:SS(military):EST/CST/PST:YYYY ? I am familiar with strftime(), but I am unsure how I would handle the HH:MM:SS and EST/CST/PST. example of how I am trying to get the date to look: Sun Mar 10 15:53:00 EST 2013 回答1: Use strftime to output a formatted string representation: print time.strftime("%a %b %d %H:%M:%S %Z %Y") A list of the format codes can be found here 回答2: from time import gmtime, strftime print

How do I change the default NLS parameters for date format through Toad?

江枫思渺然 提交于 2021-02-11 15:27:36
问题 I have a NLS date format as DD-MON-RR. This gives me the underlying date format as YY while I want to change it to YYYY. I tried using the following query and it ran successfully DECLARE v_date DATE := sysdate; BEGIN DBMS_OUTPUT.put_line(TO_CHAR(v_date, 'MM/DD/YYYY')); END; But that didn't change the default format. for some context, I am trying to import data from Oracle to Tableau. Unfortunately when I try to export a crosstab from Tableau server it looks at the underlying data rather than

Java DateFormat: How to deal with “st”, “nd”, “rd”, “th”?

百般思念 提交于 2021-02-07 07:46:12
问题 How can I parse a string like this using some DateFormat? Wednesday, 24th July As far as I can tell there's nothing in SimpleDateFormat . 回答1: try this String str = "Wednesday, 24th July"; str = str.replaceAll("(\\d\\d)..", "$1") + " " + Calendar.getInstance().get(Calendar.YEAR); Date date = new SimpleDateFormat("EEEE, dd MMMM yyyy", Locale.US).parse(str); 回答2: Any literals that are not part of the DateFormat parser can be placed between ' . Like 'th', 'T','nd','st' 回答3: Best idea I have on

Java 8 LocalDate.plusMonths is adding to days and months

喜夏-厌秋 提交于 2021-02-05 11:39:21
问题 I'm getting strange formatting issue when adding months to a LocalDate. Here is the Scala code and output: val virtualToday: LocalDate = LocalDate.parse("2015-01-01") val eightDaysFromToday: LocalDate = virtualToday.plusDays(8) val sixMonthsFromToday: LocalDate = virtualToday.plusMonths(6) println("virtualToday " + virtualToday) println("eightDaysFromToday " + eightDaysFromToday) println("sixMonthsFromToday " + sixMonthsFromToday) println( "virtualToday with formatting " + virtualToday

How to use a specific GMT for a function which will be recognised by other time zones

主宰稳场 提交于 2021-02-05 08:33:36
问题 I imagine there's a simple way to do this, I just haven't figured it out yet. I want to display a button only between 9am to 12pm AEST (GMT+10). So for a user in AWST (GMT+8), they will not be able to see the button when it is 11am for them. I have the specific time I want to use let date = Date() let dateFormatterTime = DateFormatter() dateFormatterTime.dateFormat = "HH:mm:ss" dateFormatterTime.timeZone = TimeZone(secondsFromGMT: 36000) let sydneyTime = dateFormatterTime.string(from: date)

How to use a specific GMT for a function which will be recognised by other time zones

。_饼干妹妹 提交于 2021-02-05 08:33:28
问题 I imagine there's a simple way to do this, I just haven't figured it out yet. I want to display a button only between 9am to 12pm AEST (GMT+10). So for a user in AWST (GMT+8), they will not be able to see the button when it is 11am for them. I have the specific time I want to use let date = Date() let dateFormatterTime = DateFormatter() dateFormatterTime.dateFormat = "HH:mm:ss" dateFormatterTime.timeZone = TimeZone(secondsFromGMT: 36000) let sydneyTime = dateFormatterTime.string(from: date)

OffsetDateTime is not showing milisecond if the string contains 000 [duplicate]

你。 提交于 2021-01-29 08:52:23
问题 This question already has answers here : Convert JAXBElement<XMLGregorianCalendar> to OffsetDateTime (1 answer) Parsing timestamp as LocalDateTime (2 answers) Closed 7 months ago . I have a string "2020-03-25T22:00:00.000Z" which i want to convert to OffsetDateTime. Below is the code I tried but when I pass milisecond as 000 then it is not reflecting in OffsetDateTime. OffsetDateTime offsetDateTime=OffsetDateTime.parse("2020-03-25T22:00:01.123Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME); print

How to get correct output of hour: “2-digit” for toLocaleString(“en-US”) with AM/PM?

自古美人都是妖i 提交于 2021-01-28 11:50:17
问题 According to the toLocaleString() MDN Documentation the option hour: "2-digit" should return a 2 digit representation of the hour, but it returns only 1 digit if the locale is en-US and the format is AM/PM . (Update: AM/PM mention) let d = new Date("2019-05-03 15:00:00").toLocaleString("en-US", {hour: "2-digit", minute: "2-digit"}); console.log(d); Is there a workaround or another easy way to get the 2-digit hour for the US locale, displaying the AM and PM? 回答1: You just have to explicitly

How to use unsupported Locale in Java

江枫思渺然 提交于 2020-12-19 04:16:33
问题 As part of Internationalisation, got a requirement to support few countries like Antigua and Barbuda - ISO3166 code - AG & Dominican Republic - ISO3166 code - DO Locale loc = new Locale("en", "AG"); DateFormat df1 = DateFormat.getDateInstance(DateFormat.SHORT, loc); System.out.println("Short format: " + df1.format(new Date())); Java will display date in format mm/dd/yy, where as date format in those countries are dd/mm/yy. Is there any way we can achieve the pattern dd/mm/yy? Even ICU4J