answersLogoWhite

0

When you create a SimpleDateFormat object, you specify a pattern String. The contents of the pattern String determine the format of the date and time. For a full description of the pattern's syntax, see the tables in Date Format Pattern Syntax.

The following code formats a date and time according to the pattern String passed to the SimpleDateFormat constructor. The String returned by the format method contains the formatted date and time that are to be displayed. Date today;

String output;

SimpleDateFormat formatter;

formatter = new SimpleDateFormat(pattern, currentLocale);

today = new Date();

output = formatter.format(today);

System.out.println(pattern + " " + output);

The following table shows the output generated by the previous code example when the U.S. Locale is specified:

Customized Date and Time FormatsPatternOutputdd.MM.yy30.06.09yyyy.MM.dd G 'at' hh:mm:ss z2009.06.30 AD at 08:29:36 PDTEEE, MMM d, ''yyTue, Jun 30, '09h:mm a8:29 PMH:mm8:29H:mm:ss:SSS8:28:36:249K:mm a,z8:29 AM,PDTyyyy.MMMMM.dd GGG hh:mm aaa2009.June.30 AD 08:29 AM

source:http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Explanation of import javautilDate?

The import keyword in Java is used to tell the Java compiler where to find different classes and packages.java.util.Date is the location of the Date class: Date is a member of the util package, which is a member of the java package.


Can you convert date into words in java?

yes


How do you convert string to int in Java?

One can convert a string variable to an int variable in Java using the parse integer command. The syntax is int foo = Integer.parseInt("1234"). This line will convert the string in the parenthesis into an integer.


Which is the best way to convert numbers in string under java?

All of the Java number classes have a parse[type] method, like parseInt() in Integer or parseDouble() in Double that convert Strings to primitive numbers. String s = getInput(); int var = Integer.parseInt(s);


How do you convert java data to SQL data?

kill urself


How can someone convert string to int in Java?

To convert string to int in Java, the easiest way is to simply use the method Integer.parseInt(). For more information how to do this, refer to the integer class documents.


Any algo is used for converting class file to java source file?

You need a decompiler to convert class files to java source files. JAD is a Java Decompiler that can do it for you.


How do you convert numbers into words using java?

Using toString() method


What is the code required to convert an integer variable to a string variable in Java?

There are several different methods to convert an integer variable to a string variable in Java. For example, one can use the following code to convert an integer variable to a string variable: Integer.toString(number)


How can you convert byte to string in java?

To convert byte to String in java use the String(bytes, UTF-8); //example for one encoding type. You must know the special encoding that contains a variety of characters.


Java program to convert lowercase to uppercase?

You can use the toUpperCase() method on a String to convert any String to all uppercase.


How can I convert a float to a double in Java?

To convert a float to a double in Java, you can simply assign the float value to a double variable. Java will automatically perform the conversion for you. Here's an example: java float floatValue 10.5f; double doubleValue floatValue; In this example, the float value 10.5f is assigned to the double variable doubleValue, which will now hold the converted double value.


How to convert English words to Telugu words using java coding?

efef


What do you call a Program that runs Java byte code instruction?

Get the JDK & Bluej from net and the rest will be done by them. Java byte codes are stored as *.class ; where "*" represents the class name, in your hard disk. You can download BlueJ as well as JDK from the related link.


When mods for xbox minecraft will come out?

as soon as someone learns to convert java into c++


Why do use typecasting in java?

Type casting is used to convert from one datatype to the other


How do you convert capital string to small in Java?

To convert a String object to lowercase in Java, use the toLowerCase() method. "HELLO".toLowerCase() returns a new String: "hello".


What is deserialization in java?

De-serialization is the opposite process of serialization. This is the process where we convert data that has already been written out onto a stream as part of serialization into Java objects.


How do you convert the java file into JPEG file?

A java file it's only a text file. You can't convert a text file into a image file of any type. What you can do is open your java file in your editor an take an screenshot (you must have a key with the label 'print screen' in your keyboard) then open open some image editor like paint and finilly paste and save your image. Or you can chage the java extention for jpg in your java file and have fun trying to open it (sarcasm, don't do it).


How do you save image in sql using Java?

You can convert the image into a byte stream and save it in the database as a BLOB