Example usage for java.util Locale CHINA

List of usage examples for java.util Locale CHINA

Introduction

In this page you can find the example usage for java.util Locale CHINA.

Prototype

Locale CHINA

To view the source code for java.util Locale CHINA.

Click Source Link

Document

Useful constant for country.

Usage

From source file:com.feilong.core.util.ResourceBundleUtilTest.java

/**
 * Read all properties to map.
 */
@Test
public void testReadToMap() {
    LOGGER.debug(JsonUtil.format(readToMap(BASE_NAME, Locale.CHINA)));
}

From source file:com.zxy.commons.lang.utils.DatesUtils.java

/**
 * ?/*ww  w. j  a v  a 2 s  .co m*/
 * 
 * @param dateString 
 * @return 
 */
public Date toDate(String dateString) {
    if (StringUtils.isBlank(dateString)) {
        return null;
    }
    SimpleDateFormat df = new SimpleDateFormat(this.getDateType(), Locale.CHINA);
    df.applyPattern(this.getDateType());
    Date date = null;
    try {
        date = df.parse(dateString);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }
    return date;
}

From source file:com.personal.coine.scorpion.jxnuhelper.view.activity.SchoolCalendarActivity.java

@Override
public void renderDate(List<SchoolCalendar> calendarList) {
    AgendaCalendarView schoolCalendarView = (AgendaCalendarView) findViewById(R.id.school_calendar_view);
    Calendar minDate = Calendar.getInstance();
    Calendar maxDate = Calendar.getInstance();

    minDate.add(Calendar.MONTH, -2);
    minDate.set(Calendar.DAY_OF_MONTH, 1);
    maxDate.add(Calendar.YEAR, 1);
    List<CalendarEvent> eventList = new ArrayList<>();
    try {/*from w  w w  .  ja v  a  2  s.c o m*/
        for (int i = 0; i < calendarList.size(); i++) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
            Calendar startTime = Calendar.getInstance();
            Calendar endTime = Calendar.getInstance();
            startTime.setTime(sdf.parse(calendarList.get(i).getStartDate().getDate()));
            endTime.setTime(sdf.parse(calendarList.get(i).getEndDate().getDate()));
            int backColor[] = new int[] { ContextCompat.getColor(this, R.color.orange_dark),
                    ContextCompat.getColor(this, R.color.yellow),
                    ContextCompat.getColor(this, R.color.blue_dark) };
            DrawableCalendarEvent event = new DrawableCalendarEvent(calendarList.get(i).getEventTitle(),
                    calendarList.get(i).getEventContent(), calendarList.get(i).getEventLocation(),
                    backColor[i % 3], startTime, endTime, calendarList.get(i).getAllDay(),
                    android.R.drawable.ic_dialog_info);
            eventList.add(event);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    schoolCalendarView.init(eventList, minDate, maxDate, Locale.CHINA, this);
    schoolCalendarView.addEventRenderer(new DefaultEventRenderer());
}

From source file:org.apache.tiles.definition.TestUrlDefinitionsFactory.java

/**
 * Tests the getDefinition method./*from  ww  w . j a  va  2s  .  c o  m*/
 *
 * @throws Exception If something goes wrong.
 */
@SuppressWarnings("unchecked")
public void testGetDefinition() throws Exception {
    DefinitionsFactory factory = new UrlDefinitionsFactory();

    // Set up multiple data sources.
    URL url1 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs1.xml");
    assertNotNull("Could not load defs1 file.", url1);
    URL url2 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs2.xml");
    assertNotNull("Could not load defs2 file.", url2);
    URL url3 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs3.xml");
    assertNotNull("Could not load defs3 file.", url3);

    factory.addSource(url1);
    factory.addSource(url2);
    factory.addSource(url3);
    factory.init(Collections.EMPTY_MAP);

    TilesRequestContext emptyContext = new MockOnlyLocaleTilesContext(null);
    TilesRequestContext usContext = new MockOnlyLocaleTilesContext(Locale.US);
    TilesRequestContext frenchContext = new MockOnlyLocaleTilesContext(Locale.FRENCH);
    TilesRequestContext chinaContext = new MockOnlyLocaleTilesContext(Locale.CHINA);
    TilesRequestContext canadaFrenchContext = new MockOnlyLocaleTilesContext(Locale.CANADA_FRENCH);

    assertNotNull("test.def1 definition not found.", factory.getDefinition("test.def1", emptyContext));
    assertNotNull("test.def2 definition not found.", factory.getDefinition("test.def2", emptyContext));
    assertNotNull("test.def3 definition not found.", factory.getDefinition("test.def3", emptyContext));
    assertNotNull("test.common definition not found.", factory.getDefinition("test.common", emptyContext));
    assertNotNull("test.common definition in US locale not found.",
            factory.getDefinition("test.common", usContext));
    assertNotNull("test.common definition in FRENCH locale not found.",
            factory.getDefinition("test.common", frenchContext));
    assertNotNull("test.common definition in CHINA locale not found.",
            factory.getDefinition("test.common", chinaContext));
    assertNotNull("test.common.french definition in FRENCH locale not found.",
            factory.getDefinition("test.common.french", frenchContext));
    assertNotNull("test.common.french definition in CANADA_FRENCH locale not found.",
            factory.getDefinition("test.common.french", canadaFrenchContext));
    assertNotNull("test.def.toextend definition not found.",
            factory.getDefinition("test.def.toextend", emptyContext));
    assertNotNull("test.def.overridden definition not found.",
            factory.getDefinition("test.def.overridden", emptyContext));
    assertNotNull("test.def.overridden definition in FRENCH locale not found.",
            factory.getDefinition("test.def.overridden", frenchContext));

    assertEquals("Incorrect default country value", "default",
            factory.getDefinition("test.def1", emptyContext).getAttribute("country").getValue());
    assertEquals("Incorrect US country value", "US",
            factory.getDefinition("test.def1", usContext).getAttribute("country").getValue());
    assertEquals("Incorrect France country value", "France",
            factory.getDefinition("test.def1", frenchContext).getAttribute("country").getValue());
    assertEquals("Incorrect Chinese country value (should be default)", "default",
            factory.getDefinition("test.def1", chinaContext).getAttribute("country").getValue());
    assertEquals("Incorrect default country value", "default",
            factory.getDefinition("test.def.overridden", emptyContext).getAttribute("country").getValue());
    assertEquals("Incorrect default title value", "Definition to be overridden",
            factory.getDefinition("test.def.overridden", emptyContext).getAttribute("title").getValue());
    assertEquals("Incorrect France country value", "France",
            factory.getDefinition("test.def.overridden", frenchContext).getAttribute("country").getValue());
    assertEquals("Incorrect France title value", "Definition to be extended",
            factory.getDefinition("test.def.overridden", frenchContext).getAttribute("title").getValue());
}

From source file:com.sitexa.android.community.utils.DateUtil.java

public static String getPrettyTime(Date date) {
    Date currentDate = new Date();
    Calendar current_cal = Calendar.getInstance(Locale.CHINA);
    Calendar date_cal = Calendar.getInstance(Locale.CHINA);
    if (date == null) {
        date = currentDate;//w  ww  . j a va 2s  .  c o  m
    }
    String time = getHourAndMin(date);
    current_cal.setTime(currentDate);
    date_cal.setTime(date);

    int current_year = current_cal.get(Calendar.YEAR);
    int current_monthOfYear = current_cal.get(Calendar.MONTH);
    int current_dayOfMonth = current_cal.get(Calendar.DAY_OF_MONTH);
    int current_hour = current_cal.get(Calendar.HOUR_OF_DAY);
    int current_minOfHour = current_cal.get(Calendar.MINUTE);

    int year = date_cal.get(Calendar.YEAR);
    int monthOfYear = date_cal.get(Calendar.MONTH);
    int dayOfMonth = date_cal.get(Calendar.DAY_OF_MONTH);
    int hourOfDay = date_cal.get(Calendar.HOUR_OF_DAY);
    int minOfHour = date_cal.get(Calendar.MINUTE);

    if (current_year > year || current_monthOfYear > monthOfYear) {//? ?
        return getTime(date);
    } else if (current_dayOfMonth > dayOfMonth) {//?
        int days = current_dayOfMonth - dayOfMonth;
        String result = "";
        switch (days) {
        case 1:
            result = " " + time;
            break;
        case 2:
            result = "? " + time;
            break;
        default:
            result = days + "?";
            break;
        }
        return result;
    } else if (current_hour > hourOfDay) {//??
        return current_hour - hourOfDay + "??";
    } else if (current_minOfHour > minOfHour) {//?
        return current_minOfHour - minOfHour + "?";
    } else {
        return "";
    }

}

From source file:cn.vlabs.duckling.vwb.ui.servlet.AbstractLoginServlet.java

private void redirectToUmt(HttpServletRequest request, HttpServletResponse response, String viewUrl)
        throws IOException, ServletException {
    Oauth oauth = new Oauth(properties);
    int siteId = getVwbcontext(request).getSiteId();
    VWBContainer container = VWBContainerImpl.findContainer();
    Locale locale = request.getLocale();
    String language = locale.getLanguage() + "_" + locale.getCountry();
    if (!locale.equals(Locale.CHINA)) {
        language = Locale.US.getLanguage() + "_" + Locale.US.getCountry();
    }//w w w.j ava2  s.co m
    if (StringUtils.isEmpty(language)) {
        language = container.getSiteConfig().getProperty(siteId, KeyConstants.SITE_LANGUAGE);
    }

    try {
        String redirectUrl = oauth.getAuthorizeURL(request) + "&state=" + URLEncoder.encode(viewUrl, "UTF-8")
                + "&locale=" + language;
        response.sendRedirect(redirectUrl);
    } catch (UMTOauthConnectException e) {
        throw new ServletException(e);
    }
}

From source file:com.luke.lukef.lukeapp.tools.LukeUtils.java

/**
 * Parses date from MS to the defined format
 *
 * @param submission_date The amount of milliseconds from the Jan 1, 1970 GMT to the desired date
 * @return Date as String in defined format
 *///from  w  w w  .  j a  v  a 2 s  .  c  o  m
public static String parseDateFromMillis(long submission_date) {
    Date date = new Date(submission_date);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.CHINA);
    format.applyPattern("hh:mm dd/MM/yyyy");
    return format.format(date);
}

