Convert string YYYY-mm-dd to dd-mm-yyyy format
Hi All,
I am getting a date as a string in YYYY-mm-dd i.e. 2009-12-25.
I want to convert it to 25-Dec-2009.
Please help it really urgent.
Thanks
--Anil
Thanks for the reply.
But I am new to java. I will really appreciate if you could provide some sample code.
I already done googling but could not find anything so finally thought to write a thread.
Thanks once again.
Waiting for reply.
Thanks
--Anil
Similar Messages
-
Convert String to Date and Format the Date Expression in SSRS
Hi,
I have a parameter used to select a month and year string that looks like: jun-2013
I can convert it to a date, but what I want to do is, when a user selects a particular month-year (let's say "jun-2013")
I populate one text box with the date the user selected , and (the challenge Im having is) I want to populate a text box next to the first text box with the month-year 2 months ahead. So if the user selects
jun-2013 textbox A will show jun-2013
and textbox B will show aug-2013..
I have tried:
=Format(Format(CDate(Parameters!month.Value ),
"MM-YYYY" )+ 2 ) -- But this gives an error
This returns the month in number format like "8" for august...
=Format(Format(CDate(Parameters!month.Value ),
"MM" )+ 2 )
What is the proper syntax to give me the result in this format = "aug-2013" ???
Thanks in advance.
MC
M CollierYou can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
In your case, the code would be something like:
var sDate = "2013-01-10";
// Convert string to date
var oDate = util.scand("yyyy-mm-dd", sDate);
// Convert date to new string
var sDate2 = util.printd("mm/dd/yyyy", oDate);
// Set a field value
getField("date2").value = sDate2;
The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started. -
How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date
Hi
Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
Thankshttp://javaalmanac.com/egs/java.text/FormatDateDef.html
Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html) -
Convert a String Mar 7, 2008 to date in yyyy-dd-mm format
Hi,
Please help me to Convert a String Mar 7, 2008 to date in yyyy-dd-mm format..
have to store that Date in SQL Server date field in yyyy-dd-mm.
Regards,I done this and got the desired result 2008-03-07. Thanks... know checking it with my code :)
String ss = "Mar 7, 2008";
//System.out.println(ss);
try{
SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy");
Date date = dateFormat.parse(ss);
System.out.println(date.toString());
System.out.println(new java.sql.Date(date.getTime()));
}catch(Exception ee)
ee.printStackTrace();
} //endsEdited by: bunty_india on May 8, 2008 8:09 PM -
How i convert string(dd/mm/yyyy) to java.util.Date object
<%
try{
String date="1/8/2000";
SimpleDateFormat ts= new SimpleDateFormat("dd-MMM-yyyy");
Date sqlToday = new java.sql.Date(ts.parse(date).getTime());
out.println("I am Here");
out.println("Date:"+sqlToday);
out.println("After Date:");
catch(ParseException e){
e.printStackTrace();
%>It is the code and i cann't get any result.
i am very new to JSTL and netbeans pls help me
Thanks in AdvanceWrite your format string to match the user input. ie yyyy-MM-dd (if that is what the user types in). MMM means month in short words - ie Jan, Feb, Mar etc
Once you parse it into a date, and get a java.sql.Date, you should use a prepared statement and the setDate() method.
Try
dd/MM -
How to convert (YYYY-MM-DD) to (DD-MM-YYYY)
Hi Guys,
I have one doubt on WDJ,
While exporting data into Excel Sheet having date format is showing like the format (YYYY-MM-DD).
But I need to convert into this format (DD-MM-YYYY). Can any one suggest me? How to convert (YYYY-MM-DD) to (DD-MM-YYYY)
I was written this code for getting date from ECC System and Convert to String type.
Date DelivDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getDeliv_Date();
String DelivDate1 = DelivDate.toString();
Date ShtDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getStat_Date();
String ShtDate1 = ShtDate.toString();
//wdComponentAPI.getMessageManager().reportSuccess("ShtDate1::"+ShtDate1);
Date ExptShpDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getExpt_Shp_Date();
String ExptShpDate1 = ExptShpDate.toString();
Regards
Vijay KalluriHi Greg,
Still i haven't resolve the issue.
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
sdf.format(date);
Date DelivDate = wdContext.nodePoDetails_ExcelData().getPoDetails_ExcelDataElementAt(i).getDeliv_Date();
String DelivDate1 = DelivDate.toString();
could you please give me more clarification on above code. if possible.
Regards
Vijay Kalluri -
Trying to convert String to java.sql.Date
I need to convert a String (in the format "yyyy-mm-dd") to java.sql.Date
It was suggested I use the following,
SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
Date result = formater.parse(dbirth.getText());
However, It seem to produce a java.util.Date
Error: found java.util.Date
Required : java.sql.Date
Can anyone help?
Thanks, MarikaI need to convert a String (in the format
"yyyy-mm-dd") to java.sql.Date
It was suggested I use the following,
SimpleDateFormat formater = new
SimpleDateFormat("yyyy-mm-dd");
Date result = formater.parse(dbirth.getText());
However, It seem to produce a java.util.Date
Error: found java.util.Date
Required : java.sql.Date
Can anyone help?
Thanks, Marika SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
java.util.Date parsedDate = formater.parse(dbirth.getText());
java.sql.Date result = new java.sql.Date(parsedDate.getTime()); -
I want convert string to date format in Oracle
Dear All
I want convert string to date format in Oracle,Format is given below
'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'>
Hi Parwez,
I want convert string to date format in Oracle,Format is given below
'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'SELECT TO_DATE('Friday, 02 March 2012 2:44 P.M.', 'DAY, DD MONTH YYYY HH:MI A.M.') from dual;
As well as what the other poster suggested, look here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
HTH,
Paul... -
Convert String to java UTC date then to sql date
Hi,
I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
This is what I did:
String dateAsString = "10/01/2007";
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);
java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
Now I need to store this date and time to MS SQL database.
I used the following code:
java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
But this code give only the date, not time 2007-09-30
Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
Thanks,
semajsemaj07 wrote:
Hi,
I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
This is what I did:
String dateAsString = "10/01/2007";
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);
java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
Now I need to store this date and time to MS SQL database.
I used the following code:
java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
But this code give only the date, not time 2007-09-30
Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
Thanks,
semajTake a look at java.sql.Timestamp:
http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
Edited by: hungyee98 on Oct 17, 2007 8:57 AM -
Hi All,
I am having a String value which is having date in the format 'Mon Apr 14 16:07:52 IST 2008'
Now I want to convert this String to Date with format 'mm/dd/yyyy' , to display as 04/14/2008
Also I want to add 5 days to this date and display the new date 04/19/2008
I don't know How to convert the string which is having date in 'Mon Apr 14 16:07:52 IST 2008' format to format I need.
Please help me.Hi ,
I wrote a class that tries to parse a String Date and converts it to object. However, I found a very interesting thing while testing this code. I was trying to paarse "2008:03:04 16:21:05" string by using
DateFormat.getDateFromString(null,"2008:03:04 16:21:05" )
It should by pass all try loop accept the one with yyyy:MM:dd HH:mm:ss format. But it went inside the try loop which had MM:dd:yyyy HH:mm:ss format and gave me a wrong date object with year 0171, april 03.
Could any one help me to understand why it is happening? as a work around I put MM:dd:yyyy HH:mm:ss at the end of the program and it is giving me correct object as it did not have to go that far before matching the format.
Thanks,
AL-Amin
Code:
import java.text.*;
import java.util.*;
public class DateFormat
public Date getDateFromString(String format, String parseDate)
Date d;
if(format!=null) {
try
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
d = null;
return d;
else {
try
format = "yyyy-MM-dd HH mm ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyy-MM-dd HH_mm_ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyy-MM-dd HH-mm-ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyy-MM-dd-HH-mm-ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyyMMddHHmmss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "MM-dd-yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "dd-MM-yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "MM:dd:yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "dd:MM:yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
try
format = "yyyy:MM:dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
d = sdf.parse(parseDate);
catch(Exception e)
System.out.println(e.toString());
System.out.println("The Date was not of '"+format+" ' format");
d = null;
if(d==null) {
System.err.println("None of the Date format worked. Please modify the calling method and provide a specific format");
return d;
} -
Converting date format yyyy-mm-dd to mm/dd/yyyy
Hi,
I need help converting the above date format. In the database the date is stored as a VARCHAR with the format yyyy-mm-dd
but I would like it changed to DATE with the format mm/dd/yyyy. I tried the following and I keep getting invalid month
select To_date(date_value, 'mm/dd/yyyy') as date_value from table
When I try to convert it to char first before converting to date I get an invalid number error
select to_date(to_char(date_value, 'mm/dd/yyyy'), 'mm/dd/yyyy') as date_value from table
What do I do?
Thanks for your help!!!Hi,
The second argument of TO_DATE tells what format the first argument is already in.
So you want:
select To_date (date_value, 'yyyy-mm-dd') as date_value
from table_x;Format is a quality of strings, not DATEs. Once you have converted your string to a DATE, is is stored in the same internal format as all the other DATEs. Use TO_CHAR to display it in any format you like.
For example:
SELECT TO_CHAR ( TO_DATE (date_value, 'yyyy-mm-dd')
, 'mm/dd/yyyy'
FROM table_x;Things are much easier if you store dates in DATE columns. -
I'm trying to convert a string "2004-08-12" to a date of format "mm/dd/yyyy" like 08/12/2004.
how do I do this?
thanks.SimpleDateFormat sdfInput =
new SimpleDateFormat( "yyyy-MM-dd" );
SimpleDateFormat sdfOutput =
new SimpleDateFormat ( "MM/dd/yyyy" );
String textDate = "2001-01-04";
Date date = sdfInput.parse( textDate );
System.out.println( sdfOutput.format( date ) ); -
Not able to convert string attribute to number and date please help me out
not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out
Hi,
You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
regards,
Nick -
Hi All,
I want to convert the output of Applescript which is in object format to string or text format, am running Applescript with Java, I need to display the output of applescript in Eclipse Java Console, since its object format the output is not properly displayed..
Pls suggest.. I used the below code
repeat with i in allContents
if class of i is button then set the end of allStaticText to contents of i
end repeat
Applscript ouptput
{button 1 of window "Player Installer" of application process "Install Player" of application "System Events", button 2 of window "Player Installer" of application process "Install Player" of application "System Events", button 3 of window "Player Installer" of application process "Install Player" of application "System Events", button "Finish" of UI element 1 of scroll area 1 of window "Player Installer" of application process "Install Player" of application "System Events"}
Java output
<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'want':'butT', 'seld':1, 'from':'obj '{ 'form':'name', 'want':'cwin', 'seld':'utxt'(" Player Installer"), 'from':'obj '{ 'form':'name', 'want':'pcap', 'seld':'utxt'("Install Player"), 'from':'null'() } } }>Here's an improved version of the previous script, where the handler now returns "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"" instead of "button \"2\" of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"":
tell application "System Events"
get button 2 of window 1 of process "TextEdit"
my objectToText(result) --> "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\""
end tell
on objectToText(UI_element)
set theText to ""
tell application "System Events"
repeat
if exists attribute "AXParent" of UI_element then
set theParent to value of attribute "AXParent" of UI_element
set theClass to class of UI_element
if name of UI_element exists then
set theName to name of UI_element
set theText to theText & (theClass as text) & " \"" & theName & "\" of "
else
set k to 0
get UI elements of theParent whose class is theClass
repeat with thisItem in result
set k to k + 1
if contents of thisItem is UI_element then exit repeat
end repeat
set theIndex to k
set theText to theText & (theClass as text) & " " & theIndex & " of "
end if
set UI_element to theParent
else
set theClass to class of UI_element
set theName to name of UI_element
set theText to theText & (theClass as text) & " \"" & theName & "\" of application \"System Events\""
exit repeat
end if
end repeat
end tell
return theText
end objectToText
Message was edited by: Pierre L. -
Convert String variable value to an Object referece type
Hi all,
I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
Let's think that there is a string variable name like,
String name="HelloWorld";
and there is a class name same to the variable value.
class HelloWorld
I am passing this string variable value to a method which is going to make a object of helloworld;
new convertobj().convert("HelloWorld");
class convertobj{
public void convert(String name){
// in hert it is going to create the object of HelloWorld;
// HelloWorld hello=new HelloWorld(); just like this.
now i want to do this from the name variable value.( name na=new name()) like wise.
please let me know if there any possible way to do that.
I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
thanx.Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
John -
How to convert string to an integer in SQL Server 2008
Hi All,
How to convert string to an integer in sql server,
Input : string str="1,2,3,5"
Output would be : 1,2,3,5
Thanks in advance.
Regards,
SunilNo, you cannot convert to INT and get 1,2,3 BUT you can get
1
2
3
Is it ok?
CREATE FUNCTION [dbo].[SplitString]
@str VARCHAR(MAX)
RETURNS @ret TABLE (token VARCHAR(MAX))
AS
BEGIN
DECLARE @x XML
SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
INSERT INTO @ret
SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
FROM @x.nodes('//t') x(i)
RETURN
END
----Usage
SELECT * FROM SplitString ('1,2,3')
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Maybe you are looking for
-
How can I get the InsertionPoint with FindText method.
Hi All: In indesing script, I can find "abc text" with FindText method, and I want to insert a image here, but how can I get the insertionPoint(the FindText method return an object)? any help? Thanks in advance.
-
How to view 3d picture scenewindow in fullscreen?
I would like the scenewindow that renders a 3D picture to enter fullscreen mode (as opposed to a maximized window). Is this possible? Thanks, Joe
-
I am running Photoshop CS5 on a Q6600, 6 gigs of ram 3 Tbytes HD space and a 8600GT 512 video card. CS5 runs great until I add a configurator 2 panel, then strange things happen. When I select a tool using a keyboard shortcut, is changes very slowly
-
Hi There, I am trying to deploy an EJB module into the Sun Application Server 8 using ANT scripts. The given below is the script, I use. <taskdef name="sun-appserv-deploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask"> <cl
-
LR5 Filename Template Editor - Where do I find detailed help?
I would like to export photos to my iPad in {capture date} sequence. I read somewhere (?) that LR5 exports photos in {filename} sequence and not {capture date} sequence and so I have to rename my photos so that the {capture date} dominates the expor