I have a silly question for you guys.i am running a java program

public class manish
{
        public static void main(String s[])
        {
                Date d=new Date();
                System.out.println("Date is"+d.toString());
        }
}

while i running this on RHEL 5.2 i am getting this output
Date isFri Jul 08 10:55:30 IST 2011

while in RHEL 5.5 o/p is
Date isFri Jul 08 11:15:26 GMT+05:30 2011


can anybody explain me tha reason .Actually in my complete program i am using substring method.So on rhel 5 My application is not doing the right thing.

Recommended Answers

All 3 Replies

import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;

    private String getDateTime() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        return dateFormat.format(date);
    }

Format Your Date Structure.

but i want the answer to my query.You are ok on your side

import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;

    private String getDateTime() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        return dateFormat.format(date);
    }

Format Your Date Structure.

Output can vary according to your computer's regional settings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.