From source file:org.springframework.security.captcha.CaptchaEntryPoint.java

/**
 * @param redirectUrl StringBuffer.// www .  ja  v a  2 s .c o m
 * @param req http servlet request
 */
private void buildInternalRedirect(StringBuffer redirectUrl, HttpServletRequest req) {
    // construct it
    StringBuffer simpleRedirect = new StringBuffer();

    String scheme = req.getScheme();
    String serverName = req.getServerName();
    int serverPort = portResolver.getServerPort(req);
    String contextPath = req.getContextPath();
    boolean includePort = true;

    if ("http".equals(scheme.toLowerCase(Locale.CHINA)) && (serverPort == DEFAULT_HTTP_PORT)) {
        includePort = false;
    }

    if ("https".equals(scheme.toLowerCase(Locale.CHINA)) && (serverPort == DEFAULT_HTTPS_PORT)) {
        includePort = false;
    }

    simpleRedirect.append(scheme);
    simpleRedirect.append("://");
    simpleRedirect.append(serverName);

    if (includePort) {
        simpleRedirect.append(":");
        simpleRedirect.append(serverPort);
    }

    simpleRedirect.append(contextPath);
    simpleRedirect.append(captchaFormUrl);

    if (forceHttps && req.getScheme().equals("http")) {
        Integer httpPort = Integer.valueOf(portResolver.getServerPort(req));
        Integer httpsPort = (Integer) portMapper.lookupHttpsPort(httpPort);

        if (httpsPort != null) {
            if (httpsPort.intValue() == DEFAULT_HTTPS_PORT) {
                includePort = false;
            } else {
                includePort = true;
            }

            redirectUrl.append("https://");
            redirectUrl.append(serverName);

            if (includePort) {
                redirectUrl.append(":");
                redirectUrl.append(httpsPort);
            }

            redirectUrl.append(contextPath);
            redirectUrl.append(captchaFormUrl);
        } else {
            redirectUrl.append(simpleRedirect);
        }
    } else {
        redirectUrl.append(simpleRedirect);
    }
}

