• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Convert date in difference format

 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a date as String in dd/mm/yyyy (07/12/2005) format.

I want to convert it into dd-MMM-yy(07-DEC-05) format.

How to do this?

Are there any free libraries for that?
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Are there any free libraries for that?



Y do u need a seperate utility class for this.

Use SimpleDateFormat and specify the format u want the u get the result.

For examples see here
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is sample code for ur query.

package mypackage;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test
{
public Test()
{

String dateString = new String("07/12/2005");
java.util.Date dtDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
SimpleDateFormat sdfAct = new SimpleDateFormat("dd/mm/yyyy");
try
{
dtDate = sdfAct.parse(dateString);
System.out.println("Date After parsing in required format:"+(sdf.format(dtDate)));
}
catch (ParseException e)
{
System.out.println("Unable to parse the date string");
e.printStackTrace();
}
}

/**
*
* @param args
*/
public static void main(String[] args)
{
Test test = new Test();
}
}
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic