How to convert string to date in talend - talend

I want to convert string
1516270217
to date format
hh:mm dd-MM-YY

You can do that in a tmap for example.
TalendDate.formatDate("hh:mm dd-MM-YY",TalendDate.parseDate("HHmmddMMyy",row21.newColumn))

Related

talend format yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss

I am trying to change the date format in txmlmap component but its not working
i want change date format
from yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss
expected output:- yyyy-mm-dd HH:mm:ss
You can parse your string to a date using your source pattern and then format that date to a string using your target pattern:
TalendDate.formatDate("yyyy-mm-dd HH:mm:ss", TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSSz", myDateString))
In almost all coding languages format is text, while date is a double. That means you must first make a date of the first expression, before setting the new format of that date. But in Your case the 'T' is some kind of special format that need to be replaced with a blanck space. I have no idea about what it would look like in talend but in VB it would look like this:
' from yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss
DateTxt = "2022-12-01'T'22:45:10"
DateTxt = Replace(DateTxt, "'T'", " ")
MyDate = CDate(DateTxt)
MsgBox Format(MyDate, "yyyy-mm-dd HH:mm:ss")

How to convert unix timestamp to iso 8601 in Flutter

I am getting date from a server as a unix timestamp, how can I convert it to ISO 8601 date format in flutter?
the date I receive:
1611694800000
How I want to convert it to be
2021-01-26T22:00:00.000+00:00
What I have done so far with no luck
String s = '1611694800000';
debugPrint("Recevied date is: $s");
String dateS = DateTime.parse(s).toIso8601String();
debugPrint("Converted date : $dateS");
String dateStr = (dateS.split(".")[0].split("T")[0] + " 00:00:00").substring(1);
debugPrint("Activation date: $dateStr");
I end up getting:
Unhandled Exception: FormatException: Invalid date format.
Use DateTime.fromMillisecondsSinceEpoch:
var timestampMilliseconds = 1611694800000;
var datetime =
DateTime.fromMillisecondsSinceEpoch(timestampMilliseconds, isUtc: true);
print(datetime.toIso8601String()); // Prints: 2021-01-26T21:00:00.000Z
(Note that the printed time is one hour off of your stated expectation, but I'm assuming that's a mistake in your expectation.)
The reason why you are getting invalid date format is because you have to provide date in string like '2021-04-19' and not milliseconds;
This package makes it easy to format dates time_formatter

How to convert date from one format to another golang

I am converting a date into unix timestamp and fetching the date using split as follows
tm := time.Unix(1470009600, 0).UTC()
dateString := strings.Split(tm.String(), " ")
The output of dateString is 2016-07-15 i.e. YYYY-MM-DD format. How can I convert this into DD-MMM-YY format? eg: 15-Jul-16?
Use Format method with the appropriate format:
fmt.Println(tm.Format("02-Jan-06")) // Prints "01-Aug-16".
Playground: https://play.golang.org/p/uYDYzPwnbJ.

Hive date format

Anybody converted a date from mm/dd/yyyy hh:mm format to
yyyy-mm-dd hh:mm:ss format using hive query ?
I have a string with date in the / format need to add some duration in it
Do this:
select
regexp_replace('2015/04/15','(\\d{4})\\/{1}(\\d{2})\\/{1}(\\d{2})','$1-$2-$3') as dt
from x;
INPUT:2015/04/05
OUTPUT:2015-04-05
Grab four numeric digits (\d{4}), two (\d{2}), and two more (\d{2}) from the original string and put them in that order seperated by dashes.

Filtering Date column of dataview using Rowfilter

I want to filter my View according to selected date which is in the format "DD/MM/YYYY", but my dataview column has date in "DD/MM/YYYY hh:mm:ss" format.I want to filter the view according to selected date irrespective of time.How do i convert MATCH_DATE column to the format "DD/MM/YYYY" format in RowFilter.
dtFixt.DefaultView.RowFilter = "MATCH_DATE='" & CType(calSeason.SelectedDate,DateTime).ToString("dd/MM/yyyy") & "'"
You can convert the MATCH_DATE column to "DD/MM/YYYY" format in your view, using CONVERT function as follows:
CONVERT(VARCHAR(10), MATCH_COLUMN, 103)
103 is a Date Format Code that converts the any date in "DD/MM/YYYY" format.
For more details on different date formats, refer article Date Formats.