D
dkarthik
Hi,
I'm a newbie to Java programming. I am developing a log manager
application, where in log files generated by some other application are
processed and copied to remote location. The log files generated by the
app has name something like below:
rhlin1_1150807460297_1001.log
where in rhlin1 is the hostname and the next value is the
currentTimeMillis() when the file was rolled over and 1001 is some 4
digit consecutive number.
I tried the following snippet of code, to get the date corresponding to
milliseconds value:
import java.util.Date;
import java.util.Locale;
import java.text.DateFormat;
import java.text.ParseException;
public class TimeMillis {
public static void main(String [] args) {
String some_time = "1150807460297";
Date aDate;
DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL,
Locale.US);
try
{
aDate = fmt.parse(some_time);
System.out.println("Date is: "+fmt.format(aDate));
}catch (ParseException e) {
System.out.println(e);
}
return;
}
}
and got an exception:
java.text.ParseException: Unparseable date: "1150807460297"
Is it possible to get the Date corresponding to milliseconds by any
other means? I don't have the control over the application that is
generating log files with this format.
Thanks & Regards,
Karthik
I'm a newbie to Java programming. I am developing a log manager
application, where in log files generated by some other application are
processed and copied to remote location. The log files generated by the
app has name something like below:
rhlin1_1150807460297_1001.log
where in rhlin1 is the hostname and the next value is the
currentTimeMillis() when the file was rolled over and 1001 is some 4
digit consecutive number.
I tried the following snippet of code, to get the date corresponding to
milliseconds value:
import java.util.Date;
import java.util.Locale;
import java.text.DateFormat;
import java.text.ParseException;
public class TimeMillis {
public static void main(String [] args) {
String some_time = "1150807460297";
Date aDate;
DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL,
Locale.US);
try
{
aDate = fmt.parse(some_time);
System.out.println("Date is: "+fmt.format(aDate));
}catch (ParseException e) {
System.out.println(e);
}
return;
}
}
and got an exception:
java.text.ParseException: Unparseable date: "1150807460297"
Is it possible to get the Date corresponding to milliseconds by any
other means? I don't have the control over the application that is
generating log files with this format.
Thanks & Regards,
Karthik