Using if condition on data type - jasper-reports

I want to use a condition in my report based on the datatype.
I have a 'date' field which is of date format in some cases and in String format in other cases. For string format I do a conversion to get the date. No conversion is required for those already in date format.
For example, I am trying this in the expression editor:
$F{start}.getClass()== "class java.util.Date" ? "Date" : "String"
But it is printing "String" for date fields. What am I doing wrong here?

OK I got the solution, I was missing the 'toString()' function:
(($F{start}.getClass()).toString()== "class java.util.Date")?"Date":"String"

Related

what formulas should be put for the date by sequence in crystal report?

There is an error message shown up for when I edit the formulas.
we want to sort the ship date by sequence.
parameter field
error message for "A date-time is required here"
If then else must return the same data type for all branches.
So Convert the dates to a string. For example, ToText({Ship_Date}, 'yyyyMMdd')
and convert the numbers to a string as well. For example, ToText({PartN}, 0, "")
ToText {CUST_ORDER_LINE.PART_ID}
is missing ()
Need to be
ToText({CUST_ORDER_LINE.PART_ID},0,"")

Unable to filter after Date in Realm swift

I'm trying to apply a filter on realm which includes a Date but with no luck.
I've found out that Date object cannot be passed because the %# format expects a Foundation object as argument, so I've applied a cast to NSDate.
let newDate = Date()
realm.objects(E.self)
.filter(String(format: "%# <= %#", key, newDate as NSDate)).first
The issue that appears is "Unable to parse the format string timestamp==2020-03-20 08:21:00 +0000"
key is the name of the field, which in this case it is "timestamp" and on the model it has the type Date.
Any input is appreciated.
Thanks
You should use:
.filter("\(key) <= %#", newDate as NSDate)
This is calling the overload of Realm's filter method that accepts a format and arguments.
String(format:) is not the right thing to use here, as that just does general string formatting. But here, you want the date to be formatted according to the rules of NSPredicate formats. On the other hand, the key can just be interpolated into the string because the name of the table column doesn't need a special format.
If key comes from a UITextField or something like that, then you might need to beware of injection attacks as well, and validate and/or escape the key properly beforehand.

DataStage Parsing Input String to Date Format

I have a string input format of i.e
'Thu, 30 Nov, 2017'
I need to transform this into a more Oracle database friendly Date type format of something like '11-30-2017' or '11/30/2017'. I started in the path of
Convert(' ','-',Convert(',','',DSLink.InputDate[5]))
which should return a string of: 30-Nov-2017
However I'm stuck on dynamically parsing the 'Nov' month part. Any clever ideas?
also I don't think this will work:
StringToDate(Convert(' ','-',Convert(',','',DSLink.InputDate[5])),"%dd-‌​%mm-%yyyy")
as the function is looking for a numeric type on the month field?

Date format in Talend "2006-05-27 17:00:00.000"

I am facing an issue with Talend dates. I have tried several solutions but still an "unparseable date" error persists.
My date format is of the form : "2006-05-27 17:00:00.000"
Can you help me ?
you can use below talendDate function to parse your string into date..
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.sss","2006-05-27 17:00:00.000")
this would take input as string and return you date.
If you don't handle the conversion yourself in a tMap but just want to use a schema, then: In your mapping configuration in the date field, you can add the following string:
yyyy-MM-dd HH:mm:ss.SSS
to set the correct format mapping for the date string. Otherwise the answer of garpitmzn is the way to go.
you should use this function in talend to fetch date:
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.SSS","2016-01-12 12:45:00.000")

converting a utc format date string to date object in Extjs

I have a date string in the format "2013-01-31T10:10:05.000Z". I want to convert this string to a Date object in extjs.
I have tried to use Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-dTH:i:s.uZ"). But it is returning undefined.
I also tried with new Date("2013-01-31T10:10:05.000Z"), but it is also returning undefined.
Note: I have tried in IE8 browser.
Could anyone please help me to convert the above date string to Date object?
Thanks a lot sra. Now I am getting the result as ...UTC+5:30... Is there any way to convert this in IST format?
Try Ext.Date.parse("2013-01-31T10:10:05.000Z","c");
The c is the format type for ISO 8601 formatted dates
See the Ext.Date API for more details on this or other available formats
That's because 'T' and 'Z' are special characters in the Date format: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Date
You have to escape them like this: Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-d\\TH:i:s.u\\Z")