Tuesday, 11 June 2013

how to convert long to string in java

for this type of Err ==> Type mismatch: cannot convert from long to String.

public class LongToString {

  public static void main(String q[]){
   
    long lDateTime = new Date().getTime();
        System.out.println("Date() - Time in milliseconds: " + lDateTime);

        Calendar lCDateTime = Calendar.getInstance();
        System.out.println("Calender - Time in milliseconds :" + lCDateTime.getTimeInMillis());
        String s = String.valueOf(lCDateTime.getTimeInMillis());
        System.out.println("Long to Sting  :" + s);
       
}

    }

No comments:

Post a Comment