Need Help, Extension development

I am new in extension development. I am trying to convert seconds in timestamp
please show where I am wrong. *using niotron ide

library
Capture

package com.mfd.endtime;

import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;


import java.util.*;

@DesignerComponent(
        version = 1,
        description = "",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "")

@SimpleObject(external = true)
//Libraries
@UsesLibraries(libraries = "java-util-1.9.2.jar")
//Permissions
@UsesPermissions(permissionNames = "")

public class EndTime extends AndroidNonvisibleComponent {

    //Activity and Context
    private Context context;
    private Activity activity;

    public EndTime(ComponentContainer container){
        super(container.$form());
        this.activity = container.$context();
        this.context = container.$context();
    }

    @SimpleFunction(description = "Sample Function Generated by Niotron")
    public string main(long unix){
   
        //convert seconds to milliseconds
        Date date = new Date(unix*1000L); 
        // format of the date
        SimpleDateFormat jdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        jdf.setTimeZone(TimeZone.getTimeZone("GMT+6"));
        String java_date = jdf.format(date);
        return java_date;
   }


}

2 Likes

In this you write string that’s wrong because String start with big S and you write small s and if provlem is noft solve then show error

2 Likes

Ya @Faraz_Firoz is right.

1 Like

I solved that. now this errors

1 Like

@fahim_shahoriar you have to import this first

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

and actually, you don’t need to use that lib because it is already available, so remove that lib and remove this line too : import java.util.*;

2 Likes

Thank you.
Though I am new in extension development. can you tell me which libraries are
already available
again thank you

2 Likes

you can find it here

2 Likes

Have a look
If any one can create this

1 Like