Grails dataBinding not working on default marshalled grails date - date

It seems that Grails by default is providing a date marshalled in JSON as "EEE MMM dd HH:mm:ss z yyyy" (e.g: Sat Jan 05 00:02:00 CET 2019)
If this (string) date is used in a domain creation activity (create an instance of the same domain class with this string-date as the date), Grails will not recognize it by default (although I think it should logically accept it).
Pooblem is that the Data Format "EEE MMM dd HH:mm:ss z yyyy" is not recognized in the
grails.databinding.dateFormats = [
'EEE MMM dd HH:mm:ss z yyyy',
'dd/MM/yyyy HH:mm:ss',
'dd/MM/yyyy',
'yyyy-MM-dd HH:mm:ss',
'yyyy-MM-dd HH:mm:ss.S',
"yyyy-MM-dd'T'hh:mm:ss'Z'",
'dd.mm.yyyy',
'MMddyyyy'
]
or in the #BindingFormat as well.
It looked like, to parse the 'EEE MMM dd HH:mm:ss z yyyy', the locale is also needed.
Something like:
def dateFormat = "EEE MMM dd HH:mm:ss z yyyy";
SimpleDateFormat smpDF= new SimpleDateFormat( dateFormat, Locale.UK );
Is there a way to pass the locate so grails binds this date as it is from the string?
Update: This is Grails 3.3.9

Related

Flutter custom date format

I am facing issue while formatting the date to custom format.
I need to convert date yyyy-MM-dd HH:mm:ss ===> EEEE, MMM dd, yyyy
For example I am getting date from server 27-10-2022 11:02:50, and I need to convert it to Thursday, October 27, 2022
Getting Date format is "dd-MM-yyyy HH:mm:ss" and the desire format will be "EEEE, MMMM dd, yyyy"
final data = "27-10-2022 11:02:50";
final format = DateFormat("dd-MM-yyyy HH:mm:ss");
final DateTime result = format.parse(data);
print(result); //2022-10-27 11:02:50.000
final newFormatter = DateFormat("EEEE, MMMM dd, yyyy");
final newFormatString = newFormatter.format(result);
print(newFormatString); // Thursday, October 27, 2022
I am using intl package
Just checked in flutter docs. Your date format is not good. For converting string to date.
The following date format is required,
"2012-02-27 13:27:00"
"2012-02-27 13:27:00.123456789z"
"2012-02-27 13:27:00,123456789z"
"20120227 13:27:00"
"20120227T132700"
"20120227"
"+20120227"
"2012-02-27T14Z"
"2012-02-27T14+00:00"
"-123450101 00:00:00 Z": in the year -12345.
"2002-02-27T14:00:00-0500": Same as "2002-02-27T19:00:00Z"
And you can convert that into the format like below
var date1 = DateFormat('dd-MM-yyyy hh:mm:ss').parse("27-10-2022 11:02:50");
var date2 = DateFormat('yyyy-MM-dd hh:mm:ss').format(date1);
print( DateFormat('EEEE, MMMM dd, yyyy').format(date2));
please try this, hope you will get the idea,
print(DateFormat('dd-MM-yyyy HH:mm:ss').parse('27-10-2022 11:02:50'));

Logstash: How to match the timezone ID 'CET' in a date filter pattern?

In Logstash, I want to convert a string into a timestamp using the date filter. The string looks follows:
Fri Nov 05 06:24:28.651 CET 2021
I've tried the following pattern to no avail:
date {
match => [ "syslog_timestamp", "EEE MMM dd HH:mm:ss.SSS ZZZ yyyy"]
locale => "en_US"
timezone => "Europe/Berlin"
target => "syslog_timestamp"
}
This is confusing since Logstash is said to use the Joda library and Joda in turn says 'CET' is a legal timezone ID. I confirmed the results by testing the Jody library v2.10.13 directly in a Java application.
How to parse CET/CEST in the date filter?
Since time zone names (z) cannot be parsed and ZZZ still wouldn't match the daylight-saving variant 'CEST' according to Joda's documentation, I worked around this issue in Logstash by handling the timezone code as text and passing multiple patterns with the standard time zone and daylight-saving time zone to the filter:
match => [ "syslog_timestamp", "EEE MMM dd HH:mm:ss.SSS 'CET' yyyy", "EEE MMM dd HH:mm:ss.SSS 'CEST' yyyy"]

Converting date string to/from date of different locale

Taking the Japanese locale for example,
converting 2017-06-08T14:41:56+0000 to a format EEEE, MMM d, yyyy under the locale ja will give:
木曜日, 6月 8, 2017
but converting 木曜日, 6月 8, 2017 to a date object using the format EEEE, MMM d, yyyy and locale does not work.
Is there a way to handle date/time string conversions for unique locales?

Change the format of a google spreadsheet date to include day of the week

I am trying to change a simple date format "1/24/2016" to " Tuesday, Jan 24 2016"
sheet.getRange("A2:A10").setNumberFormat("EEE, d MMM yyyy");
prints:
"EEE, Jan 24 2016"
This is an undocumented feature
you can use:
range.setNumberFormat("DDD, MMM dd, YYYY");
For more details you can see the issue report here:
https://code.google.com/p/google-apps-script-issues/issues/detail?can=2&start=0&num=100&q=setNumberFormat&colspec=Stars%20Opened%20ID%20Type%20Status%20Summary%20Component%20Owner&groupby=&sort=&id=4175

dateFromString() returns incorrect date

I'm trying to convert string to Date, but it result incorrect date.
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd MMM YYYY"
let dt = dateFormatter.dateFromString("17 Sep 2015")
println("Date : \(dt)")
It result
Date : Optional(2014-12-20 18:30:00 +0000)
Please let me know where I'm making mistake. I tried other format too, but it return nil.
The format for year is incorrect, it should be yyyy, not YYYY.
"Y": Year (in "Week of Year" based calendars). This year designation is used in ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. May not always be the same value as calendar year.
See: Date Field SymbolTable.
Also: ICU Formatting Dates and Times
Your date format string is wrong. Change it to the following:
dateFormatter.dateFormat = "dd MMM yyyy"
For more information read Date Formatters documentation.