converting long string to date

前端 未结 6 760
盖世英雄少女心
盖世英雄少女心 2020-12-20 02:40

I am getting date value from DB as a long value. I am converting this to string to use parse function. Given below is my code

6条回答
  •  一向
    一向 (楼主)
    2020-12-20 03:24

    Try the following code segment:

            Calendar c = Calendar.getInstance();
            c.setTimeInMillis(Long.parseLong(val));         
            Date d = (Date) c.getTime();        
            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");       
            String time = format.format(d);//this variable time contains the time in the format of "day/month/year".    
    

提交回复
热议问题