Date Format required to change in java

Ads
 

Date Format required to change in java

can we change the format of date like sql as per our requirements???If yes then please give the detail solution.

View Answers

March 2, 2011 at 4:09 PM

Using SimpleDateFormat class, you can change the format of date.

Here is an example:

import java.util.*;
import java.text.*;
class  DateExample
{
    public static void main(String[] args) 
    {
        Date date=new Date();
        String formats[]={"dd-MM-yyyy","d MMM  yyyy","dd/MM/yyyy","EEE, MMM d,yyyy","dd-MM-yyyy HH:mm:ss"};
        for(int i=0;i<formats.length;i++){
        SimpleDateFormat sdf=new SimpleDateFormat(formats[i]);
        String d=sdf.format(date);
        System.out.println(d);

        }
        }
}

Ads









Related Tutorials/Questions & Answers:
Date Format required to change in java
Date Format required to change in java  can we change the format of date like sql as per our requirements???If yes then please give the detail solution
java format date
java format date  Hi, How can I format the date in the following...) { Date date=new Date(); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); String formattedDate=sdf.format(date
Advertisements
how to add date and change date in java - netbeans
how to add date and change date in java - netbeans  I need to code use to increase date How to get date after 30 days using netbeans
Java Date Format Example
Java Date Format Example You can format date in many ways. In this tutorial Format class is used to format the java date in to the different formats... in the following ways. 1. Create an object of Format class. 2. Set The required date
How to convert date to UTC format in Java?
How to convert date to UTC format in Java?  Hi, What is UTC Date format and How to convert date to UTC format in Java? I need simple to learn... of world. You can use Java program to convert the date in UTC String
How to convert current date to dd mm yyyy format in Java?
How to convert current date to dd mm yyyy format in Java?  Hi, How to convert current date to dd mm yyyy format in Java? In my program I have... date into * dd-mm-yyyy format. You can also change the format * to convert
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
How to convert current date to mm dd yyyy format in Java?
How to convert current date to mm dd yyyy format in Java?  Hi, How to convert current date to mm dd yyyy format in Java? Share me the program... format. You can also change the format * to convert the current date
String to Date format
String to Date format  My Date format is String Eg(Jan 20 2011 ).... How to Change This values Like to database date format Eg(2011-01-20) using java   import java.util.*; import java.text.*; class ChangeDateFormat
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... to format string to date. Here is the full example code: package net.roseindia
How to convert date to string in Java in yyyy-mm-dd format
to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... it to yyyy-mm-dd String format. Here is Java example for converting String Date...How to convert date to string in Java in yyyy-mm-dd format  Hi, I
How to format current date into yyyy-mm-dd in Java
to do this in Java Programming Language. How to format current date...How to format current date into yyyy-mm-dd in Java  Hi, I have requirement to format the date into yyyy-MM-dd format for inserting it into MySQL
String to date with no format
into a date .. this is simple .. but i want to do it without knowing the date format.... but i want to write a java program to find out dis format for me. the result... date format can be (mm-dd-yyyy) if the 99th record also was 06-06-2006
how to get date format in string from date object containing real date in java
how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object containing real date. date frequently vary in from of only month & year
how to get date format in string from date object containing real date in java
how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object containing real date. date frequently vary in from of only month & year
JQuery date change event
JQuery date change event  JQuery date change event I have been designing a date form in HTML and JQuery, wher i need two different date vales start... any specific start date then end date should automatically get change by adding
Java String To Date
the conversion of Java string written into the specified format to a Java date object...Java String To Date In this section you will read about how to convert a string to date. Here you will read how the specified string into date format can
Date auto format
Date auto format  Hi, I have jsp page and Date field with input type. Requirement is, if we enter date as MMDDYY or MMDDYYYY and clicking the tab the date(MMDDYY or MMDDYYYY) have to auto format to MM/DD/YYYY. could you please
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
Hibernate Date Format
This section contains description of Hibernate Date Format
NSDateformatter format Date
NSDateformatter format Date  Hi, What is the correct way of writing NSDateFormatter in string format. Thanks.   For current Date in NSDate... that represent other data types. For example to show the date in string format we'll
date format in javascript
date format in javascript  display date format as dd/mm/yyyy and day... help me. thank u var date=/^\d{2}\/\d{2}\/\d{4}$/ if(document.userform.joindate.value.search(date)==-1) { alert("please enter date format as dd/mm/yyyy
get current date in java in yyyy mm dd hh mm ss format
get current date in java in yyyy mm dd hh mm ss format  Hi, I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string date into the date format. How to convert string to date from format yyyy-mm-dd
Mysql Date Input
date into the required format date("Y-m-d|").     In this example give input the date and convert into the required format. <... into the required format. Understand with Example The Tutorial helps you to understand
Mysql Date Format
Mysql Date Format       Mysql Date Format explains you the way of formatting Date. Understand with Example The Tutorial elaborate an example from 'Mysql Date Format
Java Date
different format of date in Java. Following example creates date object...Java Date  Hi, What is the API for Date management in Java? How use the Java Date API for manipulating date object in Java? Provide some
Date not getting in proper format
Date not getting in proper format  import java.util.*; class Date { public static void main(String[]args) { Date d = new Date(100000000000L); System.out.print("1st date"+d.toString()); } } out put:- 1st date@3e25
date format updated
date format updated  package LvFrm; import java.awt.Color; import... panel1,panel2,panel3,panel4; Font f1; JComboBox i1,j1,k1; JButton b1,b2; //for date...); panel2.setBorder(b2); frm.add(panel2); /*for date entry & adding
Example program to change Date formatting Symbols
Example program to change Date formatting Symbols... you have learned about how to create date and how to format them and many such examples. Now you will learn how we can change the formatting symbols for date
struts2.2.1 date Format example
struts2.2.1 date Format example. In this example, We will discuss about the different type of date format using struts2.2.1. Directory structure of example... Format Example</title> </head> <body> <h2>Date

Ads