Any Expert on Date and Calendar????

Once I set my own calendar .. why it's not keeping my calendar and printing the date and time onwards from my set date time...
I just print only one time the date/time but later in my thread, it prints OS date and time....?
Any Ideas??
import java.util.*;
import java.text.*;
public class DateCheck {
  DateCheck(){
    public static void main(String[] args){
        System.out.println("System  bb");
  //      DateCheck d = new DateCheck();
               System.out.println("In constructor");
        Calendar d3 = Calendar.getInstance();
        d3.set(Calendar.YEAR,2005);
        d3.set(Calendar.MONTH,Calendar.OCTOBER);
        d3.set(Calendar.DAY_OF_MONTH,27);
        d3.set(Calendar.HOUR,01);
        d3.set(Calendar.MINUTE,01);
        d3.set(Calendar.SECOND,01);
    //    Date dt = new Date(2005,05,01,01,01);
       System.out.println("Start...")  ;
            try{
                //System.out.println("Here:  " + dfNormal.format(now));
               // System.out.println("There: " + dfGMT.format(new Date()));
                System.out.println(" Five seconds Before : " + d3.getInstance().getTime());
      //          System.out.println(" Five seconds Before date : " + dt.getTime());
                Thread.sleep(5000);
                //  System.exit(0);
            }catch (Exception e){System.out.println("Some Problems" +e);}
        while(true){
            try{
                //System.out.println("Here:  " + dfNormal.format(now));
               // System.out.println("There: " + dfGMT.format(new Date()));
                Thread.sleep(5000);
                System.out.println("NOW : " + d3.getInstance().getTime());
        //         System.out.println(" Now date : " + dt.getTime());
                Thread.sleep(1000);
                //  System.exit(0);
            }catch (Exception e){}
}

Chuck, Thanks for you reply..
But your solution would 'nt work if some one change the system date..
I need some solid solution....
If you do not understand what i am say then do this
Run your solution.. put it in the thread.... and change your time from
your computer... and seee what happens....
Thanks again

Similar Messages

  • TableCellEditor that Supports Both Date and Calendar

    Hi,
    I'm trying to write a TableCellEditor that supports both the Date and Calendar Classes (i.e., my table could have either Dates or Calendar objects, and I want this cell editor to work seamlessly with either one).
    Here is a simplified version of my code:
    public class DateCellEditor extends AbstractCellEditor implements TableCellEditor {
    /** The editor component. */
    private DateChooser editor;
    private Calendar cal;
    public DateCellEditor() {
    super();
    editor = new DateChooser();
    cal = Calendar.getInstance();
    public Object getCellEditorValue() {
    cal.setTime(editor.getDateValue());
    return cal;
    public Component getTableCellEditorComponent (JTable table,
                                                                                                                            Object value,
                                                                                                                            boolean isSelected,
                                                                                                                            int row,
                                                                                                                            int column) {
    if (value != null) {
    if (value instanceof Calendar)
         editor.setDateValue(((Calendar)value).getTime());
         else if (value instanceof Date)
         editor.setDateValue((Date)value);
    return editor;
    As you can see, I've already modified getTableCellEditorComponent to accepted object of class Date or Calendar. My problem arises in the getCellEditorValue method. How do I know which type of object to return? In the code sample above, I'm returning a Calendar object, but I'm not sure how to code this method to return either Calendar OR Date.
    By the way, editor.getDateValue() returns a Date object.
    I could easily write two separate TableCellEditors, but I would prefer a more elegant solution. Any ideas?
    Thanks!
    Karen Prengaman

    If you really must have both objects and don't want to convert one into another, you could add a function like
    setMode(int modetype) {}
    where modetype is either DATE or CALENDAR, and then return the set type when the user calls getValueAt

  • Overview of Dates and Calendar

    hi,
    does anyone know some good links that explain what is going on with Date and Calendar etc..
    It seems quite complicated - is there any docs on the general idea/framework? (and why things have been deprecated etc..)
    I don't know anything about different world calendars, but theres lot on the web, so its more the java specifics I'm interested in!
    thanks,
    asjf

    Don't use Date at all, use Calendar instead (unless you need to use dates in databases). What parts of the Calendar docs aren't clear? The general idea is each instance of Calendar represents a point in time, with methods to change and retrieve various datetime fields.

  • Date and Calendar

    Why is it so confusing to get the time
    can someone tell me what's the best way to get the time

    Why is it so confusing to get the time
    can someone tell me what's the best way to get the
    timefrom java.util.Calendar.getInstance you can get a Calendar object which contains current date and time.
    you can use java.text.SimpleDateFormat to get the string which formatted the date or time.

  • Ical or Calendar (or whatever) doesn't detect dates and calendar names anymore!

    Hi everyone.
    I used to have a weekly email created with automator and ICal, parsing a specific calendar by its name, and creating
    a list of events occurred in the week (monday to sunday) to send. I used an automator ical alarm for this (now called automator CALENDAR alarm???).
    It worked like a charm.
    Enter Mavericks.
    It's doesn't work anymore.
    Couldn't open the file. So I set to edit it and re-create it, but to no avail.
    I've tried to debug it, by going down to basic actions and their output, and I found out that for example:
    - A one action workflow, find calendar events, with date starting this week, doesn't work!
         No output, when I have pretty many events occurring in the week.
         It doesn't work even if I change the condition (today, or 2 days from now etc...)
    - Another single action workflow (still for testing purposes), filter calendar where title contains any calendar name returns nothing, while there are many calendars in the app!
    Can anyone help?
    Did you experience the same problems?

    Any solution on this problem? I'm experiencing the exact same problem on our 2 GHz iMac Core 2 Duo.

  • Date and Calendar object

    Hi there,
    I am trying to display the current seconds by using the following method. It keeps displaying the first value, over and over. I also tried using the date object and got the same result. Can you help me? Do you know why it does that? Thank you.
    Berk Can Celebisoy
    Calendar calendar;
    calendar = calendar.getInstance();
    public static void main(String[] args)
    //just to get in the loop
    while (2+2==4)
    try
    System.out.println(calendar.get(calendar.SECOND));
    //below line is by using the date object
    //System.out.println(date.getSeconds());
    this.sleep(1000);
    catch (InterruptedException e){}
    /////////////////////////////////////

    Thanks for your reply.
    Berk.
    public static void main(String[] args)
    Calendar calendar = null;
    //just to get in the loop
    while (true)
    calendar = Calendar.getInstance(); //get the instance
    each time u loop
    try
    System.out.println(calendar.get(calendar.SECOND));
    Thread.sleep(1000);
    catch (InterruptedException e){}

  • Converting HDV to H.264 for storage. Any simple way dates and clip splits can be preserved?

    THE PROBLEM
    Tapes are one of the riskiest ways to archive footage as not only is there the possibility of tape damage but the very real chance that the camera will fail after a few years leaving you with unplayable footage .. .. .. .. unless you are lucky enough to find a replacement one or are prepared to spend money on obsolete equipment.
    A further disadvantage is the linear nature of tape which takes ages to import or spool through.
    THE SOLUTION
    Digital storage on hard drives, memory sticks or SD cards has none of these problems and your video can be played anywhere on any computer etc.
    Furthermore after converting to H.264, the video is virtually identical in quality and only takes up 35% of the space (using FCP X's convert to H.264 default setting).
    THE SNAGS
    I intend to import all my HDV tapes, stick each one on the FCP X timeline and export it as mentioned above.
    This will reduce my HDV file size to around 4GB which would also fit conveniently on one DVD, as well as the above mentioned storage devices.
    The only problem I can see is that I wll lose the date/time and also the clip-breaks.
    The precise date/time is not a serious problem but I would like to preserve clip breaks if possible, even though the inability to do so would not be too serious.
    THE HELP?
    So have there been any recent developments that would help me with either of these problems cheaply and quickly.
    P.S.  I know that I could burn the date/time on the first frame of every clip but that would take an eternity. I could also export every clip singly to H.264 but that too would take an age.

    Thanks for the reply, however, unless I am missing something there would be no advantage over simply retaining the original imported HDV files and avoiding the additional time taken to create the archive?
    The H.264 route preserves the quality whilst dramatically reducing the file size and will probably be a more universally accepted format than HDV.
    Luckily I can live without the metadata and timecode but it would be nice to be able to preserve it.
    Naturally I have written details but as they are not integral with the video, there is always the strong possibility of them being lost after my demise.
    I intend to keep the HDV tapes and camera of course, but I don't know how long the camera (even when unused) will survive.
    My original Canon Video 8 camcorder, bought in 1992 packed in after 8 years leaving me with 25 unplayable tapes until last year, when by a minor miracle I was able to borrow a Video 8 tape deck.
    Similarly, my first mini-DV camera purchased in 2000, packed in recently but luckily I have another DV camera together with my HDV one which can still play them.
    From the research I have done it seem quite general that many cameras, even when little used, bite the dust after a decade, probably due to electronic deterioration/malfunction. They work perfectly but the next time you use them the transport mechanism refuses to function  even though there is obviously no mechanical wear.

  • Where do Date and Calendar get the current date?

    The server's time is correct, but my Java application is one hour fast... Why could that be?

    Maybe because Java has a different notion of "local time zone" than whatever you use to check the time.
    Try checking the local timezone that Java thinks is in effect and compare this with whatever the OS provides.
    A common case seems to be that Java has more up-to-date timezone data than the OS and Java is actually true.
    And: you could easily make a mistake by converting Date/Calendar/... around an mess up the timezone information (don't ask me how exactly, but I've seen it before).

  • How can I get Chinese characters in the date and calendar?

    The other night I was using a friend's Japanese iBook. I noticed that she the day displayed with a Chinese character in the menu bar and in the calendar widget (e.g., Her clock said 月4:27 instead of Monday 4:27), but her interface was in English (no Japanese menus).
    How can I set the day to display with a Chinese character?
    iBook G4 12   Mac OS X (10.4.8)  

    System Preferences/International/Formats/Region/Japan

  • Question on Dates and Calendar

    i need to find the number of days between 2 given dates. For example, the number of days between Nov 29th 2006and Dec 3rd 2006 is 4. The number of days between Nov 10th and Nov 15th is 5. How do i do this? Is there an api for doing this?

    No API does this; by using the Claendar and related classes it's easily calculated. See these:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=date+difference&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums

  • Financial Reporting - Derived data and calendar periods

    I have two questions with Financial Reporting
    1. I have a P&L report that shows the full 12 months. FR displays the derived data of the next actual period even if there has been no consol. It therefore looks like all the data has been reversed to zero. Is there a setting to stop FR from displaying derived data?
    2. The application has a June year end. We want to display in the report titles the months based on their calender year rather than the fiscal year. This means that for Sept we want Sept 2011 to display, not Sept 2012 that will come from the Year dimension. Is there a function to handle that?
    regards

    1. I have a P&L report that shows the full 12 months. FR displays the derived data of the next actual period even if there has been no consol. It therefore looks like all the data has been reversed to zero. Is there a setting to stop FR from displaying derived data?
    The answer for this might be the VIEW dimension.If u have taken YTD please change it to Periodic and give a try.
    2. The application has a June year end. We want to display in the report titles the months based on their calender year rather than the fiscal year. This means that for Sept we want Sept 2011 to display, not Sept 2012 that will come from the Year dimension. Is there a function to handle that?
    While creating application profile we have a choice to select the years or just look into application settings.I am not sure just give a try.

  • Date and Calendar Classes

    Well, I'm trying to do a program which valildates a Date given by the User (Does it matter if it's an example using the console, or not?? 'Cuz I'm using it on a Swing application). I WAS using
    date's constructor:
    new Date(y, m, d); but it doesn't do a thing, I can make a new instance
    of Date EVEN if it's February 31st (WHICH IS NOT RIGHT!!!)... how can I do it??

    Im not really sure if I understand what your asking, but I thnk that in the constructor you need some stuff like
    if ( m > 12){
          m = 0
    if ( m == 2 && d > 28 ){ // that would be just for febuary
          d = 0
    }But you probobly would have to do that for every month.
    hope this helps

  • Sudden change date and hour

    Hi,
    yesterday I turned on my Mac and, after typed my password to login in, I found a warning icon telling that the date and the hour is changed to 01 January 2001, 03.05.00 (I don't remember very well the hour).
    So I adjust the date and the hour in the Date and Hour Setting, then I found that the computer asked to select the home wireless network as if it is the first time I used the Pc. Obviously I selected my wireless network with his password, and everything was fine.
    And today is fine.
    But my question is : this sudden change of date and network is work of a malicious cookie, or malware? Or a problem of the OS X?
    I am very careful with downloads from internet: I download only from well-known sites (as university, documents from my friends..), but should I delete the cookies from Safari and Firefox?
    Marta
    PS= before I write this post, I looked for information on my computer, but I don't understand much...

    First, it would be helpful to know what model of computer you have.
    Any time the date and time reset, it is likely because of an SMC reset. This can happen under several scenarios, the most common being that your computer lost power entirely. Current laptops have a coin battery in addition to the main battery that actually powers your computer. That way if the main battery dies, the coin battery still keeps the date and time settings. If the coin battery is bad (or if you have an older computer like an iBook or 12" PowerBook that doesn't have one) and your main battery dies, the date and time will reset.
    If you have an iMac, and your computer was unplugged or if your home was without power for a length of time, it's also possible for this to happen, but it depends on the model as to the specifics.
    It is not likely the cause of a 'malicious cookie or malware', Macs very rarely get viruses.

  • Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?

    Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
    This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
    If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
    Thankyou
    Andrew.

    Andrew,
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
    If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback.

  • I have a 4s...today, for no apparent reason, I am missing data including, calendar appts, notes, contacts and maybe other things that I am not aware of right now.  I did nothing to cause this.  Any ideas on how to restore?

    I seem to have lost a significant amount of data from calendars (ll appts are gone), notes (a good percentage are gone) and contacts (more than 50% are gone).  I have done nothing to cause this.  Any ideas how I might restore everything?

    try turning the phone off and then back on it worked for me.

Maybe you are looking for