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
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.
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.
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.
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.
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); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With