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.
Related
i am not used to working with excel anymore and there is no VBA available at my workplace.
I have a set of data showing a userID (left) and numbers (right) which indicate a day in december (1 = december 1st to 24 = december 24th)
I figured out how many people participated on specific days, but i'd also like to know what the amount of participations looks like overall (how many people played only 1/24 times, how many people played 24/24 times etc). It's mostly a fun project for work where not much of excel analysis is being done, that's why i'm asking here. Thanks in advance!
I tried a combination of COUNTIF with FREQUENCY but i couldn't figure it out on my own
What about inserting a pivot table?
You can have a look at my example here:
By clicking on the right-arrow (see green rectangle), you can change the properties of the "summing" field and turn it into a "counting" field:
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);
This is a multi-tiered project. Let me give a quick overview. I have attendance data, card/ timestamp punches. I would like to have a pivot table with slicers in Excel. Ideally you'd be able to choose a department / last name / associate number. And also a period of time. Ideally this would be a table with the company period/week. And maybe default to last weeks.
I can get at timecard data in two ways:
(1) generate a CSV that automatically performs the timecard math, to figure out how many hours someone worked and it is smart enough to understand 3rd shift workers. The format of that CSV is:
Last Name, First Name, Personnel Type, Associate Number, Facility, Department, TimeIn, TimeOut, Total Hours
The problem with this method is that I would have to manually append the information to the CSV tables. Or come up with some autoIT script.
(2) Get at the raw data via sql/odbc. This way the math is not done. It is just all of the associates timestamps. I would have to figure up the daily hours myself and figure out a 3rd shift formula too. It is not a set schedule, many people swing shifts and others get called in a lot.
Lastly, I would like to be able to filter the dates by using our company fiscal calendar. I have a spreadsheet that goes from 2000 to 2093. With everyday listed and it's corresponding year/period/week.
Example period info spreadsheet:
date Year Period week WeekTotal Period Total
12/3/2007 2008 1 1 2008.1.1 2008.1
12/4/2007 2008 1 1 2008.1.1 2008.1
I know there is a lot going on here, but what would be the best way to approach this project?
First I have not been able to post any script however the last I tried it I used two options 1. Was a php conversion where the time was numbers ( which makes it easier for calculations)
2. Was in the tables where I deliberately entered the values places the time in different columns or fields for hours, mins, and seconds this meant that while the input is eased I still have to calculate the output in php especially for totals, averages and differences.
Hope it helps a bit
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.
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.