How to controll dates in the best way

Hello
I have a question regarding comparing dates. I'm about to make an application where the user can choose between 2 accounts 1)access for a week or 2) access for a month. So my first thought was to convert current date to milliseconds ( Number of milliseconds since 1/1/1970 (GMT)) which will be the "start date" and then add correct number of milliseconds to the "start date" to get exact "stop date". Then when the visitor is logging in I get the date of current day -->transform it to milliseconds (currentdate)-->and compare it to my "stopdatems" (A value in my class Visitor below") as I do below:
----------------------------------------controll when logging in-----------------------------------
Visitor v="Current visitor".
if(v.stopdatems<currentdate)[
ok=true;
-----------------------------------------Visitor--------------------------------------------------------
public class Visitor{
public String name;
public String idnr;
public Date startdate;
public Long startdatems; //startdate.getTime()
public Long stopdatems; //Lets say the visitor wants a trial for a week----> stopdatems=startdatems+(60*60*24*7*1000)
Is this a good way to do this or do you have any other suggestions
Thanks in advance!

Hi,
It's better to use the calendar class to increase the current date by one week or a month.
/Kaj

Similar Messages

  • How to migrate What is the best way to connectold iMac to new iMac

    What is the best way to connect a 2006 iMac to a 2013 iMac? ( Lion to Mountain Lion )
    I have a TM on the older Mac. I understand using set-up is best. I cannot afford to lose
    Any data.
    Thanks.
    OGT

    By Firewire. However, you will need a Thunderbolt to Firewire adaptor from Apple to use on your new iMac.
    See Target Disk Mode.

  • BOM and ECN, what's the best way to do it?

    Hello Experts,
    I want to use ECN to keep track of changes on mulitlevel BOMs, but I am struggeling with understanding how this is done in the best way.
    Basically, my understanding is that if you want to do a change, you create a change master and set a validity date. Then, next time you want to do a change, a new change master is created with its validity date. So you end up with a lot of change masters for the same BOM.
    Now, how am I supposed to report all changes done to a BOM in a userfriendly and easy way? I cannot find a report that gives me changes pr part/BOM number?
    Am I missing the point here or do you have any good ideas?
    rgds
    GAR

    Dear GAR,
    Change number helps you to find out the history of the objects like BOM,material master.
    The history includes the creation,changes and deletion of datas.
    But there is no direct report in SAP where in you will get all the details like in which field the change
    has happened in combination with ECM.
    You can have a look in the reports like CC05,CC04,CC07.
    Still if this does not suit your business requirements means then you have to go for a customized report.
    You can also refer these links related to ECM,
    Re: ECM
    Re: ECM ECR
    Re: ECM for BOM
    http://www.sap-img.com/pp007.htm
    Re: Bom Change Enter change number - to make error message
    Revert back,still if you have more queries.
    Regards
    Mangalraj.S

  • What is the best way to increase the size of a "full" Xserve raid?

    Hi,
    our Xserve raid consists of 2 x 7 x 350GB disks.
    These are arranged in 2 volumes (one per controller), RAID 0+1, 3 disks striped, then mirrored, and such are using 6 of the 7 disks per controller. 1 disk per controller is configured as a hot spare.
    During time both volumes have filled up and now there only are 100GB left on every volume and we need more space
    Is there a way to hot replace 350GB disks by 750GB disks?
    Or is the only way to copy data off, replace disks, and restore data?
    I would guess, that I can replace one disk with a 750GB disk, but only 250GB of it will be used. If I then would wait for reconstruction of that new part, and then replace its counterpart? Would only the first 350GB be reconstructed and the 400GB be lost, or would the raid recognize the free space and allow to add it to the stripes and mirrors?
    Cheers,
    Martin

    A disks in the array need to be the same size, so your guess is correct - if you replace a disk with a larger disk, the additional space will be lost.
    As a result there's no trivial way of doing this.
    Copying off the data, reformatting and restoring the data is the best way to go.
    If that's not possible, you have one small chance thanks to how you've currently configured the arrays as 0+1.
    You could break the mirror on controller 1- that would give you two logical arrays of three disks each. You could then take the data off the 0+1 array on the second controller and put it on the second half of the first controller, leaving the second controller's volumes spare.
    Then destroy both volumes on the second controller and rebuild it as a RAID 5 volume. If you want to retain a hot-spare, this will equate to a 6-disk RAID 5, or about 1.8TB
    Now you move the data from the two RAID 0 arrays on controller 1 onto the RAID 5 array on controller 2 and repeat the process to rebuild the 6 disks into a single RAID 5 volume. You can then redistribute the files as you like.
    Of course, during this process you'll be running with lower (read: no) redundancy, so you had better hope a disk doesn't fail in the process.
    A 6 disk RAID 5 is going to offer about the same performance and redundancy as the two mirrored 3-disk RAID 0 arrays (more performance if those RAID 0 arrays are full), with the advantage that RAID 5 isn't so wasteful of disk space (you lose have your total space to the mirror as opposed to one disks-worth of data to parity in RAID 5).
    Either way, back the data up first.

  • What is the best way to find what version of PDF Reader from Adobe is installed on a windows OS?

    Hi,
    I am developing a .Net App in which i want to find which version of PDF Reader from Adobe is installed on an Windows OS.
    It can be any of the software
    Adobe Reader
    Adobe Acrobat X Pro
    or any other.
    How to find out?

    The best way would be to find and query the AcroRd32.exe executable. The file version information is stored in the executable itself.
    There are lots of places in the registry that you could also potentially access relevant information.
    For example the uninstall string:
    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    Contains a string that you could use to search for the application version.
    How you would do this in .NET I'm not sure but you would use some kind of text search command to search for the relevant text and then use "if exists" condition.

  • How is the best way to send data from local database into remote database ?

    Hi all,
    I need to send data from local Oracle database into remote oracle database. Both sites connected via 128 kbps frame relay connection.
    The sending need to be done once a week, can be done nightly.
    How is the best way to do this ?
    Thank you very much,
    xtanto

    How is the best way to do this ?How much are you planning to send?
    You can use COPY command. Ensure that you have valid database link between two databases.
    Available options are:
    create - creates a new table. errors out if the destination table exists.
    replace - drop the destination table and re-creates with data.
    insert - inserts data if the destination table exists.
    append– appends data into an existing table.
    use set arraysize 5000 -The arraysize specifies the number of rows that SQL*Plus will retrieve from the database at one time.
    copy from scott/tiger@ORCL to scott/tiger@ORCL92 create new_emp using select * from emp;

  • How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

  • My Macbook pro was stolen 09/12, the police just returned it to me. I want to remove all the data and start over. Format the drive's etc. I have windows 7 on 1 partion and mountain lion OSX on the apple partition. How is the best way to do this?

    My Macbook pro was stolen 09/12, the police just returned it to me. I want to remove all the data and start over. Format the drive's etc. I have windows 7 on 1 partion and mountain lion OSX on the apple partition. How is the best way to do this?

    Have a look here...
    what-to-do-when-your-hard-drive-is-full.html

  • What's the best way to load FieldPoint measurement data into PI System?

    I am finding the best way to load data collected by NI Field Point (FP2220) into the PI system of our power plant.
    I found pieces of information about FieldPoint OPC server in NI.com. Not sure if it comes with Field Point Hardware, sold by NI as a separate product or it is actually non-standard NI products. Anyway, I know that there exists a thing called FieldPoint OPC server.
    The PI system I mentioned has a OPC client software called PI-OPC interface. It is able to communicate with standard OPC DA server. If that FieldPoint OPC server is a standard OPC DA server provide data collected by Field Point complying to OPC standard, than that's perfect.
    Anyone familar with PI system and NI product, please help if the above is going to work or if there is a better way to put Fieldpoint data into PI.

    Hi Eric,
    This information really helpful, thanks. Regarding to the NI OPC server for NI FieldPoint, I have the other query.
    In my setup, there are two sets of FieldPoint located in two different locations on my ethernet network. They are going to be controlled by a single PC. If I am going to connect both my FieldPoint sets with OPC standard, how many NI OPC server for FieldPoint do I need to connect to? Are there two NI OPC servers each serves one FieldPoint set? Or there is only NI OPC server which serves both FieldPoint sets?
    I am concerning about the number of NI OPC server instances running, because the number of OPC client license I need to purchase depends on how many OPC server I need to connect to. If one NI OPC server serves both my FieldPoint sets, I only need to buy one OPC client license; otherwise, I need to purchase two. In the future, I am going to have another two sets of FieldPoint sets, so the answer of my query determines how many OPC clients I need to purchase eventually - One or four. A huge price difference.
    Looking forward to your reply.
    Regards,
    Roger

  • What is the Best way To Copy and paste data from 1 book to another

     I have 18 sheets in 5 different books that I want to extract data from specific cells.  What is the best way to do this?  Example:  1 sheet is called Numbers E-O1 data in 13:WXYZ. The data updates and moves up 1 row every time I enter
    a new number. So let's say I enter the number 12. Through a lot of calculations the output goes in 13:WXYZ. To what I call a counter which is a 4 digit number.  Anyways, how can I send that 4 digit number to a totally different sheet?  To bullet
    what I'm talking about
    data in cells Row 13:WXYZ in book called Numbers sheet E-O1
    send data to book called "Vortex Numbers" Sheet E-O row 2001:CDEF
    What formula or Macro can I use to make this work?
    thank you!

    Hello Larbec,
    Syntax:
    '[BookName]SheetName'!Range
    Enter in cell  2001:CDEF:
    ='[Numbers]E-O1'!13:WXYZ
    This assumes that the file is open in Excel. Otherwise you need to add the path:
    'ThePath[BookName]SheetName'!Range
    Best regards George

  • What is the best way to store and search 2D data

    Hi,
    There is a set of data (~10k records ) in 2D dimension.
    like this :
    Col 1, Col 2, Col3....
    What is the best way to store and search those records ?
    Thanks in advance
    Wilson

    Hi,
    Either userObjet[][] if you know how much data you have, and the data size is fixed, or use a list of lists. E.g. A Vector of Vectors (some will probably say that you should use an ArrayList instead, and that could be the case, but it sounds like you would want to display the data later on, and a DefaultTableModel (for JTables) uses a Vector as data holder).
    Kaj

  • What is the best way to consolidate data on two Macs?

    Hi All,
    About to embark on a small project to move all my data on to my MacBook before finally saying goodbye to my trusty iMac.  In order to do this I'll be upgrading the HDD on the MacBook to a large one and using Time Machine to restore all the original data onto the new drive.  This bit I'm good with as I did it before when I upgraded the drive on my old iMac. 
    The main problem I have is that the majority of my photos, music, videos and documents are on my old iMac and I'd like to discuss the best way to merge these with a smaller amount of data that the MacBook has on it.  Both machines are running Snow Leopard and I'm not aware of any tools that are currently available to do something like this although I am aware that Lion is supposed to have features that would consolidate everything to the cloud and might make things quite easy.  This is something I would be willing to spend the £30 or so doing so if anyone has any experience of using Lion to merge everything across Macs to the cloud please let me know if you feel this would be a suitable approach.
    Just to summarise the state my data is in currently and the approach I currently intend to take. 
    Have the Mobile Me service so Mail, Address Book, Calendars and all that stuff are all synced across both machines anyway. 
    Applications - Some stuff on the old Mac that I no longer user but nothing here that I really want to migrate.  Some specific application stuff is mentioned below. 
    Movies - This is the bit that I'm most concerned about.  Have a lot of legacy iMovie stuff on the old iMac which I'd like to keep.  iDVD as well.  Not sure of the best way to get this across and maybe it even warrants a separate discussion. Aside from that most of my older video stuff and projects are on the iMac with the newer stuff on the MacBook.  I'm unaware of any function to export and import this but I have a large HDD which I can use to copy stuff over and am going to look into this a bit further.  There will be a small amount of duplication here but this is manageable. 
    Documents - Will just copy these across and organise them as and when I need them.  Again, a small amount of duplication but this is manageable. 
    Music - Pretty much all my stuff the old iMac.  Can just export this and copy it onto the MacBook. 
    Pictures - Bit complicated this.  Most of my stuff on the old iMac but some newer albums on the new MacBook.  No duplication so presuming I can just export the library off the old iMac and import it on to the new MacBook. 
    No websites or anything like that. 
    iPhone currently syncs with iMac but once I have all the stuff over it should not be too hard to change this. 
    Just my user account on each machine that I really want to keep.  Shared documents and other users accounts all contain temporary stuff that I'm happy to lose or archive. 
    Given this is anyone able to offer advice as to 1) Whether this is the best approach? 2) Have I considered everything? 3) Are there any tools that might help me?
    Many thanks,
    Tom

    OK, seeing as no-one replied (presumably because a lot of this information is on the forums in bits elsewhere) here's how I've got on so far.
    Applications - just went through them.  About the only one I needed was my media server app.  Just downloaded and re-installed, had a quick look back though my email to find the license key and it all went on fine.  Installation never seemed quite right on my old machine so solved that problem too. 
    Movies - New iMovies just copied across the clips and projects into their respective folders.  Seems to have worked but haven't checked it all that thoroughly.  Some duplicate footage here but I can trim this out at some point when I get a chance to go through here. 
    Documents - Just copied these across. 
    Photos - used an app called iPhoto Library Manager.  You can download for free but have to pay to use the part that consolidates your libraries.  Possibly if I was willing to spend a bit more time I could have got away without using this but given I didn't know the state of my different libraries and just how many duplicates I had this was too much of a convenience to ignore.  Also got my library into a state where I can now spend a few hours organising it a bit better with Faces / Events etc. 
    Not attempted Music or iPhone sync yet as been stuck trying to solve a problem with my power adapter. 

  • What is the best way to write 10 channels of data each sampled at 4kHz to file?

    Hi everyone,
    I have developed a vi with about 8 AI channels and 2 AO channels... The vi uses a number of parallel while loops to acquire, process, and display continous data.. All data are read at 400 points per loop interation and all synchronously sampled at 4kHz...
    My questions is: Which is the best way of writing the data to file? The "Write Measurement To File.vi" or low-level "open/create file" and "close file" functions? From my understanding there are limitations with both approaches, which I have outlines below..
    The "Write Measurement To File.vi" is simple to use and closes the file after each interation so if the program crashes not all data would necessary be lost; however, the fact it closes and opens the file after each iteration consumes the processor and takes time... This may cause lags or data to be lost, which I absolutely do not want..
    The low-level "open/create file" and "close file" functions involves a bit more coding, but does not require the file to be closed/opened after each iteration; so processor consumption is reduced and associated lag due to continuous open/close operations will not occur.. However, if the program crashes while data is being acquired ALL data in the buffer yet to be written will be lost... This is risky to me...
    Does anyone have any comments or suggestions about which way I should go?... At the end of the day, I want to be able to start/stop the write to file process within a running while loop... To do this can the opn/create file and close file functions even be used (as they will need to be inside a while loop)?
    I think I am ok with the coding... Just the some help to clarify which direction I should go and the pros and cons for each...
    Regards,
    Jack
    Attachments:
    TMS [PXI] FINAL DONE.vi ‏338 KB

    One thing you have not mentioned is how you are consuming the data after you save it.  Your solution should be compatible with whatever software you are using at both ends.
    Your data rate (40kS/s) is relatively slow.  You can achieve it using just about any format from ASCII, to raw binary and TDMS, provided you keep your file open and close operations out of the write loop.  I would recommend a producer/consumer architecture to decouple the data collection from the data writing.  This may not be necessary at the low rates you are using, but it is good practice and would enable you to scale to hardware limited speeds.
    TDMS was designed for logging and is a safe format (<fullDisclosure> I am a National Instruments employee </fullDisclosure> ).  If you are worried about power failures, you should flush it after every write operation, since TDMS can buffer data and write it in larger chunks to give better performance and smaller file sizes.  This will make it slower, but should not be an issue at your write speeds.  Make sure you read up on the use of TDMS and how and when it buffers data so you can make sure your implementation does what you would like it to do.
    If you have further questions, let us know.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • What is the best way to stack DAQ aquired data in labview?

    I'm developing an application to work with an M-series daq card and labview 8.5 to output a signal and then record on 8 differential inputs for a short period of time (~10 ms). I need to stack my data, however, because the incoming signal will be very, very small, even after amplification. So basically i'm running a slightly modified version of the multifunction Synch AI-AO.vi (included with the install of daqmx). What is the best way for me to rerun this vi a set number of times and add new data directly to the old data (not cat-ing or anything, like |sample 1 of run 1| + |sample 1 of run 2| = stacked stample 1).
    A slightly modified version of the mutlifunction synch AI-AO.vi is attached.
    Attachments:
    des_v2_Multi-Function-Synch AI-AO.vi ‏143 KB

    Hi LSU,
    see attachment on how to "stack" several measurements. I simply add the waveforms and use a shift register to keep the last iterations value.
    Writing to files in each iteration is extremly CPU consuming - especially with express vis. Using for loops for just one iteration is "senseless". You could enable the conditional terminal of the for loop to realize your stop feature.
    For your message 4:
    Have you ever tried all the things you asked for? Sometimes it's easiest to just try&error
    And for the "n=n+x" question: It really helps to take the free online courses offered by NI!
    Message Edited by GerdW on 11-11-2009 06:27 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    des_v2_Multi-Function-Synch AI-AO.vi ‏128 KB

  • What is the best way to append data from one field to another?

    I have the following table, table1:
    Name Null? Type
    MAIL_ID NOT NULL NUMBER(10)
    LAST_NAME VARCHAR2(45)
    FIRST_NAME VARCHAR2(45)
    MIDDLE_INITIAL VARCHAR2(1)
    ADDRESS_1 VARCHAR2(45)
    CITY VARCHAR2(35)
    STATE VARCHAR2(2)
    ZIP VARCHAR2(10)
    REMARKS VARCHAR2(200)
    The table has duplicate entries that need to be removed. The records that will be removed need the
    data in the Remarks column appended to the Remarks data of the record that is not deleted.
    For example, the following listing shows a sample of the duplicate records.
    Mail ID Last Name First Name M Address City St ZIP Remarks
    189 BROWN STEPHEN 6706 MOESER LN EL CERRITO CA 94530-2909 Sf7#s124,f16#d7996(NML)[Cl#117][Ml#1649][NMf1#d288][NCf9#d319][SNl#e62]
    211023 BROWN STEPHEN B 6706 MOESER LN EL CERRITO CA 94530 RLl#a12047[IDl#i398]
    287796 BROWN STEPHEN B 6706 MOESER LN EL CERRITO CA 94530 SNl#e1163
    The following listing shows how the kept record should appear after the duplicate records are deleted.
    Mail ID Last Name First Name M Address City St ZIP Remarks
    189 BROWN STEPHEN 6706 MOESER LN EL CERRITO CA 94530-2909 Sf7#s124,f16#d7996(NML)[Cl#117][Ml#1649][NMf1#d288][NCf9#d319][SNl#e62]RLl#a12047[IDl#i398]SNl#e1163
    I have the process of deleting duplicates working but have yet to determine the best way to move
    the Remarks data from the deleted records to the preserved record.
    I know there are probably various ways to approach this.
    Any suggestions will be greatly appreciated!
    Here is the sql for deleting duplicates.
    DELETE FROM table1
    WHERE mail_id in (SELECT mail_id FROM table1
              where not first_name = 'Null' and
    not last_name = 'Null' and
              not city = 'Null' and
              not state = 'Null'and
    not last_name = 'Anon'
              minus
              select min(mail_id) from table1
              group by first_name, last_name, city, state, address_1, organization, title);
    THANKS in advance!!!!

    Here's quick and dirty example probably a better way to do it, but this is what I came up with quickly.
    My table looks like this:
    MAIL_ID LAST FIRST PHONE REMARKS
    123 Ruff Shawn 555-555-5555 Called 10-10-04
    135 Ruff Shawn 555-555-5555 Called 10-12-04
    201 Ruff Shawn 555-555-5555 Called 10-19-04
    The code below will concatenate the remarks column from the rows, and delete the 135 and 201 rows, then update the 123 row with the concatenated remarks.
    declare
    l_remarks varchar2(500);
    l_min_mail_id number;
    begin
    select min(mail_id) into l_min_mail_id
    from test
    group by last, first, phone;
    select remarks into l_remarks from test where mail_id = l_min_mail_id;
    for i in (select mail_id, remarks from test
         where last = 'Ruff'
              and first = 'Shawn'
              and phone = '555-555-5555'
              and mail_id <> l_min_mail_id)
    loop
    l_remarks := l_remarks||','||i.remarks;
    delete from test where mail_id = i.mail_id;
    end loop;
    update test set remarks = l_remarks where mail_id = l_min_mail_id;
    commit;
    end;
    Hope this helps.

