Convert time string hh: mm: its corresponding long value.

Hi all

I want to convert hh: mmtime S to its corresponding values long chain, I also searched supportforums messages but not a post is close to my question how do you please explain... Thanks in advance.

http://www.BlackBerry.com/developers/docs/7.1.0api/java/lang/String.html#Substring(int,%20int) has a pretty good documentation and there is a lot of samples autour.
This allows to mark your string in substrings as
"08" (hours), '00' (minutes) and '00' (seconds).
Integer.parseInt () allows to convert these values in integer values.

The next class you use is calendar. Call instance() to get a Calendar object and http://www.blackberry.com/developers/docs/7.1.0api/java/util/Calendar.html#set(int,%20int) allows to set the appropriate fields.
for example, with hourValue as type int with the value of the substring of the hour and myLittleCalendar as a calendar item:
myLittleCalendar.set (Calendar.HOUR, hourValue);

Note that a newly built calendar a date set to 0, then 01.01.1970, if you set only the component "hour", you will have the time this day.

Tags: BlackBerry Developers

Similar Questions

  • Converts a string to a 32 long

    Hello, how to convert a string in the form of a figure with its real numerical value to format long32.

    Please see the attachment.

    Nevica

    There is a function "decimal string.

  • Converts a string to a military time AM/PM

    Hello

    I'm writing a method that converts a time (in military format) an hour AM/PM.  The format of the original time is:

    17:00

    After the conversion, I wish he was:

    17:00

    So far, I have the following method:

    public String formatTime(String time) {
            String result;
    
            if (!isNullOrBlank(time)) {
                Date date = new Date(HttpDateParser.parse(time));
                DateFormat sdf = new SimpleDateFormat("h:mm a");
    
                if (date == null) {
                    result = time;
                } else {
                    result = sdf.format(date).toLowerCase();
                }
            } else {
                result = time;
            }
    
            return result;
    
        }
    

    Now, it formats the time without problem, but the time is bad.  That's because it's in GMT format (as explained in this post, the time will be formatted based on the local time zone: http://supportforums.blackberry.com/t5/Java-Development/How-to-get-the-current-time-in-GMT/m-p/18328...)

    Someone with experience of development in the form of time without taking into account time zone?

    Thank you.

    I suspect the results you get from the analysis of HttpDateParser are in fact all 0.  Which means that the time GMT, you will get is midnight Jan 1, 1970, and so the time you will get is 12:00.  However, I suspect that your local time is 5 hours before GMT, so when the local time out, you get 19:00 the previous day.

    You want to check that?

    If you get 0, I think that you have to parse the date yourself - that is really not difficult and there were a few discussions for people to try to do it right.

  • How to convert the string with numbers in U8 with ascii

    Hello

    I have a string with only numbers 0. 9 paper.

    Now, I want to convert to table-U8.

    He works here, but now the problem: How can I change each character to its ascii value?

    Example:

    entry: 123 (string)

    output: x 31, x 32, x 33 (U8-array)

    Thanks for the help

    It's very easy

    String to Byte Array Function
    Have the Palette: string/array/path Conversion functions

    Converts a string to an array of unsigned bytes. Each byte in the array has the ASCII value of the character corresponding to the string.

  • How to convert times from second to hh with CVI

    How to convert times from second to hh with CVI?

    Can anyone advice?

    It's here. As I told you, it's very simple:

    //----------------------------------------------------------------------
    // Function secToHMSstring ()
    //----------------------------------------------------------------------
    /// HIFN secToHMSstring ()
    /// HIFN The function takes an amount of seconds and returns a string with
    /// HIFN the corresponding value in H:M:S format
    /// HIPAR sec/Value in seconds to convert
    /// HIPAR verbose/If True use "hms" separators; if not, use ":" separator
    /// HIPAR string/The output string. It is responsibility of the programmer
    /// HIPAR string/that the string is large enough to keep the resulting text
    /// OUT string
    void secToHMSstring (int sec, int verbose, char *string)
    
    {
        int     hh = 0, mm = 0, ss = 0;
    
        if (sec >= 3600) {
            hh = sec / 3600;
            sec -= hh * 3600;
        }
        if (sec >= 60)
            mm = sec / 60;
        ss = sec - mm * 60;
    
        strcpy (string, "");
        if (verbose) {
            if (hh > 0) sprintf (string, "%s%dh", string, hh);
            if (mm > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%dm", string, mm); }
            if (ss > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%ds", string, ss); }
        }
        else {
            if (hh > 0) sprintf (string, "%s%d:", string, hh);
            if (mm > 0) {
                if (strlen (string)) sprintf (string, "%s%02d:", string, mm); else sprintf (string, "%d:", mm);
            }
            else if (strlen (string))
                strcat (string, "00:");
            if (strlen (string)) sprintf (string, "%s%02d",  string, ss); else sprintf (string, "%d", ss);
        }
    
        return;
    }
    
  • Is there an easy way to get a Date/time string seconds?

    I have 2 strings of the format depending on whether I would like to convert in seconds (since 1900). I need this value to set the t0 in a field.

    Date: ' 30/06/2014 '.

    "Time: '16:06 ' 08."

    Is there a CVI function that will do this conversion for me? If not, is there an easy way to do it?

    Thank you!

    This code should do what you want:



    static time_t calt;
    struct Shared tm tm;
    public static char msg [64];
    public static int AA, mm, DD, hh, mn ss;

    strcpy (msg, ' 2014/06/30 16:06:08 ');

    Extract the date/time string component
    Scan (msg, "%d [x] %d [x] %d [x] %d [x] [x] %d %d", & mm, dd, and yy, & hh, & mn, &ss);)

    Transfer to a struct tm components
    TM.tm_hour = hh;
    TM.tm_min = mn;
    TM.tm_sec = ss;
    TM.tm_year = yy - 1900;
    TM.tm_mon = mm - 1;
    TM.tm_mday = dd;

    Obrtain calendar
    CALT = 0;
    CALT = mktime (&tm);)

  • convert a string to a path

    I want to assign a value to a global variable of the station (type: number) to the local variable (type: number).

    The problem is, that knowledge straight from the global variable of the station at the time of execution.

    I have a string like "StationGlobals.PARAMETER.SWITCH.xx.nRESISTOR_VALUE" - the characters 'xx' variable will be replaced when running...

    Now I want to convert this string to a path variable to assign to the local variable (type: number) the value of the global variable of the station (type: number)

    Do you know how I can do?

    Greetz

    Jonathan K.

    Try

    Locals.nCurrentResistorValue = Evaluate (Locals.sFunctionPath)

  • converting a string to some general engineering

    Hello world

    All know how to convert a string of engineering in a normal formatted string?

    Thank you

    Hi nem.

    in your vi there is no 'CH2-01. Do you mean "DAQ21"?

    See the attachment for a few minor changes (deleted sequence, its inhabitants, to build a better way). Why divide you your berries into 4 parts when you need to rebuild all the berries again?

    Are you sure this isn't a problem of formatting Excel? You set all the numbers in the excel worksheet to display in the form of "numbers"?

    When I try your vi I do not get any number in scientific format in Excel. (And I would say to transpose Excel import data...)

  • With 32-bit and a clean install also takes a long time to start and a very long time to stop.

    I use 32-bit and a clean install also, it takes a very long time to start (and sometimes it will not) and a verlong tike to close

    Hello Duane,

    For more clarity and response, I divided it in its own thread.

    After your post, it seems that Vista 32 bit takes a long time to start and a very long time to stop.

    What are the specifications of material of this machine?

    We might want to try a clean boot and see how that affects the issue.

    More details about this is located at the following link:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    Let us know if this helps solve this problem.

    Best regards

    Matthew_Ha

  • How to convert the string in milliseconds

    Hello

    Please suggest how I can convert a string (October 9, 1989) in milliseconds...

    If it has a certain format, you can use HttpDateParser, otherwise create a calendar object, set the relevant values and get the time to it.

  • Problem with convert the string to date using DateTimeStringConverter

    Hello

    I would like convert string date (JJ/MM/AAAA) - it is useful to compare dates in TableColumns.

    so I use DateTimeStringConverter (the string "01/11/2014" is a value of date picker)

    DateTimeStringConverter format = new DateTimeStringConverter (Locale.FRANCE,

    "dd/MM/YYYY");

    Date d1 = format.fromString("01/11/2014");

    D1. ToString()

    "I do not get the right date, but that date =" Mon Dec 30 00:00:00 THIS 2013!

    I don't understand what the problem is (which in fact should not be a problem)?

    Any ideas?

    Thanks in advance

    Fabrice

    You have an error in the spec use format ' dd/MM/YYYY' instead of 'dd/MM/YYYY '.

    DateTimeStringConverter f = new DateTimeStringConverter(Locale.FRANCE, "dd/MM/yyyy");
    Date d1 = f.fromString("01/11/2014");
    System.out.println(d1.toString()); // --> Sat Nov 01 00:00:00 CET 2014
    

    If you do not need long, I would use DateStringConverter

  • Orchestrator Timer Date Time String pending

    Using VCenter Orchestrator - I have a workflow that will get kicked off via the REST API but the only option of entry, I have my users POV is a string.

    The entrance to the user should look something like 2:125 9 mai 2016:50 PM or similar.

    Is there a way for me to format the string/pass one string in the workflow and the value of the timer to wait on this entry object?

    Any help would be appreciated.

    Thank you.

    OK, if you want to get a value of the user string and convert it into a Date object to be able to link it to the timer.date of the timer element attribute on hold?

    The string to date conversion can be done easily. Here is a code example:

    var datestr = "May 9, 2016 2:25:50 PM";  // user-provided date string
    var dt = new Date(datestr); // parses the string and creates an object of type Date
    System.log(dt);  // log the Date object value
    
  • Help for a date and time string in the format of get-date

    When you take a date / time string of an object:

    The format of the entry is a string and get-date doesn't seem to be able to convert to the

    a System.DateTime.

    I want to compare this value to 30 days so there are get-date ((get-date).adddays(-30))

    When I try the following, it seems to work then import it:

    (get-date - UFormat "%d/%m/%Y %T" ("2010-06-30 00:00:00" ""))

    If I add the following:

    "[datetime]" (get-date - UFormat "%d/%m/%Y %T" ("2010-06-30 00:00:00" ""))

    He can't convert it.

    Without the datetime component, when I try a superior test uses only the date

    the part as well:

    $Test = '2009-10-06 00:00:00.

    If ($Test - gt (get-date - UFormat "%T"("06/05/2010 00:00:00") %d/%m/%Y ""))

    {

    $Tested = 'Yes '.

    }

    On the other

    {

    $Tested = 'no '.

    }

    $tested

    Results in a Yes tentatives being earlier.

    In the script it returns all records where the date is after

    as 05 and ignore the year, month, and time.

    Any help with this would be greatly appreciated.

    Thank you

    This has to do with the 'culture' that you use in your PowerShell session.

    You can use the Get-Culture cmdlet to see that one you use.

    If you try

    [datetime](get-date -UFormat "%m/%d/%Y %T"("30/06/2010 00:00:00"))
    

    The parameter - UFormat produces a string and

    the cast is expected default mm/dd/yyyy format, for the part of the date.

    So, by reversing the month and day of your UFormat string - that has been corrected.

    BTW, I have attached the line because the SW forum do not have hooks.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Adding a 'today' date and time string

    Is it possible to insert a 'live' date/time string and have it appear on several pages.  Have tried to do this without success, I am confident, that it must be possible.

    Hope that I live long enough to really get my mind around all benefits of Dove.

    Thank you

    Grandpa70

    Hello

    You use CP4? Then, it's really simple:

    • Insert a text caption
    • Add to this the caption text system variables

      $$cpInfoCurrentDateString$ $ and

      $$cpInfoCurrentTime$ $

    • in the properties of the text caption, Options, choose "display for the rest of the project.

    The date and time added will be those of the system on the PC (so they must be good values

    Lilybiri

  • [Oracle 8i] How to convert a string (timestamp) in a date?

    I find it difficult to know how to convert a string to a date time stamp (or possibly several).

    The timestamp is 20 positions, character (NOT NULL, CHAR (20))
    in the format: YYYYMMDDHHMMSSUUUUUU
    where Y = year, M = month, D = day, M = Minutes, S = seconds and U = microseconds

    The reason why I want to convert it is so that I can compare a timestamp to each other (that is, I want to be able to find the MIN (timestamp), MAX (timestamp) and make comparisons of inequality).

    Is this possible?

    Thanks in advance for the help on this!

    Hello

    As Damorgan said, if all you want to do is find which is the earlier or later, then you can just compare the strings: they are in a format where it works.

    If you need to do other things, such as compare to today date or see the difference between two of your lines of days, you will need to convert it to date. (He has no reason to convert them to numbers).

    A new TIMESTAMP data type, which manages the fractions of a second, was introduced in Oracle 9.
    Since you use Oracle 8 (depending on your subject line), or it must be
    (1) ignores the microseconds, or
    (2) use a separate column for microseconds.

    Whatever it is, use TO_DATE to convert the first 14 characters in DATE:

    TO_DATE ( SUBSTR (txt, 1, 14)
            , 'YYYYMMDDHH24MISS'
            )
    

    where txt is your column of type CHAR.
    To convert microseconds to a number (between 0 and 999999):

    TO_NUMBER (SUBSTR (txt, 15))
    

Maybe you are looking for

  • Can when I download beta windows of PTC?

    I keep finding web pages pointing me on connect.microsoft.com, yet whe I connect here and try to find PTC Windows or Windows Thin PC, nothing is available. I would like to test the beta version, before its release on July 1, 2011. Thanks in advance.

  • My computer has no validation after a power failure

    I had a power failure while my computer was on when power is relit, the computer starts normally, except I now get a black screen and the message "you may be victim of software counterfeiting.  This copy of windows has failed the genuine Windows vali

  • How can I reinstall my copy of Windows 7 that came on the computer if I had no CD with it?

    I have a Dell Latitude E5400 and it had windows 7 32 bit on it.  I bought it without any of the cd and something went wrong shot, and it wiped the hard drive.  As I said I have no cd for it, but I don't have a Windows XP Pro SP2 cd.  Can I install th

  • Bango: Missing Indonesia sales

    I just got my Bill from Bango for December 2012. I was surpised to see that revenues are much lower than in November (of course, there is a decline constant saled BBOS apps but not as steep). After I examined the Bill, it seems that there is no sale

  • Invalid field

    Hi all I have two areas of labels of the gains of land vefticalfield first manager.when label focus wil change to yellow color of his text. Along with this, I need second label field to change its color... That is to say, when the first label field g