Can't retrieve correct time and date from netflow records.

209 Views Asked by At

I used jflow-0.3[1] to collect and decode netflow records which I receive from a router. nettrack.net.netflow.Flow.java class contains the code for decoding necessary data from records received. I called getFirst() function of it which returns "The time in Coordinated Universal Time (UTC) seconds when this data collection period began."[2]. Then I converted it into date time format using following code.

  long seconds = getFirst();
  long millis = seconds * 1000;
  Date date = new Date(millis);
  SimpleDateFormat sdf = new SimpleDateFormat("EEEE,MMMM d,yyyy h:mm,a", Locale.ENGLISH);
  sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
  String formattedDate = sdf.format(date);
  System.out.println(formattedDate);

But when I run this I observe weird results for date like Monday,March 2,1970 4:21,PM, Sunday,April 27,2059 4:17,AM,etc. UTC value is also change from very small values like 300 to very large values like 3154137089 which does not make any sense. What is the problem here? how can I solve this?

  1. https://github.com/aptivate/netgraph/tree/master/jflow-0.3
  2. http://www.cisco.com/en/US/docs/net_mgmt/netflow_collection_engine/6.0/tier_one/user/guide/data.html
0

There are 0 best solutions below