I have this project in spring roo wherein there's a datetime field. The date format is Short while the time format is Medium. The output for the date is ok however the time output is always showing 12:00:00 AM. It doesn't change.
Any help?
Thanks.!
If you have something like
#Temporal(TemporalType.TIMESTAMP)
#DateTimeFormat(style = "MS")
private Date endDate;
then it's showing 12:00 a.m. because date is whatever the date but no time has been set up.
Make sure your object has a time component, you can try with
new SimpleDateFormat("ddMMyy HH:mm").format(yourdateobject)
Related
How Google Sheet looks
How Firebase Database looks
So the date keeps saving as the day before date;
At Google script appsscript.json is set my real timezone:
"timeZone": "Europe/Kiev"
Any suggestions?
It sounds like the two timestamp values actually refer to the same moment in time. Firebase timestamps are always in UTC.
2021-05-16 00:00 GMT+3 refers to the same point in time as 2021-05-15 21:00 GMT+0. The timezone difference between Kiev and GMT is two hours + one hour because of daylight saving time, so during EEST the two serialized values will look like they are three hours apart.
You can deal with the timezone difference in the client, displaying the timestamp value you retrieve from Firebase in the local time of the client. If the client is in the Kiev timezone, the value will then look the same as it was in the Google Sheet originally.
If you want to save the date as a static text string instead of as a Date object, you may want to convert it in Apps Script with const timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone() and const dateString = Utilities.formatDate(myDate, timezone, "yyyy-MM-dd"), or in JavaScript with the Intl object or a library like moment.js.
My startDate looks like this 03-03-2020 but I need to add time as well. I have checked some example schema from other sources and have come across something similar:
2020-03-03T12:45:00+01:00
I have two concerns:
Does the time format matter? My format is dd-mm-YYYY. The second example format is different. Is there any problem having it either way?
How do you properly add the time time to the startDate property. Is the last extension the TimeZone e.g +03:00 or should you use the Universal Time zone then include your Timezone (Time offset).
Please help clarify.
I have two concerns: Does the time format matter? My format is
dd-mm-YYYY. The second example format is different. Is there any
problem having it either way?
If you check the description of the startDate property then there you will see the following information:
The start date and time of the item (in ISO 8601 date
format).
If you follow the specified link, then in the Wikipedia article (in the right panel) you can see the following time format:
Date 2020-03-04
In order to establish a machine-readable format, you can use an HTML element such as time with datetime.
======================================
How do you properly add the time time to the startDate property. Is
the last extension the TimeZone e.g +03:00 or should you use the
Universal Time zone then include your Timezone (Time offset).
Indicate time in ISO format with a time offset, e.g., if you are located in the Canadian province of Yukon then you can use a time zone indication such as 2020-03-04T05:16:15-08:00.
In Sweden, I have Central European Time with a time offset of +1 hour and summertime +2 hours. So at the moment in Sweden, I can use a time format such as 2020-03-04T05:22:16+01:00. However, the Sweden summertime will be in a format such as 2020-07-04T05:22:16+02:00
I have a lotus notes field which should save the date/time in the GMT format,
for that I used
Dim timenow As Variant
timenow = Now()
Dim dateTime As New NotesDateTime( timenow )
doc.abc = dateTime.GMTTime
This will set the field 'abc' to have the date and time in GMT. But now I am having issues with the date format. In my system it saves it in the format 10/28/2016, but for other users whose system date format is different, it saves it in the format 28.10.2016. I need to force the date format to be 10/28/2016, I tried used format function
doc.abc = Format(dateTime.GMTTime, "m/d/yy h:nn")
The above code gives the date and time in GMT, but doesn't change the date format.
You are wrong in the assumption, that the date is SAVED in that format.
Date items in the backend are number- items. They store the date as number, the integer part is the day, the fraction part is the time of the day (day 0 is 12/31/1899 00:00)
Then the setting in the client determins, how the client displays the date.
In the properties of the item you usually define "Client" as display format, but you could fix the display of the date to a specific form.
But usually this is NOT necessary, and every german will not like the "reversed" order of english / american time formatting.
This will only be a problem, if you construct a text from that date, as #Text() will convert it using the clients format.
I guess, that your problem is not in the "saving" of the item, but somewhere else in your code, where you interpret the date as text, and this is always a problem.
What type of field is it? If it's a date field, the Notes client will use the user's local date format.
If you want to use a specific format, you can use a text field instead, but of course then the time won't adjust to the user's local time zone.
The way to get the best of both worlds is to store the date in date field, but use a computed-for-display field to show it in the user's current timezone, but in exactly the format that you want.
Most people use a NotesDateTime object to set the date in a field
Dim ExpiryDate As New NotesDateTime(Cstr(Today))
Even if the field in the form uses a specific format, the date like 2019-09-08 can mean 8th september 2019 or 9th august 2019 depending of the LocalDate setting
To avoid this behavior, you need to force the format in your NotesDateTime Object
Like this
Dim ExpiryDate As New NotesDateTime(Format$( Today, "yyyy-mm-dd "))
What I need to do is in my program i need to add the Arrival DATE and the Nights staying together and have it display into another textbox called Departure date. The format for the arrival date will be in the "##/##/##" context and the nights staying is an integer between 1 and 14.
I have all of the code for the rest of my program completed, I just do not know how to do this. I dont know how to take an integer and add it to a date so in the display box, after they are added together, it displays a date X amount of days after the arrival days. Where X is the Nights staying.
I Will greatly appreciate any help with this.
Use DateTime.AddDays to add number of days in the DateTime object like:
DateTime arrivalDate = new DateTime(2014,03,10);
DateTime departureDate = arrivalDate.AddDays(1); // Add One day
To get the formatted Date back use ToString with Custom DateTime Formats
string formattedDate = departureDate.ToString("dd/MM/yy", CultureInfo.InvariantCulture);
I have an asp.net calendar that is used to display events taken from an access database. It works fine, but as the server is US based so according to Indian Standard Time(IST), it changes current day after 12:30 PM (11hrs, 30 min after actual IST time). This gets a little confusing for people using it.
I want a solution so that the calendar changes to today's date at correct time i.e. 12:00 AM IST. Or you may say that the time of the server should be added 11 hrs & 30 min so as to display date according to IST.
Solved!!!
Declared a DateTime variable and with DateTime.UtcNow, added 5 Hrs and 30 Min to the result.
Then this resultant DateTime is used as Today's Date.
DateTime todayDate = new DateTime();
todayDate = DateTime.UtcNow.AddHours(5).AddMinutes(30);
Calendar1.TodaysDate = todayDate;