×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    88

    Getting current date and time

    Hi

    I wanted to access the current date and time in my appliction. I am able to get current date but no time for ex if it is 5:07PM it is giving 11:37 AM. I am using NetBeans 5.5. The code which i have used is

    Calendar r = Calendar.getInstance();
    dt.setDate(r.getTime());

    Regards
    Deepa

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: Getting current date and time

    try
    Code:
    Date d = new Date();
    String s = d.toString();
    this string is sth like: dd.mm.yy .. 13:12:07 ...

  3. #3
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    88

    Re: Getting current date and time

    Hi

    For that also i am getting the same. This code works fine in Nokia sets, but in samsung sets it is giving current time with additon of time 5:30.

    Regards

    Deepa

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: Getting current date and time

    on every samsung? perhaps u have the wrong time on your phone. or wrong timezone.

  5. #5
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    88

    Re: Getting current date and time

    Hi

    I had setted current time and date in settings with time zone Delhi+5:30. Then also the same out put. I am thinking subtracting 5:30 by the current time and displaying. Please give me the suggestions.

    Regards

    Deepa

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    25

    Getting current date and time

    Try this code

    TimeZone tz = TimeZone.getTimeZone("GMT+530");// set your time zone

    Calendar cal=Calendar.getInstance(tz);

    Date date=new Date();

    cal.setTime(date);

    System.out.println("Date---->"+cal.get(Calendar.DATE)+"Time----------->"+cal.get(Calendar.HOUR)+"."+cal.get(Calendar.MINUTE));

    Set your timezone first,u didnt set the timezone,so only u got 5.30 hours difference, i think the above code can be easily understand.

    Regards
    Sasi Kumar T
    tsasikumarmca(at)gmail(dot)com
    Last edited by sasikumar31; 2008-06-25 at 06:40.

  7. #7
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    88

    Re: Getting current date and time

    Hi

    Thanks Sasikumar.
    I am able to get current time only in output instruction not in samsung handset , After setting time zone also i am getting current time with addition of 5:30.

    Regards
    Deepa.G

Similar Threads

  1. how to get the current time and date
    By Bhoopathi Kummara in forum Symbian
    Replies: 4
    Last Post: 2008-01-08, 11:32
  2. Pim toSerialFormat writes the current time and date
    By ianstrain in forum Mobile Java General
    Replies: 2
    Last Post: 2007-09-20, 10:09
  3. Displaying Current date time in SMS??
    By arunjadhav_v in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2005-08-13, 12:22
  4. How to display current time and date?
    By yanxiang in forum Symbian User Interface
    Replies: 5
    Last Post: 2004-11-04, 08:04
  5. How to display current time and date?
    By yanxiang in forum Symbian
    Replies: 3
    Last Post: 2004-03-10, 15:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×