How to allow set hours and minutes for date format? - jhipster

How to add possibility of set hours and minutes? Currently, I have something like this:
But in this case is impossible to set hours and minutes. What should I do to allow set this data via the web browser?

In your entity, I suspect the startDate field is a LocalDate. Try ZonedDateTime instead.
LocalDate: A java.time.LocalDate object, used to correctly manage dates in Java.
ZonedDateTime: A java.time.ZonedDateTime object, used to correctly manage dates and times in Java.
See creating an entity.

Related

get all docs from couchDB updated in a specific time range

I would like to get all the docs in couchDb updated in a specific time range.
I'm using the below API but I don't get any result.
/_all_docs?startkey="2019-01-01T00:00:00Z"&endkey="2020-01-01T00:00:00Z"
Any suggestions are welcome.
Andrea
_all_docs's key is the document ID, not timestamp. For your query to be useful, you'll need to create a custom view based on a timestamp (and ensure the timestamp is updated by your code).

Storing converted dates in MongoDB [duplicate]

This question already has answers here:
Store date in MongoDB without considering the timezone
(2 answers)
Closed 4 years ago.
I was working on a project and since it is the first one, I didn't know about Mongo storing everything in UTC until I noticed that birthdates were being stored at day X-1 23:00:00 instead of day X 00:00 as it should. I've tried using moment and converting the date to my timezone before storing it but Mongo ignores it.
const bdate = moment.tz(body.birthdate, "YYYY-MM-DD", "Europe/Lisbon").format();
On console it shows:
1998-10-20T00:00:00+01:00
On the database it shows: "1998-10-19T23:00:00.000Z"
What can I do to be able to store the data in my local timezone or force MongoDB to show local timezone dates instead?
I've seen solutions using $project to convert into the local timezone but I'd like to get the entire converted date and not just hour/day/month.
From mongo docs seems like you can't https://docs.mongodb.com/manual/tutorial/model-time-data/
They recommend you convert it application side.
I think you should consider how you're going to use the date and how you're going to index the collection.
For example, if your goal is to send the user a notification "Happy birthday" on their birthday at a specific time of day in their local time zone, you might want to bake that time zone shift into what you store in Mongo. That way you can index on the birthdate field, and get all the users you need to notify by querying like db.users.find({ birthdate: ). Obviously if the user physically moved time zones this would break (you'd have to update that if they moved). Alternatively you could store their birthday + local timezone as separate fields, but that would make querying it much more complicated.

create integer associated to a string in java

i've been programming for about three weeks on a game in Java.
The last days I was searching for a way to "connect" an integer value to an string and being abled to create new objects which are abled to hold this values aswell.
This would be needed to create item-objects holding an item-ID and the path for the item-image.
I got some inspiration from other people in my company aswell, who told me to use XML-Files or CSV-files to save the item-ID to the correct item-path, but before i learn to create an XML or use a CSV i wanted to know if there might be a better or easier way to create items without wasting more time in try and error to assign an Integer to an String...
Thanks for your Attention

set only time in mongoose schema

How to set only time in mongoose schema ?
like we can do in sequelize schema
startTime: DataTypes.TIME,
endTime: DataTypes.TIME
is their any way in mongoose to set time in mongoose schema??
It's simple Date and nothing else like this --> startTime : Date
Here is the documentation for all available data types for mongoose: http://mongoosejs.com/docs/schematypes.html
In case you only require the time of the date you can use a getters to achieve that: http://mongoosejs.com/docs/2.7.x/docs/getters-setters.html
I've tried achieving the same thing before but failed.
The best solution that was I able to come up with was to just add the time during the insert to the database and not when creating the schema.
This way you can use datetime.toLocaleTimeString(); or moment.js to just add the time without the date etc.
I'm afraid there is no mongoose schema type to store a time like you can do in SQL.
I have stored a time as a Date in one of my project, keeping just the time part of that date. It works more or less.
And maybe MongoDB $hour and $minute aggregation can help.
But it is not a very elegant solution.
Another possibility is to store your time as separate Number (hours, minutes, seconds).
Best method I found so far is to store it as a String, as mentioned in this answer.
Maybe you can go further into this idea and create your own custom schema Time type.

Set value of datetime field to null

So, I´ve got an issue that someone might have solved (or so I hope). I have a datetime field that I use in a contenttype (on a listtemplate) that has its own editform.
Here´s a walkthrough of what happens:
Adding a value to the datetime column and saving the updated value shows up (as expected).
Updating the datetime column and adding null (emptying out the value) via the editform. The value isn´t updated but instead showing the old value.
I did some experimenting with this and I came to the conclusion that if I add an eventreceiver and try to update the value there it doesn´t even enter the eventreceiver as a blank string (I had an idea that the value is as a blank string and sharepoint can´t parse that to a null datetime) which leads me to think that there´s an issue with the fieldcontrol that causes this. I also found this article on MSDN which seems to be around the same issue. And also, the datetime field in the contenttype isn´t required.
Any ideas or suggestions?
UPDATE:
Apparently this only happens when I use a custom editform. When I use one of built in listtemplates this works like a charm.
I've had similar issues with this in the past. It is indeed a known bug. One work around is to set the field to the min or max value of the type and check for this value wherever needed and do the appropriate conversions. Depending on your setup and use, you could create a trigger to convert min/max values to null and thus minimize the code required to handle such a work around.
After some deep investiongation I have found that the root of this problem is related to the fact that I was using XML node propagation between the columns in the list and the actual xml file. I had prevoiusly been struggling with this regarding stardard text fields and thought that I had taken care of the issue..apparently not. DateTime fields apparently will not get sent to the eventreceiver afterproperties if it is null as thus my code will not pick it up as a null value. I had to take case of that and add them to afterproperties if I can´t find them in afterproperties. I will make a blogpost series about these issues and post the links to this post shortly.
UPDATE:
I have now completed a blogpost about how I solved this issue. Feel free to check it out:
http://johanleino.wordpress.com/2009/08/24/node-demotion-does-not-work-with-blank-empty-values/

Resources