date-format

Is Joda-Time DateTimeFormatter class thread safe?

China☆狼群 提交于 2019-11-28 20:01:24
Is the Joda-Time DateTimeFormatter class thread safe ? Once I get an instance from DateTimeFormat.forPattern , can its various parse methods be called by multiple threads? DateTimeFormatter's Javadocs makes no mention of thread safety. Erre Efe Yes, it is : DateTimeFormat is thread-safe and immutable, and the formatters it returns are as well. and so is the Java 8 version Implementation Requirements: This class is immutable and thread-safe. A quick look at the code shows there isn't any mutable shared state in DateTimeFormatter , which would make it thread safe. Found this question on top of

Java date format - including additional characters

雨燕双飞 提交于 2019-11-28 19:03:12
Is there an equivalent to php date() style formatting in Java? I mean, in php I can backslash-escape characters to have them treated literally. I.e. yyyy \y\e\a\r would become 2010 year . I did not find anything similar in Java, all examples deal only with built-in date formats. In particular, I deal with JCalendar date pickers and their dateFormatString property. I need it because in my locale it is required to write all sorts of additional stuff in date format, like d. (for day) after days part, m. (for years) after years part and so on. At the worst case I could use string replace or regexp

Parsing a String into Date with DateFormat not parsing correctly

穿精又带淫゛_ 提交于 2019-11-28 14:17:30
I've been searching all over and just can't find a explanation or reason why this is happening but the parse(String) method of DateFormat just isn't parsing my String correctly. I'm trying to parse a String into the date format that is used for HTTP headers and got as far as getting the String on its own such as: Thu, 11 Nov 2010 18:34:22 GMT Which is in the format: E, d MMM yyyy HH:mm:ss z But when I use df.parse(dateStr); this is what I get out of it: Thu Nov 11 18:34:22 GMT 2010 Which is nothing like what I wanted, why is the year now after the GMT? Why is there no comma anymore? And why is

Why does PowerShell always use US culture when casting to DateTime?

淺唱寂寞╮ 提交于 2019-11-28 13:18:24
When trying to read a CSV yesterday, I noticed that PowerShell seems to always assume US date format when using [datetime]"date" . My regional settings are all correct , and [DateTime]::Parse("date") uses the UK date format (dd/mm/yyyy). Is this a bug, or a deliberate decision ? If a deliberate decision, is this documented anywhere? PS D:\> [DateTime]"12/10/2012" 10 December 2012 00:00:00 PS D:\> [DateTime]::Parse("12/10/2012") 12 October 2012 00:00:00 (Note: on a US machine, I expect these objects will be the same, but not so here on my machines in the UK). Note: I don't want to change the

What is the best way to parse a date in MM/DD/YY format and adjust it to the current / previous century?

泄露秘密 提交于 2019-11-28 12:06:36
One of our customers wants to be able to enter a date with only 2 digits for the year component. The date will be in the past, so we want it to work for the previous century if the 2 digit year is after the current year, but work for the current century if the 2 digit year is equal to or less than the current year. as of today 10/30/2008 01/01/01 = 01/01/2001 01/01/09 = 01/01/1909 This is a strange requirement, and I solved the problem, I just don't like my solution. It feels like there is a better way to do this. Thanks for the help. public static String stupidDate(String dateString) { String

Alignment date parts in JTable column formatted in propotional font

ぐ巨炮叔叔 提交于 2019-11-28 11:55:53
问题 I need to make the date parts (dd, MMMM, yyyy) to be vertically aligned. I asked a question at Fixed length of month and day in date format? to insert padding letters, but I found that it doesn't help in case of proportional font (the width of the letters are different). For example, with Lucida Fax font: Making different labels for different date parts is considering but it's too manual. It's hard to make the text wrapped if the column width is small.... Thanks 回答1: note as for all Renderers

How to format a date with slashes in C# [duplicate]

我只是一个虾纸丫 提交于 2019-11-28 10:52:32
This question already has an answer here: why does DateTime.ToString(“dd/MM/yyyy”) give me dd-MM-yyyy? 5 answers When i write a date in C# by using DateTime.Now.ToString("yyyy/MM/dd") then it returns 2010-09-10 , but I need 2010/09/10 . How do I make it output slashes? Lasse Vågsæther Karlsen Specify a culture. Your current culture uses - for the separators, and that's what ToString defaults to (your current culture), unless you override it. You can try this: DateTime.Now.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture) but perhaps it would be better if you specified a different culture,

Convert date field to Quarter in R

淺唱寂寞╮ 提交于 2019-11-28 10:48:50
问题 I have data frame which has the date column in format 08/21/2000(m/d/Y) . Now I want to add new column which display the date in Quarter format that is 2000-Q3 . I install zoo package and used following command. but it is giving NA value. library(zoo) mydf$var9=as.yearqtr("mydf$Order.Date","%m/%d/%Y"). 回答1: The zoo library has created a set of functions to handle year-quarter vectors: library(zoo) mydf$var9=as.yearqtr(as.Date( mydf$Order.Date, "%m/%d/%Y" ). 来源: https://stackoverflow.com

Simple Oracle query: literal does not match format string

落爺英雄遲暮 提交于 2019-11-28 10:37:35
问题 I want to execute a simple function in Oracle. The signature is defined as follows: CREATE OR REPLACE FUNCTION NewCaseListForValidation ( p_fromDate in DATE, p_toDate in DATE, p_rowCount in INT ) RETURN SYS_REFCURSOR IS return_value SYS_REFCURSOR; ... I should be able to execute it with: var rc refcursor exec :rc := newcaselistforvalidation('2010-01-01','2011-01-01',100); print :rc But when typing "newcaselistforvalidation('2010-01-01','2011-01-01',100)", I get: ERROR at line 1: ORA-01861:

SimpleDateFormat and parsing: parse doesn't fail with wrong input string date

浪尽此生 提交于 2019-11-28 10:37:32
问题 I'm using java.util.Date date; SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); try { date = sdf.parse(inputString); } catch (ParseException e) { e.printStackTrace(); } where inputString is a string in the dd/MM/yyyy format. If the inputString is, for example, 40/02/2013, I would to obtain an error, instead the parse method returns the Date 12 March 2013 (12/03/2013). What I'm wronging? 回答1: Set the Leniency bit: public void setLenient(boolean lenient) Specify whether or not date