Maybe you are looking for

  • Custom Bios PR200 ms-1221

    Hi after updating to Bios 1221_151 my fanspeed have raised one or two levels and temp raised 3-5 deg Celsius a thing I really like to be changed back to the same level my former Bios had 1221_130. If possible the locked functions in bios opened so ad

  • How to adjust the memory size of partition?

    I have the mac os partition and bootcamp partition in my air now. And I installed win7 into the bootcamp for 190G. So I want to adjust the size of bootcamp and enlarge the mac os partition, and create a new partition for using time machine. Can I mak

  • My ipad drained one day. Now, it charges VERY slowly. There is no beep and no lightning bolt sign. But I know it's charging slowly.

    My ipad drained one day. Now, it charges VERY slowly. There is no beep and no lightning bolt sign. But I know it's charging slowly.

  • Need help fixing my hanging(?) ipod 6g

    hi there. i plugged in my 6th gen nano to my laptop and it showed a blinking circle-with-a-backslash-in-the-middle icon and a message 'Do not disconnect.' what gives? i ejected the nano and it changed to a tick icon and 'OK to disconnect'. this is a

  • Viewer on 2nd Monitor Problem

    I just upgraded FCPX to 10.06 and when I show "viewer on 2nd monitor" the image is all screwed up and distorted,  almost like it lost sync.  This has never happened before.  Has anyone had this happen after upgrading FCPx??