How to compare user entered date with current date

Hi all
my requirement is, user allowed select one date, in code i have compare this date with current day date. it should be 15days gap other wise display error message.
I am worried about how to get current date in code. Is there any code to get current date. please reply me with code or mail me at [email protected]
Thanx
keerthi

Keerthi,
Use the method <b>getDifference()</b> of the DateHelper.java available here.<a href="http://www.koders.com/java/fid14A61FEB1B45A64E42E1DCAD7070B46AE46340BA.aspx">DateHelper</a>
1. Create a new folder, say Util under your src folder. (com.xyz.util)
2. Put this DateHelper.java file in that folder,(com.xyz.util) .
3. Now, write an import statement for this java class in the required view.
4. Use the getDifference() method of this class to the difference in days between two days.
Or
Simply use this code.
// Get msec from each, and subtract.
long diff = currDate.getTime() - selectedDate.getTime();
int noOfDays = diff / (1000 * 60 * 60 * 24);
where currDate is today's Date and selectedDate is the Date selected by the User.
Bala

Similar Messages

  • How to initiate java.util.Date with current date

    Hi
    Thank you for readingmy post.
    how i can initiate a Date object with current Date ?
    Thank you

    Please refer to the API for this type of information
    Date()
    Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

  • Replacing net due date with current date in invoice document

    Dear all,
    We  are having a functionality of replacing the net due date in the current date  with reference to the Posting area entry. in the invoice document .Can anybody tell me where and in which event we can maintain this .
    Susmita

    The obvious answer here is to have payment terms which are due immediately, and then set the transaction to use the posting date as the baseline date - that is done in the main/sub definitions within the TE305 customizing.
    regards,
    bill.

  • How to compare a date with current date

    I have 3 drop menus for a user to choose day, month and year. After the user submit the form, my system should be able to detect whether the date chosen has passed compared to TODAY's day. I thought I could compare the day, month and year as integers, but it sounds quite tedious with this integer combination. I wonder if there is any methods available to compare dates. I come to know that I can use something like Calendar.before(). Could anyone give me some idea?

    I'm little confused with your suggestion since I'm new in Java and JSP. I hope you could give me some more hints. Anyway, I got this thing but couldn't really apply it:
    public boolean before(Date when)
    Tests if this date is before the specified date.
    Parameters:
    when - a date.
    Returns:
    true if this date is before the argument date; false otherwise.

  • Compare Hiredate with Current date in PCR

    As per the requirement I have, a certain type of accrual needs to occur on the employee's anniversary date, this accrual should only happen on the first anniversary. How can I compare hire date with current date ignoring the year, and then ignoring the same logic from second year on-wards.
    Can someone please help me with the possible method of implementing this requirement in a time PCR.

    In my humble opinion, I think that you should achieve that by means of an ABAP program, it should be scheduled to run every day and compare the hiring date with the current date of every employee, then create a batch input to Infotype 2013... it would be easier to track and monitor, since you would have all logs in SM35
    Best regards,
    Federico.

  • How to compare a Date data with Current Year and Period Member on FIX

    Hi experts,
    I have a Project dim that each member is a Project (P01, P02...)
    and Account dim that stores information of the each Project (Name, Start date, Finished Date...)
    Finished Date member is in Date data type
    So how can write a IF condition below in order to compare Project Finished Date with Current Year and Period members on FIX
    FIX (@Descendants(Projects), Descendants(All Year), Descendants("Year Total")...)
    IF (@CURRMBR(Period)->@CURRMBR(Year) < Project->FinishedDate)
    Do something...
    Else
    Do something
    Please help me on this. Sorry for my bad grammar. Please ask if there is anything unclear
    Many thanks,
    Huy Van.
    Edited by: Huy Van on Jan 29, 2013 1:14 AM
    Edited by: Huy Van on Jan 29, 2013 2:24 AM
    Edited by: Huy Van on Jan 29, 2013 2:25 AM
    Edited by: Huy Van on Jan 29, 2013 6:04 PM

    Here is what I have done. Post for whom may concern later
    VAR FM; /* Finished Month of Project*/
    VAR FY; /* Finished Year of Project */
    VAR CM; /* Capture Current Month on FIX statments */
    VAR CY; /* Capture Current Year on FIX statments*/
    FIX ( @RELATIVE( "Year", 0), @RELATIVE( "Period", 0), @IDescendants( "Base Projects")....)
    FY = @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 10000, 0);
    FM = @MOD( @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 100, 0), 100);
    /* For FY13 return 13... */
    CY = @JgetDoubleFromString( @CONCATENATE( "20", @SUBSTRING( @NAME( @CURRMBRRANGE( Year, Lev, 0, 0, 0)), 2)));
    /* Set CM value based on currrent Period On FIX statement */
    IF ( @ISMBR( "Jan"))
    CM = 1;
    ELSEIF ( @ISMBR( "Feb"))
    CM = 2;
    ELSEIF ( @ISMBR( "Dec"))
    CM = 12;
    ENDIF
    IF ( CY < FY OR ( CY == FY AND CM < FM))
    Do something...
    ELSE
    Do something...
    ENDIF
    ENDFIX
    Edited by: Huy Van on Feb 19, 2013 11:10 PM
    Edited by: Huy Van on Feb 20, 2013 7:46 PM

  • How to compare current date with past date

    Sample code for comparing current date with past date
    i dont want to Calender.set method to compare it.
    How can i do it?

    PLEASE stay with ONE thread:
    http://forum.java.sun.com/thread.jspa?threadID=5143991&tstart=0

  • How to pick the file which is created with current date

    Hello All,
    I have an FTP server where files are created with current date as PO_CONFIRM_20100701.txt.
    Need to pick the file based on current date. How to pick the above file format using file sender adapter. i.e what file pattern can we use so that file will be picked only on today's date
    Regards,
    Sreenivas.

    Hi Srinivas,
    It depends upon the OS you are using. If unix you can see an example script here:
    http://www.computing.net/answers/dos/batch-file-to-rename-files-by-date/5517.html
    If windows an example here:
    http://en.kioskea.net/forum/affich-87157-finding-and-using-file-date-in-batch-command
    You may need to change slightly to fit your exact requirements. But this would make you to start. Else you can also google to get the script. Here is one link:
    http://www.google.com/#hl=en&source=hp&q=scripttorenamefileshavingtodaysdate&aq=f&aqi=m1&aql=&oq=&gs_rfai=CRE9SwTMsTNjiDpzGhgTm65iFCwAAAKoEBU_QC2i-&fp=e0fa4b5da4f245a4
    Regards,
    ---Satish

  • How to fill a prompt in webi with current date?

    A webi report is being generated on BEx Query.
    IN BEx query variables are defined for some date fields to prefill them with current date.
    Foe ex. there is license start date. For this field variable is defined so that in variable screen License start date is automatically filled with greater than or equal to current date(which is system date). WHich is a mandatory variable.
    On BO side, a webi report is being developed on a Universe (based on this BEx query).
    When the webi report is run, the license start date(mandatory variable in BEx) is automatically prompted, but date is not getting prefiiled with current date.
    How to prefill this prompt with current date?
    the prompt should be like
    LIcense start date >= <current date>

    Hi,
    Yes, it isn't possible to reference anything like 'Current Date' in the universe (like you would with a SQL data source).
    The solution I have seen recently goes like this, I don't know the exact details (so I might have some terminology wrong), but someone with ABAP skills should get what I mean.
    Assuming you want to filter on 0CALDAY.
    In ABAP, create a customer EXIT that calculates the current date as a number (so today might be 40651). Do the same for 0CALDAY.
    In the BEx create a formula variable that references each of those, then a Formula Key Figure (I forget the exact name of them) that's just the current day number minus the 0CALDAY number. This gives you the 'age' of that row of data.
    Your Webi report can then have a built in filter (or prompt with a default value) of, say Age <= 30. The report can be scheduled and will always run with the last 30 day's data.
    We actually did the customer exists to show the 'age' in months.
    Sorry I can't explain it any better, but it's working great for us.
    Hope that helps.

  • How do I know what OS I have on mu iMac? I've used it as a PC for years and need to switch over but I may be out of date with current software.  I think I read Lion somewehere....?

    How do I know what OS I have on my iMac? I've used it as a PC for years and need to switch over but I may be out of date with current software.  I think I read Lion somewehere....?  OS 10.5.8

    Click on the Apple icon at the top left of your menu bar, then About this Mac.
    OS 10.5.8 is Leopard. Lion is 10.7
    As for upgrading:
    Start by checking if you can run Snow Leopard:
    Requirements for OS X 10.6 'Snow Leopard'
    http://support.apple.com/kb/SP575
    The OS 10.6 Snow Leopard install DVD is available for $19.99 from the Apple Store:
    http://store.apple.com/us/product/MC573/mac-os-x-106-snow-leopard
    and in the UK:
    http://store.apple.com/uk/product/MC573/mac-os-x-106-snow-leopard
    but nobody knows for how long it will be available.
    When you have installed it, run Software Update to download and install the latest updates for Snow Leopard to bring it up to 10.6.8, or download the combo update from here:
    http://support.apple.com/kb/DL1399
    Check via Software Update whether further updates are required.
    You should now see the App Store icon, and you now need to set up your account:
    http://support.apple.com/kb/HT4479
    To use iCloud you have to upgrade at least to Lion, but some functions are only available in Mountain Lion:
    http://support.apple.com/kb/HT4759
    You can also purchase the code to use to download Lion (Lion requires an Intel-based Mac with a Core 2 Duo, i3, i5, i7 or Xeon processor and 2GB of RAM, running the latest version of Snow Leopard), or you can purchase Mountain Lion from the App Store - if you can run that:
    http://www.apple.com/osx/specs/

  • I have a large number of photos imported into iPhoto with the dates wrong.  How can I adjust multiple photos (with varying dates) to the same, correct, date?

    I have a large number of photos imported into iPhoto with the dates wrong.  How can I adjust multiple photos (with varying dates) to the same, correct, date?

    If I understand you correctly, when you enter a date in the Adjust Date and Time window, the picture does not update with the date you enter.  If that is the case then something is wrong with iPhoto or your perhaps your library.
    How large a date change are you putting in?  iPhoto currently has an issue with date changes beyond about 60 years at a time.  If the difference between the current date on the image and the date you are entering is beyond that range that may explain why this is not working.
    If that is not the case:
    Remove the following to the trash and restart the computer and try again:
    Home > Library > Caches > com.apple.iphoto
    Home > Library > Preferences > com.apple.iPhoto (There may be more than one. Remove them all.)
    ---NOTE: to get to the "home > library" hold down option on the keyboard and click on "Go" > "Library" while in the Finder.
    Let me know the results.

  • "Exp" utility script with current date dmp file format

    Dear All,
    I want to creat a window batch file script "oralce database 11gr2" in such a way that dmp file automatically created in c:\test folder with oralce _sid and current date.
    C:> exp file=c:\test\ora-sid_date_format.dmp owner=test
    Any help would be appreciated.
    Regards,

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\comp>exp system/sm file=c:\%ORACLE_SID%_%date%_forma
    t.dmp owner=test
    ^C
    C:\Documents and Settings\comp>exp system/sm@test file=c:\%ORACLE_SID%_%date%_
    format.dmp owner=test
    Export: Release 10.2.0.2.0 - Production on Wed May 19 12:41:11 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
    Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user TEST
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user TEST
    About to export TEST's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export TEST's tables via Conventional Path ...
    . . exporting table AGENTSINFO 7 rows exported
    . . exporting table ARCHIVE_SETT 3 rows exported
    . . exporting table ARC_CPAYMENT 0 rows exported
    . . exporting table ARC_CREDIT 2596 rows exported
    . . exporting table ARC_DEBET 4 rows exported
    . . exporting table ARC_DPAYMENT 4 rows exported
    . . exporting table BRANCHESCASH 2 rows exported
    . . exporting table CANCELCOUPON_OPRCODES 17 rows exported
    . . exporting table CHECK_PAYMENTREQUEST 36 rows exported
    . . exporting table CORPCODES 0 rows exported
    . . exporting table CREDIT_MESS 0 rows exported
    . . exporting table CREDIT_PAYMENT 0 rows exported
    . . exporting table CURRENCIES 1 rows exported
    . . exporting table DEBET_MESS 0 rows exported
    . . exporting table DEBET_PAYMENT 0 rows exported
    . . exporting table DIRECTORY 1 rows exported
    . . exporting table MAILSETTINGS 2 rows exported
    . . exporting table PAYCOUPON_OPRCODES 22 rows exported
    . . exporting table PAYMENT_OPRCODES 21 rows exported
    . . exporting table PAYMENT_REQUEST 53 rows exported
    . . exporting table PAYMENT_RESPONSE 53 rows exported
    . . exporting table REP_CANCELCOUPON 0 rows exported
    . . exporting table REP_PAYCOUPON 70 rows exported
    . . exporting table REP_VERIFYCOUPON 121 rows exported
    . . exporting table REQ_CANCELCOUPON 0 rows exported
    . . exporting table REQ_PAYCOUPON 108 rows exported
    . . exporting table REQ_VERIFYCOUPON 124 rows exported
    . . exporting table VERIFYCOUPON_OPRCODES 18 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
    C:\Documents and Settings\chinar>date
    The current date is: 19.05.2010
    Enter the new date: (dd-mm-yy)
    C:\Documents and Settings\comp>SET ORACLE_SID
    ORACLE_SID=SB
    C:\Documents and Settings\comp>
    and result is SB_19.05.2010_format.dmp

  • Interactive Report - comparing user entered text field against a table field - the comparison is not finding a hit when it should.

    Example
    User enters 12345 in a pre filter ----- item_number field and this value exist in the table but its defined as VARCHAR2(2000).
    No match is found.  Do I need to define this text field in a certain way so that a match occurs - say in the element or source for P1_ITEM_NUMBER.
    How does a user entered value of 12345 match a value in the table of 12345 - defined as a varchar2(2000).
    Thanks  

    Why are you storing numbers in a varchar2?
    This is bad designing.  (storing date information in a varchar2 field is even worst.)
    99% of the time, when the number 12345 does not match the string '12345', it is because the value in the table is actually '                         12345'
    Run the following SQL command in the SQL workshop.  (you'll need to adjust to match schema,table,column names)
    select item_number, length( item_number) as string_length
    from schema_name.table_name
    If '12345' does not have a string_length of 5, then you have bad data in your database.

  • XmlDataProvider .... is gone completely in my Xaml file. Why? How many different ways to deal with xml data source through WPF

    I followed a procedure described in a book.
    1. insert "Inventory.xml" file to a project "WpfXmlDataBinding" .
    2. add the XML data source through the data panel of "blend for 2013", named it "InventoryXmlDataStore" and store it in the current document.
    3. dragged and droppped the nodes from the Data panel onto the artboard.
    Then I checked my Xaml file against the one provided by the book
    Xaml file by the book:
    <Window.Resources>
    <!-- This part is missing in my xaml file --><XmlDataProvider x:Key="InventoryDataSource"
    Source="\Inventory.xml"
    d:IsDataSource="True"/>
    <!-- This part is missing in my xaml file -->
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid>
    <ListBox HorizontalAlignment="Left"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="89,65,0,77" Width="200"/>
    </Grid>
    my Xaml file:
    <Window x:Class="WpfXmlDataBinding.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="922" Width="874">
    <Window.Resources>
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource InventoryXmlDataStore}}">
    <ListBox HorizontalAlignment="Left" Height="370"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="65,55,0,0" VerticalAlignment="Top" Width="270"/>     
        </Grid>
    </Window>
    All looks quite the same except the <XmlDataProvider ....> part under <Window.Resources>, which is gone completely in my Xaml file.
    1, Why?
    2, How many different ways to deal with xml data source through WPF?
    Thanks, guys.
    (ps My "WpfXmlDataBinding" runs without problem through.)

    Never do yourself down Richard.
    Leave that to other people.
    It's quite common for smart developers to think they're not as good as they are.
    I coach a fair bit and it's a surprisingly common feeling.
    And to repeat.
    Never use anything ends .. provider.  They're for trivial demo apps.  Transform xml into objects and use them.  Write it back as xml.  Preferably, use a database.
    You want to read a little mvvm theory first.
    http://en.wikipedia.org/wiki/Model_View_ViewModel
    Whatever you do, don't read Josh Smiths explanation.  I used to recommend it but it confuses the heck out newbies. Leave that until later.
    Laurent Bugnion did a great presentation at mix10.  Unfortunately that doesn't seem to be working on the MS site, but I have a copy.  Download and watch:
    http://1drv.ms/1IYxl3z
    I'm writing an article at the moment which is aimed at beginners.
    http://social.technet.microsoft.com/wiki/contents/articles/30564.wpf-uneventful-mvvm.aspx
    The sample is just a collection of techniques really.
    I have a sample which involves no real data but is intended to illustrate some aspects of how viewmodels "do stuff" and how you use datatemplates to generate UI.
    I can't remember if I recommended it previously to you:
    https://gallery.technet.microsoft.com/WPF-Dialler-simulator-d782db17
    And I have working samples which are aimed at illustrating line of business architecture.  This is an incomplete step by step series but I  think more than enough to chew on once you've done the previous stuff.
    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
    The write up for step2 is work in progress.
    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • How to calculate correct week startdate with given date

    import java.util.Date;
    public class MyDate
    public static void main(String args[]){
    Date d1 = new Date();
    System.out.println("The system date is "+d1.toString());
    //enter some date and it should get starting date and ending date
    //say for sample I enter 01/23/2006 and it should get
    //start date as 12.00 AM 01/23/2006 and end date as 11.99 01/29/2006
    //and it should automatically do whatever that gets for current
    //date
    Hi,
    I have some date has current date and it should calculate starting date of the week and the
    the next date that is 7 days old with one second less as described below
    //enter some date and it should get starting date and ending date
    //say for sample I enter 01/23/2006 and it should get
    //start date as 12.00 AM 01/23/2006 and end date as 11.99 01/29/2006
    //and it should automatically do whatever that gets for current
    //date
    Any help in this regard is appreciated.
    Thanks
    Chatf

    For starters, you'll want to use the java.util.Calendar class.

Maybe you are looking for

  • My photo album " my photo stream" is no longer on my iPad. How can I get it back?

    My album "my photo stream" isn't on my iPad. Where did it go. I've checked iCloud settings & photo settings. I have rebooted my iPad as well. All updates are complete.

  • Mini software 1.4

    I have a 1st generation ipod mini and the battery has always been crap only lasting around 4 hours. I was wondering whether the new software would make my battery last longer and if so when downloading the updater whether you can just download the mi

  • Problem:obtaing file name using Dynamic configuration of file adapter

    hi all I am using Dynamic configuration for getting file name. I am getting Dynamic configuration in SXMB_MONI containg file name, but payload is empty unlike file i am sending.

  • How to create binary code ("10101") matrix with particles?

    Hi...I am trying to create a group of binary numbers that float across my composition in a loose group - the binary code should appear in lines of text, about 3 to 7 numbers wide (ideally constantly changing the number of digits as it animates). I wa

  • Scaled 4k monitor gives me smaller 1920x1080

    Hello, I just bought the new mac pro 12 core, 2 amd 700, 64 gig of ram AND a Samsung 4k monitor U28D590D. I'm having a strange behaviour (maybe its normal). I'm on 10.9.3 and when I scale the monitor to resolutions smaller than 4k I have smaller 1920