-
convert date (long since 1970) in YYYY/MM/DD
Hello
how is it possible to convert a date in long format since 1 january 1970
to YYYY/MM/DD HH:MM:SS.
Thank in advance,
Nico
-
Re: convert date (long since 1970) in YYYY/MM/DD
One of the constructors for the java.util.Date class is defined as:
Date(long date)
Allocates a Date object and initializes it to represent the
specified number of milliseconds since the standard base time known as "the
epoch", namely January 1, 1970, 00:00:00 GMT.
(copied from the Java documentation). That sounds like it should work for
the first half of your question. If you want to display a date in a
particular format, you might start by looking at the documentation for class
java.text.SimpleDateFormat.
Nicolas <nsylla@quallaby.fr> wrote in message
news:3948fe86$1@news.devx.com...
>
> Hello
> how is it possible to convert a date in long format since 1 january 1970
> to YYYY/MM/DD HH:MM:SS.
>
>
> Thank in advance,
>
> Nico
-
Re: convert date (long since 1970) in YYYY/MM/DD
You can use SimpleDateFormat class which is in java.text package.
You can convert any format of date to what ever the way you want.
Eg.
import java.text.*;
import java.util.*;
public class Test
{
public static void main(String args[])
SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/DD HH:mm:ss");
String date = fmt.format(Calendar.getInstance().getTime());
System.out.println(date);
}
}
"Nicolas" <nsylla@quallaby.fr> wrote:
>
>Hello
>how is it possible to convert a date in long format since 1 january 1970
>to YYYY/MM/DD HH:MM:SS.
>
>
>Thank in advance,
>
>Nico
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks