Skip to Content
author's profile photo Former Member
Former Member

UDF to increment date

Hi,

I have a incoming date of format YYYY:MM:DD-HH:MM:SS

We need to increment the time by 10 minutes. Can anyone help me with the UDF.

TIA

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2013 at 11:57 AM

    Hi Kiran,

    YYYY:MM:DD-HH:MM:SS is not standard date format . I assume that format is "yyyy-MM-dd HH:mm:ss".

    Very simple to increment minutes by 10 from UDF .

    In function, make argument as string .Use the code below and return the value .

    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    Date date = new Date () ;

    try

    {

    date = ( Date )formatter.parse(var1);

    }

    catch ( ParseException e){}

    Calendar clndr = Calendar.getInstance();

    clndr.setTime(date);

    clndr.add(clndr.MINUTE, 10);

    date = clndr.getTime();

    String strDate = formatter.format(date);

    return strDate;

    This will complete your requirement .

    thanks and regards,

    Anup Banerjee

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2013 at 09:04 AM

    Hi,

    Use the below logic.Fine tune it as per your req.

    import java.util.Calendar;

    Date Inputtime

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(Inputtime);
    calendar.add(Calendar.MINUTE, 10);
    Inputtime = calendar.getTime();


    Regrads

    Venkat

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.