Focus in Calendar Component - java-me

What should I do to focus on the specific date in calendar component?
I am not talking about indicator here. calendar.setCurrentDate() and calendar.setSelectedDate() gets the indicator on the date, but focus is always on date of 1st sunday. I have read on net that this functionality is not provided by calendar yet. Do any one have any idea? Any solution?

You can derive calendar and override updateButtonDayDate(Button dayButton, int currentMonth, int day).
Here you can perform a requestFocus() invocation when the specific date matches your requirement.

Related

dash/plotly how can I add a calendar/agenda/schedule view

I have created my own dashboard and would like to add a new tab with a calendar/schedule or task manager/viewer; as an example, would it be possible to come up with something like
On that picture I am mostly interested in the overall Month view (and the scroll down feature) in the center-right.
My "Calendar" would only run for the next 4 months and would be fed from a database (a table birthdays, a table appointments, a bank_holidays table...). A birthday would show up in yellow for instance while an appointment would be in red and a bank_holidays in blue. It wouldn't be dynamic as the Calendar would be initialized upon a button clicked and the data would be "frozen" until the next day/click of a button. From what I found this is far from being straightforward. I thought (think) I could have used the DatePickerRange and instead of having the calendar popping-up, having a way to have this calendar fixed/static within my page.
If this is not possible to be done intuitively based on dash/plotly I was thinking I need to create my own calendar template based on dash datatable: one datatable for each upcoming months (max 4 months). How can I initialized a dataframe to represent a month, with columns being the day of the week, and the values per rows being the day of that month?
My idea would then to cast those values into a list and then append the dates from my birthday table, appointment table and so on.
Edit: it seems there are some Calendar templates based on javascript, but then how can I embed such template into my dash/plotly dashboard?

How do you get the day out of a Date object since "getDay()" is deprecated?

When the user opens my app the date is recorded. Then it's compared with the last date that was recorded. I want to be able to tell if just the day changed between the 2. And I don't want to simply see if 24 hours lapsed. The user should be able to open the app at 11:59pm, and then again in 2 minutes and the code should tell that the day has changed. Thanks for your help!
I found a solution that solves my problem (although technically doesn't directly get the day out of the Day object.)
Comparing two java.util.Dates to see if they are in the same day
Basically make a Calendar object and call it's "setTime()" method with my Date object as the argument, then use ".get(Calendar.DAY_OF_YEAR) to get the day from each Calendar object.
You are right, and if you want to get the actual day you just need to use Calendar.getInstance() like this:
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DAY_OF_MONTH);

LWUIT Calendar. set time on selected date and find difference in milliseconds

I have loaded the calendar in my LWUIT based UI. Thanks to this thread. It is neat.
when i select a certain date i want the calendar to close and the selected date to appear in my original form in dd-mmm-yyyy form.
I want to take this selected date, set the clock to 1200 hrs (afternoon) on that day and find the time in milliseconds elapsed between now and 1200 hrs on the selected date.
something i have earlier asked here but for a desktop java applications using netbeans 7.1.2.
I find that methods like getInstance, getCalendar, setTime, are not supported in the LWUIT calendar. Are they? I can only have date = getDate(); but cant set the clock on that date.
Further,
1. How to select current time (now) in milliseconds.
Will this work?
`Calendar today = Calendar.getInstance();
Date time_now = today.getTime();`
If it will, How do i find the difference between the date selected by user and time_now. (supposing that i simply add (12*60*60*1000) to the above difference to compensate for inability to set the clock to mid-day.) The real problem is that, above two objects are date objects and i want the difference in milliseconds as a double or long variable.
Whats the solution. Thanks in advance.
You are confusing the LWUIT com.sun.lwuit.Calendar class and the java.util.Calendar class, they have similar names but they are quite different. You can just use the java.util.Calendar class by typing in its fully qualified name.
Keep in mind that the java.util.Calendar class in J2ME is more limited than the one in Java SE but can still be used to some degree.

Sharepoint 2007 date time in a list

We are using a custom list on Sharepoint where we require users to enter data with a date and time field. We have been facing huge issues in data validity when generating reports due to this field. Following are the kinds of mistakes:
Selecting AM instead of PM or vice verse. Changing to 24 hrs format doesn't help much because then the users select (as an example) 02:00 instead of 14:00 for 02:00PM.
There are errors regarding formats of dates, hence some entries have dates from the future or the past.
As the reports are generated each week, the list needs to be populated by the end of the week. If the month has changed between the week, people forget to change the month in the calendar and the entries are of the last week of the current month instead of the last week of the previous month.
Are there ways to configure the list(Pref. without programming) so that:
A. Only working hours are available in the time related dropdown.
B. Dates from the future are not allowed( Or not available)
Any help would be appreciated.
As far as I know, you won't be able to satisfy these requirements with no custom code.
If you decide to go down the coding path, what you need to do is create a custom field type. Let me know of you need help on this.

How should I store old dates in SharePoint?

I need to store dates in SharePoint that need to go back around 5000 BC. Ideally, I would like to be able to do date addition/subtraction, like this:
oldDate = '5000 BC';
newDate = '1995 AD';
DateDiff(oldDate, newDate, 'Years'); // equals 6995
How should I proceed? Build an old_date class based on strings? Just use regular dates, but add an AD or BC that makes the date negative?
This is a seriously non-trivial problem, and really depends on what exactly you want to do with those dates. For example, we've only used the current (Gregorian) calendar since 1582. Before that it was the Julian calendar, and before that an old Roman calendar. To make matters worse, this info is really only for Western Europe (and culturally-related areas). So if you are hoping to have someting that will give you proper accepted dates for historical events with a little simple math, you are in for a big dissappointment.
If you just want to carry the Gregorian calendar backwards, I suppose that's doable. However, there still is error, and on that scale it matters. From Wikipedia:
On timescales of thousands of years,
the Gregorian calendar falls behind
the seasons because the slowing down
of the Earth's rotation makes each day
slightly longer over time (see tidal
acceleration and leap second) while
the year maintains a more uniform
duration
If you are interested only in years and not in days then you could build a custom field with custom editor and store the year value as integer value.
Values less than zero mean BC and values higher or equal that zero mean AD.
I ended up storing dates as a text field in ISO 8601 format:
YYYY-MM-DDThh:mm:ss.sTZD
You don't have to store the entire string, for instance if you wanted to store 5000 BC, you would enter -5000-01-01. I don't get my date addition and subtraction very easily, but it was much easier to get the data in there in the format I wanted.

Resources