Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert long date value to mm/dd/yyyy format [duplicate]

Possible Duplicate:
converting long string to date

I need to convert long date value to mm/dd/yyyy format.my long value is

strDate1="1346524199000" 

please help me

like image 430
andro-girl Avatar asked Aug 01 '12 08:08

andro-girl


People also ask

How do I change long to date format?

Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.

How do I convert a long date to a short date in Excel?

Select the dates you want to format. On the Home tab, in the Number group, click the little arrow next to the Number Format box, and select the desired format - short date, long date or time.

How do I convert date to mm/dd/yyyy in Excel?

First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.

How do I convert a date to a string in Excel?

Here are the steps to do this: Select all the cells that contain dates that you want to convert to text. Go to Data –> Data Tools –> Text to Column. This would instantly convert the dates into text format.


1 Answers

Refer Below code which give the date in String form.

import java.text.SimpleDateFormat; import java.util.Date;    public class Test{      public static void main(String[] args) {         long val = 1346524199000l;         Date date=new Date(val);         SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");         String dateText = df2.format(date);         System.out.println(dateText);     } } 
like image 170
Suresh Avatar answered Sep 28 '22 03:09

Suresh