How can I reformat date using Flutter? - json

I'm using openweather 3hours forecast api. Why does the date show only the same time? even though values are different? date is supposed to be every three hours. I formatted the date in weatherItem.dart after iterating over each item.. how can I get the date with every three hours and render on the screen?

Looking at the JSON data you provided with the dt_txt key, you'll find that the date format does not contain time. So the JSON data you're getting does not contain a valid time you can use

Related

How to retrieve date from database

I have a column in my database that is of type DATE.
I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).
r.setRkd(Date.valueOf(LocalDate.now()));
The entry is correct because the exact date appears in the table.
rkd
------------
2022-03-02
The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.
"rkd": 1646175600000
Do you know how I can print the correct date in my JSON?
Thank you in advance.
That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD
If you need to display it in date format there should be a method to do it depending on the specific language that you're using.

Is there a snowflake command to re-format a timestamp to ensure they are correctly displayed in a CSV export

long time viewer, first time poster.
The issue I am struggling with relates to how my timestamp data appears in excel once I've run my code in snowflake and exported it to CSV. Unfortunately at the moment I am required to double click on these timestamp cells, once in exported into excel, for the true format (how it appears in results in snowflake) to appear.
There is a manual workaround to amend once the data is in excel, however I am automating this report for a client and therefore it must be presented correctly for them prior to the export.
As it stands (see below) the timestamp begins with YYYY-MM-DD and I have been asked to flip this firstly, to begin with DD. I thought that given I need to reformat the current timestamp, I may as well set it up correctly so the timestamp perhaps comes out as text, within the csv export? (from what I have read in other forums if you convert to text it is displayed in excel exactly how it appears in snowflake).
image.png
As you can see, I continue to get the "Cant Parse" error. The example timestamp given, is row 1 of the 'QuoteDate' variable.
The second part of the issue (or really the primary part of the issue) is how the timestamp completely changes format when exported (CSV) to excel. In the screen shot below I have double clicked the first 3 rows, leaving row 4 selected in order to show you all the error - which is the formula bar displays the correct format but the cell itself does not.
image.png
I hope this all makes sense and would love any assistance on how to amend this timestamp issue to run the code correctly, and present my client with a properly formatted timestamp within their extract.
Thank you :)enter image description here
For changing format
SELECT to_char ( to_timestamp ('2019-01-02 09:36:22.507' , 'YYYY-MM-DD HH24:MI:SS.FF') , 'DD-MM-YYYY HH24:MI:SS.FF') AS TS
Timestamp/dates are stored as NUMBER in database, you need to convert in required format for correct display.
to_timestamp --> Converts an input expression into the corresponding timestamp. This expects the input to be in the format provided as second argument.
to_char --> Converts the input expression to a string format.
For preserving data format while converting from csv to excel check Saving to CSV in Excel loses regional date format

Transform the field values pentaho(kattle) and store it in standard format in any table

I want to transform the value of fields name and Date using pentaho(kattle) and store it in standard format in any table.
For example
id,name,f_n,Date
1,j_vick,03-05-2015
2,jo_vick,04,08,2016
3,Arn_jonnn_vick,05,07,2017
Now I want to transform it using pentaho(kattle) IDE and store it in data base like below:
id,name,Date
1,john_vick,03/05/2015
2,john_vick,04/08/2016
3,Arn_john_vick,05/07/2017
I don't want the transformation steps concern with extraction database storage.
The date format is just some clothing of a value. Just read it with Kettle and store it as is. The database will store it in its proper internal binary format anyway.
Unless, you have to store them explicitly as varchar. In that case, use the Metadata tab of the Select Value step. Define your column as Date and specify the format as dd/MM/yyyy or MM/dd/yyyy. It will be kept internally as a Date, and converted into a String with the selected format at the last moment.
You also seam to have an other problem: the day, month and year are in three columns. The easiest way is to use a Modified Java Script Value step, in which you define a new column date = new Date(year, month, year), with type Date, and let Kettle handle with the format.
Maybe you have mixed input, in which case you can use a Filter or a Swtich step, based on weather you have something in the day and month column.
When that is done, you can make a job that runs the transformation on all the tables. You have an example in the sample/jobs/process all tables furnished with the Pentaho Data Integrator (aka Kettle).

Jackson automatically converting json date to 8 hours ahead of its time

In my json date is represented like this :-
"from":"2015-11-11T09:21:00.00Z"
But when it gets converted to java.sql.Timestamp it looks like this :-
2015-11-11 17:21:00.0
My timezone is Singapore . It is 8 hours ahead of UTC timezone and coincidentally the date also gets converted to 8 hours ahead of its time.
They are showing the same times, just formatted differently for the different locations. The time you are taking in is UTC/GMT. What you are viewing in your IDE is showing the local time stamp formating, but they are the same values and points in time.
If it really matters how it is displayed to you in the debugger you can use a Calendar object instead of a TimeStamp and set the locale value to be UTC and it will format them the same way, but again they are the same values.
I don't want the Timestamp in java to be different from json
It is not different, the display format is different do to the location setting but they are the same values just represented differently.
P.S. Be aware that if your server is set to a different time zone than your work station it will show a different format as well, but it again will be the same time just represented differently.

How to get the date value in the table in specific format?

I have one problem in my tool. I am using one MySQL table called calendar. From this table I am fetching some date values. The format of date in calendar table is yyyy-mm-dd. But in my system having dd-mmm-yy. In my c# application I fetched the date from the Calendar and If I displayed the date in c# application means date format(2012-10-05) changed to system format(05-oct-12). But I need to display in yyyy-mm-dd format. I don't know how to solve this problem.
To display DateTime in specific format, you can specify the format in .ToString() method like:
DateTime dt = DateTime.Now; //your DateTime variable
Console.WriteLine(dt.ToString("yyyy-mm-ddd"));
You may see the article: Standard Date and Time Format Strings - MSDN