Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.runtime.builtins.types.date.prototype;
 
 
public class ToISOString extends DateTimeFormatter {
    public ToISOString(GlobalContext globalContext) {
        super(globalContext);
    }
    
    @Override
    public Object call(ExecutionContext contextObject selfObject... args) {
        if (!(self instanceof DynDate)) {
            throw new ThrowException(contextcontext.createTypeError("toISOString() may only be used with Dates"));
        }
        DynDate dateObj = (DynDateself;
        if (dateObj.isNaN() ) {
            throw new ThrowExceptioncontextcontext.createRangeError"date is out of range" ));
        }
        
        long t = dateObj.getTimeValue();
        
        if ( t > 8640000000000000L || t <  -8640000000000000L) {
            throw new ThrowExceptioncontextcontext.createRangeError"date is out of range" ));
        }
        
        return format(contextdateObj.getTimeValue());
    }
    @Override
    public String format(ExecutionContext contextlong t) {
        Calendar c = Calendar.getInstance(TimeZone.getTimeZone"GMT" ));
        c.setTimeInMillis(t);
        return String.format("%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS.%1$tLZ"c);
    }
    
    @Override
    public void setFileName() {
        this. = "org/dynjs/runtime/builtins/types/date/prototype/ToISOString.java";
    }
    @Override
    public void setupDebugContext() {
        this. = "<native function: toISOString>";
    }
New to GrepCode? Check out our FAQ X