I have a Field in Mongo DB called as updated_at
Which will look in DB this way
updated_at : NumberLong(“1355754242785”)
This Updated_at filed is created in Database this way
long now = System.currentTimeMillis();
From one of the DB Record , i have taken a value as
updated_at" : NumberLong("1355754242785"), "volatility12" : "na", "vwap" : "0", "wk52hi" : "0", "wk52hidate" : "----"}
For example say its value is 1355754242785
Is it possible to convert the 1355754242785 , when this was Updated ??
When i tried converting
public class Aim {
public static void main(String[] args) {
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
long now = 1355754242785; // Error here saying out of range
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(now);
System.out.println(now + " = " + formatter.format(calendar.getTime()));
}
}
Change
to
This is a compilation error, for the assignment; that should give you a clue that the problem has nothing to do with dates, just with the fact that a literal number in Java is assumed to be an
int, which have a maximum value of2^31-1. You must add theLsuffix to tell Java that the literal is to be interpreted as along.