Example usage for org.joda.time DateTimeZone getDefault

List of usage examples for org.joda.time DateTimeZone getDefault

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone getDefault.

Prototype

public static DateTimeZone getDefault() 

Source Link

Document

Gets the default time zone.

Usage

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Converts the specified object to a date and returns a formatted string
 * representing that date in the locale returned by {@link #getLocale()}.
 * // w ww . j  av  a2 s  .c o  m
 * @param format
 *            the formatting instructions
 * @param obj
 *            the date object to be formatted
 * @return a formatted string for this locale representing the specified
 *         date or <code>null</code> if the parameters are invalid
 */
public String format(String format, ReadableInstant date) {
    final String ret;
    if (date == null) {
        ret = null;
    } else {
        final DateTimeFormatter formatter = getDateTimeStyle(format, format, Locale.getDefault(),
                DateTimeZone.getDefault());
        ret = formatter == null ? null : formatter.print(date);
    }
    return ret;
}

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Returns the specified date as a string formatted according to the
 * specified date and/or time styles./*from   w  ww . ja v  a  2s.c om*/
 * 
 * @param dateStyle
 *            the style pattern for the date
 * @param timeStyle
 *            the style pattern for the time
 * @param obj
 *            the date to be formatted
 * @return a formatted representation of the given date
 */
public String format(String dateStyle, String timeStyle, ReadableInstant date) {
    final String ret;
    if (date == null) {
        ret = null;
    } else {
        final DateTimeFormatter formatter = getDateTimeStyle(dateStyle, timeStyle, Locale.getDefault(),
                DateTimeZone.getDefault());
        ret = formatter == null ? null : formatter.print(date);
    }
    return ret;
}

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Returns the specified date as a string formatted according to the
 * specified {@link Locale} and date and/or time styles.
 * /* w w  w  . java  2  s. co  m*/
 * @param dateStyle
 *            the style pattern for the date
 * @param timeStyle
 *            the style pattern for the time
 * @param obj
 *            the date to be formatted
 * @param locale
 *            the {@link Locale} to be used for formatting the date
 * @return a formatted representation of the given date
 */
public String format(String dateStyle, String timeStyle, ReadableInstant date, Locale locale) {
    final String ret;
    if (date == null) {
        ret = null;
    } else {
        final DateTimeFormatter formatter = getDateTimeStyle(dateStyle, timeStyle, locale,
                DateTimeZone.getDefault());
        ret = formatter == null ? null : formatter.print(date);
    }
    return ret;
}

From source file:com.kitac.kinesissamples.consumer.model.KinesisRecord.java

License:Open Source License

/**
 * Set the value of timeString//from w  ww.j  a  v  a 2  s  .  c  o  m
 *
 * @param timeString new value of timeString
 */
@JsonProperty("Time")
public void setTimeString(String timeString) {
    this.timeString = timeString;
    // Convert time string into DateTime.
    String[] buff = this.timeString.split("[()+]");
    long l = Long.parseLong(buff[1]);
    setTime(new DateTime(l, DateTimeZone.getDefault()));

}

From source file:com.kopysoft.chronos.views.ClockFragments.PayPeriod.PayPeriodSummaryView.java

License:Open Source License

public PayPeriodSummaryView(SherlockActivity prnt, PunchTable table) {
    super(prnt.getApplicationContext());
    parent = prnt;// w w w  . ja  v a  2 s  . c o m

    setOrientation(LinearLayout.VERTICAL);

    Chronos chrono = new Chronos(parent);
    ListView retView = new ListView(parent);
    retView.setOnItemClickListener(listener);

    Job thisJob = chrono.getAllJobs().get(0);
    chrono.close();

    adapter = new PayPeriodAdapterList(parent, table, thisJob);
    retView.setAdapter(adapter);
    retView.setSelection(position);
    //registerForContextMenu(retView);
    //retView.setOnChildClickListener(childClickListener);

    View header = View.inflate(getContext(), R.layout.header, null);

    if (!showPay()) {
        header.findViewById(R.id.moneyViewText).setVisibility(View.GONE);
        header.findViewById(R.id.moneyViewTotal).setVisibility(View.GONE);
    }

    header.findViewById(R.id.date).setVisibility(View.GONE);
    TextView timeView = (TextView) header.findViewById(R.id.timeViewTotal);
    TextView moneyView = (TextView) header.findViewById(R.id.moneyViewTotal);
    TextView leftHeader = (TextView) header.findViewById(R.id.headerLeft);
    TextView centerHeader = (TextView) header.findViewById(R.id.headerCenter);
    TextView rightHeader = (TextView) header.findViewById(R.id.headerRight);

    DurationHolder dur = adapter.getTime(thisJob.getSaturdayOverride(), thisJob.getSundayOverride());
    int seconds = dur.getTotalTimeWorked().toStandardSeconds().getSeconds();
    int minutes = (seconds / 60) % 60;
    int hours = (seconds / 60 / 60);
    String output = String.format("%d:%02d:%02d", hours, minutes, seconds % 60);
    timeView.setText(output);

    if (enableLog)
        Log.d(TAG, "Start of pay period: " + thisJob.getStartOfPayPeriod());
    if (enableLog)
        Log.d(TAG, "Start of pay period: " + DateTimeZone.getDefault());

    if (enableLog)
        Log.d(TAG, "job: " + thisJob);
    if (enableLog)
        Log.d(TAG, "seconds: " + seconds);
    if (enableLog)
        Log.d(TAG, "dur: " + dur.toString());
    if (enableLog)
        Log.d(TAG, "pay rate: " + thisJob.getPayRate());

    double money = adapter.getPayableTime(dur, thisJob);
    Currency moneyCurrency = Currency.getInstance(Locale.getDefault());
    output = String.format("%s %.2f", moneyCurrency.getSymbol(), money);

    moneyView.setText(output);
    if (enableLog)
        Log.d(TAG, "pay amount: " + output);

    leftHeader.setText("Date");
    centerHeader.setText("");
    rightHeader.setText("Hours Recorded");

    addView(header);
    addView(retView);
}

From source file:com.marklogic.samplestack.web.QnADocumentController.java

License:Apache License

/**
 * Exposes an endpoint for searching QnADocuments.
 * @param combinedQuery A JSON combined query.
 * @param start The index of the first result to return.
 * @return A Search Results JSON response.
 *///from  w  ww. j ava 2s .  c  o m
@RequestMapping(value = "v1/search", method = RequestMethod.POST)
public @ResponseBody JsonNode search(@RequestBody ObjectNode combinedQuery,
        @RequestParam(defaultValue = "1", required = false) long start) {

    ObjectNode combinedQueryObject = (ObjectNode) combinedQuery.get("search");
    if (combinedQueryObject == null) {
        throw new SamplestackSearchException("A Samplestack search must have payload with root key \"search\"");
    }
    JsonNode postedStartNode = combinedQueryObject.get("start");
    if (postedStartNode != null) {
        start = postedStartNode.asLong();
        combinedQueryObject.remove("start");
    }
    JsonNode postedTimeZone = combinedQueryObject.get("timezone");
    DateTimeZone userTimeZone = DateTimeZone.getDefault();
    if (postedTimeZone != null) {
        try {
            userTimeZone = DateTimeZone.forID(postedTimeZone.asText());
        } catch (IllegalArgumentException e) {
            throw new SamplestackInvalidParameterException(
                    "Received unrecognized timezone from browser: " + postedTimeZone.asText());
        }
        combinedQueryObject.remove("timezone");
    }
    // TODO review for presence/absense of date facet as performance question.
    return qnaService.rawSearch(ClientRole.securityContextRole(), combinedQuery, start, userTimeZone);
}

From source file:com.music.util.persistence.PersistentDateTime.java

License:Open Source License

@Override
public void setParameterValues(Properties parameters) {
    // the type doesn't use the default joda-time timezone, but uses the JVM one instead.
    if (parameters == null) {
        parameters = new Properties();
    }//from   w w  w  .ja  v  a 2 s  . c o m
    parameters.setProperty("databaseZone", DateTimeZone.getDefault().getID());
    super.setParameterValues(parameters);
}

From source file:com.mycollab.core.utils.DateTimeUtils.java

License:Open Source License

/**
 * Convert from UTC time to default time zone of system
 *
 * @param timeInMillis/*  w ww.  j av a2 s.c om*/
 * @return
 */
public static Date convertTimeFromUTCToSystemTimezone(long timeInMillis) {
    DateTime dt = new DateTime();
    dt = dt.withMillis(DateTimeZone.getDefault().getOffset(timeInMillis) + timeInMillis);
    dt = dt.withZone(utcZone);
    return dt.toDate();
}

From source file:com.nesscomputing.mojo.numbers.DateField.java

License:Apache License

@Override
public String getPropertyValue() {
    final DateTimeZone timeZone = dateDefinition.getTimezone() == null ? DateTimeZone.getDefault()
            : DateTimeZone.forID(dateDefinition.getTimezone());

    DateTime date = getDateTime(valueProvider.getValue(), timeZone);

    if (date == null && dateDefinition.getValue() != null) {
        date = new DateTime(dateDefinition.getValue(), timeZone);
    }/*from ww w  .  ja v  a2 s  . c  om*/

    if (date == null) {
        date = new DateTime(timeZone);
    }

    final String format = dateDefinition.getFormat();

    if (format == null) {
        return date.toString();
    } else {
        final DateTimeFormatter formatter = DateTimeFormat.forPattern(format);
        return formatter.print(date);
    }
}

From source file:com.nononsenseapps.feeder.ui.ReaderFragment.java

License:Open Source License

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final int theLayout;
    if (TabletUtils.isTablet(getActivity())) {
        theLayout = R.layout.fragment_reader_tablet;
    } else {//www.j  av a 2 s  . c o  m
        theLayout = R.layout.fragment_reader;
    }
    View rootView = inflater.inflate(theLayout, container, false);

    mScrollView = (ObservableScrollView) rootView.findViewById(R.id.scroll_view);
    mTitleTextView = (TextView) rootView.findViewById(R.id.story_title);
    mBodyTextView = (TextView) rootView.findViewById(R.id.story_body);
    mAuthorTextView = (TextView) rootView.findViewById(R.id.story_author);
    mFeedTitleTextView = (TextView) rootView.findViewById(R.id.story_feedtitle);

    if (mRssItem.title == null) {
        mTitleTextView.setText("Nothing to display!");
    } else {
        mTitleTextView.setText(htmlformatter.toSpanned(mRssItem.title, getActivity()));
    }
    if (mRssItem.description == null) {
        mBodyTextView.setText("Nothing to display!");
    } else {
        //Log.d("JONAS", "Text is:\n" + mRssItem.description);
        // Set without images as a place holder
        mBodyTextView.setText(htmlformatter.toSpanned(mRssItem.description, getActivity()));
    }

    if (mRssItem.feedtitle == null) {
        mFeedTitleTextView.setText("NOthing to display!");
    } else {
        mFeedTitleTextView.setText(mRssItem.feedtitle);
    }

    if (mRssItem.author == null && mRssItem.getPubDate() != null) {
        mAuthorTextView.setText(getString(R.string.on_date,
                mRssItem.getPubDate().withZone(DateTimeZone.getDefault()).toString(dateTimeFormat)));
    } else if (mRssItem.getPubDate() != null) {
        mAuthorTextView.setText(getString(R.string.by_author_on_date, mRssItem.author,
                mRssItem.getPubDate().withZone(DateTimeZone.getDefault()).toString(dateTimeFormat)));
    } else {
        mAuthorTextView.setVisibility(View.GONE);
    }

    // Load images in text
    getLoaderManager().restartLoader(TEXT_LOADER, new Bundle(), this);

    return rootView;
}