Parsing a string by date without using SimpleDateFormat?

I am developing a spring application and in one of my controllers I have the following lines for parsing a string to date and formatting the syntax date to the desired format. But again, I need to parse a formatted string into a date without using SimpleDateFormat, so can this be done?

SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");

Date pick=dateFormat.parse(request.getParameter("pickDate"));
String pick_date=dateFormat2.format(pick);
+5
source share
3 answers

Edit:

I found on wikipedia that there is yyyy-MM-dd in China. check this link date format by country set the language to China, you will get the required date format

try it

String d1="12-27-2010";
    Stirng[] splitdata=d1.split("-");

   int month=Integer.parseInt(splitdata[0]);
 int day=Integer.parseInt(splitdata[1]);
int year=Integer.parseInt(splitdata[2]);

Calender cal=Calender.getInstance(Locale.CHINA);
cal.set(year,month,day);
Date d=cal.getTime();

This should work


, .

:

--

yyyy-MM-dd,

String d1="12-27-2010";
Stirng[] splitdata=d1.split("-");

String s2= splitdate[2]+"-"+splitdate[0]+"-"+splitdate[1];
+5

; . ...

0

You can use the concatenation operator (+) for this

0
source

All Articles