From source file:rml.controller.ShopController.java

@RequestMapping(value = "/Shop", method = RequestMethod.GET)
@ResponseBody/*from   w ww.j  a v  a  2  s.com*/
public Object shopLogin(Shop shop) {

    ReturnJson returnJson = new ReturnJson();
    returnJson.setErrorCode(1000);
    returnJson.setReturnMessage("?");
    returnJson.setServerStatus(0);

    if (StringUtils.isEmpty(shop.getMobile()) || StringUtils.isEmpty(shop.getPassword())) {

        returnJson.setErrorCode(1001);
        returnJson.setReturnMessage("?" + shop.toString());
        returnJson.setServerStatus(1);
        return returnJson;
    }
    String result1 = MD5.GetMD5Code(shop.getRandomKey() + "at^&*ta");
    if (!result1.equals(shop.getSecretKey())) {
        returnJson.setErrorCode(99999);
        returnJson.setReturnMessage("" + shop.toString());
        returnJson.setServerStatus(1);
        return returnJson;
    }
    try {
        shop.setPassword(MD5.GetMD5Code(shop.getPassword()));
        Shop shop1 = shopService.getShop(shop);
        if (shop1 == null) {
            returnJson.setErrorCode(1002);
            returnJson.setReturnMessage("??");
            returnJson.setServerStatus(1);
            return returnJson;
        }
        if (shop1.getStatus() == 1) {
            returnJson.setErrorCode(1003);
            returnJson.setReturnMessage(",");
            returnJson.setServerStatus(1);
            return returnJson;
        }
        if (shop1.getStatus() == 3) {
            returnJson.setErrorCode(1004);
            returnJson.setReturnMessage("");
            returnJson.setServerStatus(1);
            return returnJson;
        }
        Date today = new Date();
        Order order = new Order();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(new Date());
        dateString = dateString + " 00:00:00";
        order.setStartDate(dateString);
        SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
        dateString = formatter1.format(new Date());
        order.setEndDate(dateString);
        order.setShopId(shop1.getUuid());
        int orderDaily = 0;
        try {
            orderDaily = orderService.getShopReport(order);
        } catch (Exception e) {

        }
        Calendar calendar = Calendar.getInstance(Locale.CHINA);
        int YEAR = calendar.getMinimum(Calendar.YEAR);// ???()
        int day = calendar.getMinimum(Calendar.DAY_OF_WEEK);// ???()
        calendar.set(Calendar.YEAR, YEAR);
        calendar.set(Calendar.DAY_OF_WEEK, day);
        calendar.set(Calendar.HOUR, 0);
        calendar.set(Calendar.AM_PM, 0);
        calendar.set(Calendar.MINUTE, 0);
        Date date = calendar.getTime();
        int orderTotal = 0;
        order.setStartDate(date.toLocaleString());
        try {
            orderTotal = orderService.getShopReport(order);
        } catch (Exception e) {

        }
        shop1.setMoneyDaily(orderDaily);
        shop1.setMoneyTotal(orderTotal);
        returnJson.setReturnObject(shop1);
    } catch (Exception ex) {
        ex.printStackTrace();
        returnJson.setErrorCode(1005);
        returnJson.setReturnMessage("?");
        returnJson.setServerStatus(2);
        return returnJson;
    }
    return returnJson;
}

From source file:org.openkoala.koala.commons.KoalaDateUtils.java

/**
 * ?<br>/*w  w  w  .  j av a2  s.  c  o m*/
 * generate by: vakin jiang at 2012-6-4
 * 
 * @return
 */
public static Date currentGMTTime() {
    return DateUtils.addHours(Calendar.getInstance(Locale.CHINA).getTime(), -8);
}